From 1062f629fb1999c151e099c459c016a80a080c3d Mon Sep 17 00:00:00 2001 From: suleka96 Date: Thu, 13 Apr 2023 05:04:54 +0530 Subject: [PATCH 01/33] Add tests and changes for on fail error bp support --- .../compiler/parser/BLangNodeBuilder.java | 28 +- .../internal/parser/BallerinaParser.java | 22 +- .../parser/BallerinaParserErrorHandler.java | 2 + .../internal/parser/tree/STNodeFactory.java | 8 +- .../parser/tree/STNodeTransformer.java | 2 +- .../internal/parser/tree/STNodeVisitor.java | 2 +- .../parser/tree/STOnFailClauseNode.java | 30 +- .../internal/parser/tree/STTreeModifier.java | 9 +- .../compiler/syntax/tree/NodeFactory.java | 11 +- .../compiler/syntax/tree/NodeTransformer.java | 2 +- .../compiler/syntax/tree/NodeVisitor.java | 2 +- .../syntax/tree/OnFailClauseNode.java | 41 +- .../compiler/syntax/tree/TreeModifier.java | 12 +- .../syntax/statements/DoStatementTest.java | 24 + .../statements/ForEachStatementTest.java | 26 +- .../syntax/statements/LockStatementTest.java | 24 + .../syntax/statements/MatchStatementTest.java | 24 + .../statements/TransactionStatementTest.java | 56 + .../syntax/statements/WhileStatementTest.java | 24 + .../statements/do-stmt/do_stmt_assert_10.json | 377 ++ .../statements/do-stmt/do_stmt_assert_11.json | 377 ++ .../statements/do-stmt/do_stmt_assert_12.json | 1132 ++++++ .../statements/do-stmt/do_stmt_assert_13.json | 1131 ++++++ .../statements/do-stmt/do_stmt_assert_14.json | 525 +++ .../statements/do-stmt/do_stmt_assert_15.json | 401 +++ .../statements/do-stmt/do_stmt_assert_16.json | 456 +++ .../statements/do-stmt/do_stmt_assert_17.json | 462 +++ .../statements/do-stmt/do_stmt_source_10.bal | 7 + .../statements/do-stmt/do_stmt_source_11.bal | 7 + .../statements/do-stmt/do_stmt_source_12.bal | 19 + .../statements/do-stmt/do_stmt_source_13.bal | 19 + .../statements/do-stmt/do_stmt_source_14.bal | 7 + .../statements/do-stmt/do_stmt_source_15.bal | 7 + .../statements/do-stmt/do_stmt_source_16.bal | 7 + .../statements/do-stmt/do_stmt_source_17.bal | 7 + .../forEach-stmt/forEach_stmt_assert_27.json | 435 +++ .../forEach-stmt/forEach_stmt_assert_28.json | 435 +++ .../forEach-stmt/forEach_stmt_assert_29.json | 1190 +++++++ .../forEach-stmt/forEach_stmt_assert_30.json | 1189 +++++++ .../forEach-stmt/forEach_stmt_assert_31.json | 583 ++++ .../forEach-stmt/forEach_stmt_assert_32.json | 459 +++ .../forEach-stmt/forEach_stmt_assert_33.json | 514 +++ .../forEach-stmt/forEach_stmt_assert_34.json | 520 +++ .../forEach-stmt/forEach_stmt_source_27.bal | 7 + .../forEach-stmt/forEach_stmt_source_28.bal | 7 + .../forEach-stmt/forEach_stmt_source_29.bal | 19 + .../forEach-stmt/forEach_stmt_source_30.bal | 19 + .../forEach-stmt/forEach_stmt_source_31.bal | 7 + .../forEach-stmt/forEach_stmt_source_32.bal | 7 + .../forEach-stmt/forEach_stmt_source_33.bal | 7 + .../forEach-stmt/forEach_stmt_source_34.bal | 7 + .../lock-stmt/lock_stmt_assert_11.json | 377 ++ .../lock-stmt/lock_stmt_assert_12.json | 377 ++ .../lock-stmt/lock_stmt_assert_13.json | 1132 ++++++ .../lock-stmt/lock_stmt_assert_14.json | 1131 ++++++ .../lock-stmt/lock_stmt_assert_15.json | 525 +++ .../lock-stmt/lock_stmt_assert_16.json | 401 +++ .../lock-stmt/lock_stmt_assert_17.json | 456 +++ .../lock-stmt/lock_stmt_assert_18.json | 462 +++ .../lock-stmt/lock_stmt_source_11.bal | 7 + .../lock-stmt/lock_stmt_source_12.bal | 7 + .../lock-stmt/lock_stmt_source_13.bal | 19 + .../lock-stmt/lock_stmt_source_14.bal | 19 + .../lock-stmt/lock_stmt_source_15.bal | 7 + .../lock-stmt/lock_stmt_source_16.bal | 7 + .../lock-stmt/lock_stmt_source_17.bal | 7 + .../lock-stmt/lock_stmt_source_18.bal | 7 + .../match-stmt/match_stmt_assert_24.json | 536 +++ .../match-stmt/match_stmt_assert_25.json | 536 +++ .../match-stmt/match_stmt_assert_26.json | 1291 +++++++ .../match-stmt/match_stmt_assert_27.json | 1290 +++++++ .../match-stmt/match_stmt_assert_28.json | 684 ++++ .../match-stmt/match_stmt_assert_29.json | 560 +++ .../match-stmt/match_stmt_assert_30.json | 615 ++++ .../match-stmt/match_stmt_assert_31.json | 621 ++++ .../match-stmt/match_stmt_source_24.bal | 11 + .../match-stmt/match_stmt_source_25.bal | 11 + .../match-stmt/match_stmt_source_26.bal | 23 + .../match-stmt/match_stmt_source_27.bal | 23 + .../match-stmt/match_stmt_source_28.bal | 11 + .../match-stmt/match_stmt_source_29.bal | 11 + .../match-stmt/match_stmt_source_30.bal | 11 + .../match-stmt/match_stmt_source_31.bal | 11 + .../retry_stmt_assert_08.json | 318 ++ .../retry_stmt_assert_09.json | 318 ++ .../retry_stmt_assert_10.json | 619 ++++ .../retry_stmt_assert_11.json | 618 ++++ .../retry_stmt_assert_12.json | 466 +++ .../retry_stmt_assert_13.json | 342 ++ .../retry_stmt_assert_14.json | 397 +++ .../retry_stmt_assert_15.json | 403 +++ .../transaction-stmt/retry_stmt_source_08.bal | 7 + .../transaction-stmt/retry_stmt_source_09.bal | 7 + .../transaction-stmt/retry_stmt_source_10.bal | 10 + .../transaction-stmt/retry_stmt_source_11.bal | 10 + .../transaction-stmt/retry_stmt_source_12.bal | 7 + .../transaction-stmt/retry_stmt_source_13.bal | 7 + .../transaction-stmt/retry_stmt_source_14.bal | 7 + .../transaction-stmt/retry_stmt_source_15.bal | 7 + .../transaction_stmt_assert_05.json | 1578 +++++++++ .../transaction_stmt_assert_06.json | 1578 +++++++++ .../transaction_stmt_assert_07.json | 3083 +++++++++++++++++ .../transaction_stmt_assert_08.json | 3078 ++++++++++++++++ .../transaction_stmt_assert_09.json | 2311 ++++++++++++ .../transaction_stmt_assert_10.json | 1698 +++++++++ .../transaction_stmt_assert_11.json | 1966 +++++++++++ .../transaction_stmt_assert_12.json | 1996 +++++++++++ .../transaction_stmt_source_05.bal | 34 + .../transaction_stmt_source_06.bal | 34 + .../transaction_stmt_source_07.bal | 49 + .../transaction_stmt_source_08.bal | 49 + .../transaction_stmt_source_09.bal | 34 + .../transaction_stmt_source_10.bal | 34 + .../transaction_stmt_source_11.bal | 34 + .../transaction_stmt_source_12.bal | 34 + .../while-stmt/while_stmt_assert_07.json | 579 ++++ .../while-stmt/while_stmt_assert_08.json | 579 ++++ .../while-stmt/while_stmt_assert_09.json | 1334 +++++++ .../while-stmt/while_stmt_assert_10.json | 1333 +++++++ .../while-stmt/while_stmt_assert_11.json | 727 ++++ .../while-stmt/while_stmt_assert_12.json | 603 ++++ .../while-stmt/while_stmt_assert_13.json | 658 ++++ .../while-stmt/while_stmt_assert_14.json | 664 ++++ .../while-stmt/while_stmt_source_07.bal | 9 + .../while-stmt/while_stmt_source_08.bal | 9 + .../while-stmt/while_stmt_source_09.bal | 21 + .../while-stmt/while_stmt_source_10.bal | 21 + .../while-stmt/while_stmt_source_11.bal | 9 + .../while-stmt/while_stmt_source_12.bal | 9 + .../while-stmt/while_stmt_source_13.bal | 9 + .../while-stmt/while_stmt_source_14.bal | 9 + .../resources/syntax_tree_descriptor.json | 9 +- .../core/FormattingTreeModifier.java | 6 +- .../api_gen_syntax_tree_descriptor.json | 9 +- 134 files changed, 49490 insertions(+), 121 deletions(-) create mode 100644 compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_10.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_11.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_12.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_13.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_14.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_15.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_16.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_17.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_10.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_11.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_12.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_13.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_14.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_15.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_16.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_17.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_27.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_28.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_29.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_30.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_31.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_32.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_33.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_34.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_27.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_28.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_29.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_30.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_31.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_32.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_33.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_34.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_11.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_12.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_13.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_14.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_15.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_16.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_17.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_18.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_11.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_12.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_13.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_14.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_15.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_16.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_17.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_18.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_24.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_25.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_26.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_27.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_28.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_29.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_30.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_31.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_24.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_25.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_26.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_27.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_28.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_29.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_30.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_31.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_08.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_09.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_10.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_11.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_12.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_13.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_14.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_15.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_08.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_09.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_10.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_11.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_12.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_13.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_14.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_15.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_05.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_06.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_07.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_08.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_09.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_10.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_11.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_12.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_05.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_06.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_07.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_08.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_09.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_10.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_11.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_12.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_07.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_08.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_09.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_10.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_11.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_12.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_13.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_14.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_07.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_08.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_09.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_10.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_11.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_12.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_13.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_14.bal diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/parser/BLangNodeBuilder.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/parser/BLangNodeBuilder.java index 497ac600991d..0768132de9a3 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/parser/BLangNodeBuilder.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/parser/BLangNodeBuilder.java @@ -3914,26 +3914,16 @@ public BLangNode transform(OnFailClauseNode onFailClauseNode) { Location pos = getPosition(onFailClauseNode); BLangOnFailClause onFailClause = (BLangOnFailClause) TreeBuilder.createOnFailClauseNode(); onFailClause.pos = pos; - onFailClauseNode.typeDescriptor().ifPresent(typeDescriptorNode -> { - BLangSimpleVariableDef variableDefinitionNode = - (BLangSimpleVariableDef) TreeBuilder.createSimpleVariableDefinitionNode(); - BLangSimpleVariable var = (BLangSimpleVariable) TreeBuilder.createSimpleVariableNode(); - boolean isDeclaredWithVar = typeDescriptorNode.kind() == SyntaxKind.VAR_TYPE_DESC; - var.isDeclaredWithVar = isDeclaredWithVar; - if (!isDeclaredWithVar) { - var.setTypeNode(createTypeNode(typeDescriptorNode)); + onFailClauseNode.typedBindingPattern().ifPresent(typedBindingPatternNode -> { + if (typedBindingPatternNode.bindingPattern().kind() == SyntaxKind.CAPTURE_BINDING_PATTERN) { + VariableDefinitionNode variableDefinitionNode = + createBLangVarDef(getPosition(typedBindingPatternNode), typedBindingPatternNode, + Optional.empty(), Optional.empty()); + onFailClause.isDeclaredWithVar = + typedBindingPatternNode.typeDescriptor().kind() == SyntaxKind.VAR_TYPE_DESC; + markVariableWithFlag((BLangVariable) variableDefinitionNode.getVariable(), Flag.FINAL); + onFailClause.variableDefinitionNode = variableDefinitionNode; } - var.pos = pos; - onFailClauseNode.failErrorName().ifPresent(identifierToken -> { - var.setName(this.createIdentifier(identifierToken)); - var.name.pos = getPosition(identifierToken); - variableDefinitionNode.setVariable(var); - variableDefinitionNode.pos = getPosition(typeDescriptorNode, - identifierToken); - }); - onFailClause.isDeclaredWithVar = isDeclaredWithVar; - markVariableWithFlag(variableDefinitionNode.getVariable(), Flag.FINAL); - onFailClause.variableDefinitionNode = variableDefinitionNode; }); BLangBlockStmt blockNode = (BLangBlockStmt) transform(onFailClauseNode.blockStatement()); blockNode.pos = pos; diff --git a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/BallerinaParser.java b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/BallerinaParser.java index 024fed5abc1b..1057187b4fa3 100644 --- a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/BallerinaParser.java +++ b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/BallerinaParser.java @@ -13843,19 +13843,29 @@ private STNode parseOnFailClause() { STNode onKeyword = parseOnKeyword(); STNode failKeyword = parseFailKeyword(); STToken token = peek(); - STNode typeDescriptor = STNodeFactory.createEmptyNode(); - STNode identifier = STNodeFactory.createEmptyNode(); + STNode typedBindingPattern = STNodeFactory.createEmptyNode(); if (token.kind != SyntaxKind.OPEN_BRACE_TOKEN) { - typeDescriptor = parseTypeDescriptor(ParserRuleContext.TYPE_DESC_IN_TYPE_BINDING_PATTERN, true, false, - TypePrecedence.DEFAULT); - identifier = parseIdentifier(ParserRuleContext.VARIABLE_NAME); + typedBindingPattern = addTypedBp(); } STNode blockStatement = parseBlockNode(); endContext(); - return STNodeFactory.createOnFailClauseNode(onKeyword, failKeyword, typeDescriptor, identifier, + return STNodeFactory.createOnFailClauseNode(onKeyword, failKeyword, typedBindingPattern, blockStatement); } + private STNode addTypedBp() { + STNode typeDescriptor = parseTypeDescriptor(ParserRuleContext.TYPE_DESC_IN_TYPE_BINDING_PATTERN, + true, false, TypePrecedence.DEFAULT); + STToken token = peek(); + if (token.kind == SyntaxKind.ERROR_KEYWORD) { + STNode errorBP = parseErrorBindingPattern(); + return STNodeFactory.createTypedBindingPatternNode(typeDescriptor, errorBP); + } + STNode captureBP = + STNodeFactory.createCaptureBindingPatternNode(parseIdentifier(ParserRuleContext.VARIABLE_NAME)); + return STNodeFactory.createTypedBindingPatternNode(typeDescriptor, captureBP); + } + /** * Parse retry keyword. * diff --git a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/BallerinaParserErrorHandler.java b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/BallerinaParserErrorHandler.java index 40e81b7cf966..1d9061aa0343 100644 --- a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/BallerinaParserErrorHandler.java +++ b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/BallerinaParserErrorHandler.java @@ -5342,6 +5342,8 @@ private ParserRuleContext getNextRuleForBindingPattern(boolean isCaptureBP) { case ERROR_ARG_LIST_MATCH_PATTERN_FIRST_ARG: endContext(); return ParserRuleContext.ERROR_FIELD_MATCH_PATTERN_RHS; + case ON_FAIL_CLAUSE: + return ParserRuleContext.BLOCK_STMT; default: return getNextRuleForMatchPattern(); } diff --git a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/tree/STNodeFactory.java b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/tree/STNodeFactory.java index f6df582aff6b..0da1eb7c3c7e 100644 --- a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/tree/STNodeFactory.java +++ b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/tree/STNodeFactory.java @@ -2303,15 +2303,13 @@ public static STNode createOrderKeyNode( public static STNode createOnFailClauseNode( STNode onKeyword, STNode failKeyword, - STNode typeDescriptor, - STNode failErrorName, + STNode typedBindingPattern, STNode blockStatement) { return new STOnFailClauseNode( onKeyword, failKeyword, - typeDescriptor, - failErrorName, + typedBindingPattern, blockStatement); } @@ -2670,7 +2668,7 @@ public static STNode createReBracedQuantifierNode( mostTimesMatchedDigit, closeBraceToken); } - + public static STNode createMemberTypeDescriptorNode( STNode annotations, STNode typeDescriptor) { diff --git a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/tree/STNodeTransformer.java b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/tree/STNodeTransformer.java index 8c9ad1eb3040..77d1d4c8afb4 100644 --- a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/tree/STNodeTransformer.java +++ b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/tree/STNodeTransformer.java @@ -920,7 +920,7 @@ public T transform(STReQuantifierNode reQuantifierNode) { public T transform(STReBracedQuantifierNode reBracedQuantifierNode) { return transformSyntaxNode(reBracedQuantifierNode); } - + public T transform(STMemberTypeDescriptorNode memberTypeDescriptorNode) { return transformSyntaxNode(memberTypeDescriptorNode); } diff --git a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/tree/STNodeVisitor.java b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/tree/STNodeVisitor.java index f971f9cf24f4..900a23939bbe 100644 --- a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/tree/STNodeVisitor.java +++ b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/tree/STNodeVisitor.java @@ -920,7 +920,7 @@ public void visit(STReQuantifierNode reQuantifierNode) { public void visit(STReBracedQuantifierNode reBracedQuantifierNode) { visitSyntaxNode(reBracedQuantifierNode); } - + public void visit(STMemberTypeDescriptorNode memberTypeDescriptorNode) { visitSyntaxNode(memberTypeDescriptorNode); } diff --git a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/tree/STOnFailClauseNode.java b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/tree/STOnFailClauseNode.java index 03c73c83803f..518ccdfba296 100644 --- a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/tree/STOnFailClauseNode.java +++ b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/tree/STOnFailClauseNode.java @@ -33,21 +33,18 @@ public class STOnFailClauseNode extends STClauseNode { public final STNode onKeyword; public final STNode failKeyword; - public final STNode typeDescriptor; - public final STNode failErrorName; + public final STNode typedBindingPattern; public final STNode blockStatement; STOnFailClauseNode( STNode onKeyword, STNode failKeyword, - STNode typeDescriptor, - STNode failErrorName, + STNode typedBindingPattern, STNode blockStatement) { this( onKeyword, failKeyword, - typeDescriptor, - failErrorName, + typedBindingPattern, blockStatement, Collections.emptyList()); } @@ -55,22 +52,19 @@ public class STOnFailClauseNode extends STClauseNode { STOnFailClauseNode( STNode onKeyword, STNode failKeyword, - STNode typeDescriptor, - STNode failErrorName, + STNode typedBindingPattern, STNode blockStatement, Collection diagnostics) { super(SyntaxKind.ON_FAIL_CLAUSE, diagnostics); this.onKeyword = onKeyword; this.failKeyword = failKeyword; - this.typeDescriptor = typeDescriptor; - this.failErrorName = failErrorName; + this.typedBindingPattern = typedBindingPattern; this.blockStatement = blockStatement; addChildren( onKeyword, failKeyword, - typeDescriptor, - failErrorName, + typedBindingPattern, blockStatement); } @@ -78,8 +72,7 @@ public STNode modifyWith(Collection diagnostics) { return new STOnFailClauseNode( this.onKeyword, this.failKeyword, - this.typeDescriptor, - this.failErrorName, + this.typedBindingPattern, this.blockStatement, diagnostics); } @@ -87,14 +80,12 @@ public STNode modifyWith(Collection diagnostics) { public STOnFailClauseNode modify( STNode onKeyword, STNode failKeyword, - STNode typeDescriptor, - STNode failErrorName, + STNode typedBindingPattern, STNode blockStatement) { if (checkForReferenceEquality( onKeyword, failKeyword, - typeDescriptor, - failErrorName, + typedBindingPattern, blockStatement)) { return this; } @@ -102,8 +93,7 @@ public STOnFailClauseNode modify( return new STOnFailClauseNode( onKeyword, failKeyword, - typeDescriptor, - failErrorName, + typedBindingPattern, blockStatement, diagnostics); } diff --git a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/tree/STTreeModifier.java b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/tree/STTreeModifier.java index f6addf53f083..a36a9a1a73f2 100644 --- a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/tree/STTreeModifier.java +++ b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/tree/STTreeModifier.java @@ -2474,14 +2474,12 @@ public STOnFailClauseNode transform( STOnFailClauseNode onFailClauseNode) { STNode onKeyword = modifyNode(onFailClauseNode.onKeyword); STNode failKeyword = modifyNode(onFailClauseNode.failKeyword); - STNode typeDescriptor = modifyNode(onFailClauseNode.typeDescriptor); - STNode failErrorName = modifyNode(onFailClauseNode.failErrorName); + STNode typedBindingPattern = modifyNode(onFailClauseNode.typedBindingPattern); STNode blockStatement = modifyNode(onFailClauseNode.blockStatement); return onFailClauseNode.modify( onKeyword, failKeyword, - typeDescriptor, - failErrorName, + typedBindingPattern, blockStatement); } @@ -2870,7 +2868,8 @@ public STReBracedQuantifierNode transform( mostTimesMatchedDigit, closeBraceToken); } - + + @Override public STMemberTypeDescriptorNode transform( STMemberTypeDescriptorNode memberTypeDescriptorNode) { STNode annotations = modifyNode(memberTypeDescriptorNode.annotations); diff --git a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/NodeFactory.java b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/NodeFactory.java index 877f7c7e35e5..743c2a0a1583 100644 --- a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/NodeFactory.java +++ b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/NodeFactory.java @@ -3039,8 +3039,7 @@ public static OrderKeyNode createOrderKeyNode( public static OnFailClauseNode createOnFailClauseNode( Token onKeyword, Token failKeyword, - TypeDescriptorNode typeDescriptor, - IdentifierToken failErrorName, + TypedBindingPatternNode typedBindingPattern, BlockStatementNode blockStatement) { Objects.requireNonNull(onKeyword, "onKeyword must not be null"); Objects.requireNonNull(failKeyword, "failKeyword must not be null"); @@ -3049,8 +3048,7 @@ public static OnFailClauseNode createOnFailClauseNode( STNode stOnFailClauseNode = STNodeFactory.createOnFailClauseNode( onKeyword.internalNode(), failKeyword.internalNode(), - getOptionalSTNode(typeDescriptor), - getOptionalSTNode(failErrorName), + getOptionalSTNode(typedBindingPattern), blockStatement.internalNode()); return stOnFailClauseNode.createUnlinkedFacade(); } @@ -3417,8 +3415,7 @@ public static ReCharSetAtomNoDashWithReCharSetNoDashNode createReCharSetAtomNoDa Objects.requireNonNull(reCharSetAtomNoDash, "reCharSetAtomNoDash must not be null"); Objects.requireNonNull(reCharSetNoDash, "reCharSetNoDash must not be null"); - STNode stReCharSetAtomNoDashWithReCharSetNoDashNode = - STNodeFactory.createReCharSetAtomNoDashWithReCharSetNoDashNode( + STNode stReCharSetAtomNoDashWithReCharSetNoDashNode = STNodeFactory.createReCharSetAtomNoDashWithReCharSetNoDashNode( reCharSetAtomNoDash.internalNode(), reCharSetNoDash.internalNode()); return stReCharSetAtomNoDashWithReCharSetNoDashNode.createUnlinkedFacade(); @@ -3517,7 +3514,7 @@ public static ReBracedQuantifierNode createReBracedQuantifierNode( closeBraceToken.internalNode()); return stReBracedQuantifierNode.createUnlinkedFacade(); } - + public static MemberTypeDescriptorNode createMemberTypeDescriptorNode( NodeList annotations, TypeDescriptorNode typeDescriptor) { diff --git a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/NodeTransformer.java b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/NodeTransformer.java index 7a2e5af1a020..d97123d4a4fb 100644 --- a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/NodeTransformer.java +++ b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/NodeTransformer.java @@ -931,7 +931,7 @@ public T transform(ReQuantifierNode reQuantifierNode) { public T transform(ReBracedQuantifierNode reBracedQuantifierNode) { return transformSyntaxNode(reBracedQuantifierNode); } - + public T transform(MemberTypeDescriptorNode memberTypeDescriptorNode) { return transformSyntaxNode(memberTypeDescriptorNode); } diff --git a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/NodeVisitor.java b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/NodeVisitor.java index 366c544fb908..a915f81623c4 100644 --- a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/NodeVisitor.java +++ b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/NodeVisitor.java @@ -930,7 +930,7 @@ public void visit(ReQuantifierNode reQuantifierNode) { public void visit(ReBracedQuantifierNode reBracedQuantifierNode) { visitSyntaxNode(reBracedQuantifierNode); } - + public void visit(MemberTypeDescriptorNode memberTypeDescriptorNode) { visitSyntaxNode(memberTypeDescriptorNode); } diff --git a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/OnFailClauseNode.java b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/OnFailClauseNode.java index c1e2bb0f0f21..deeade759b25 100644 --- a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/OnFailClauseNode.java +++ b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/OnFailClauseNode.java @@ -41,16 +41,12 @@ public Token failKeyword() { return childInBucket(1); } - public Optional typeDescriptor() { + public Optional typedBindingPattern() { return optionalChildInBucket(2); } - public Optional failErrorName() { - return optionalChildInBucket(3); - } - public BlockStatementNode blockStatement() { - return childInBucket(4); + return childInBucket(3); } @Override @@ -68,22 +64,19 @@ protected String[] childNames() { return new String[]{ "onKeyword", "failKeyword", - "typeDescriptor", - "failErrorName", + "typedBindingPattern", "blockStatement"}; } public OnFailClauseNode modify( Token onKeyword, Token failKeyword, - TypeDescriptorNode typeDescriptor, - IdentifierToken failErrorName, + TypedBindingPatternNode typedBindingPattern, BlockStatementNode blockStatement) { if (checkForReferenceEquality( onKeyword, failKeyword, - typeDescriptor, - failErrorName, + typedBindingPattern, blockStatement)) { return this; } @@ -91,8 +84,7 @@ public OnFailClauseNode modify( return NodeFactory.createOnFailClauseNode( onKeyword, failKeyword, - typeDescriptor, - failErrorName, + typedBindingPattern, blockStatement); } @@ -109,16 +101,14 @@ public static class OnFailClauseNodeModifier { private final OnFailClauseNode oldNode; private Token onKeyword; private Token failKeyword; - private TypeDescriptorNode typeDescriptor; - private IdentifierToken failErrorName; + private TypedBindingPatternNode typedBindingPattern; private BlockStatementNode blockStatement; public OnFailClauseNodeModifier(OnFailClauseNode oldNode) { this.oldNode = oldNode; this.onKeyword = oldNode.onKeyword(); this.failKeyword = oldNode.failKeyword(); - this.typeDescriptor = oldNode.typeDescriptor().orElse(null); - this.failErrorName = oldNode.failErrorName().orElse(null); + this.typedBindingPattern = oldNode.typedBindingPattern().orElse(null); this.blockStatement = oldNode.blockStatement(); } @@ -136,15 +126,9 @@ public OnFailClauseNodeModifier withFailKeyword( return this; } - public OnFailClauseNodeModifier withTypeDescriptor( - TypeDescriptorNode typeDescriptor) { - this.typeDescriptor = typeDescriptor; - return this; - } - - public OnFailClauseNodeModifier withFailErrorName( - IdentifierToken failErrorName) { - this.failErrorName = failErrorName; + public OnFailClauseNodeModifier withTypedBindingPattern( + TypedBindingPatternNode typedBindingPattern) { + this.typedBindingPattern = typedBindingPattern; return this; } @@ -159,8 +143,7 @@ public OnFailClauseNode apply() { return oldNode.modify( onKeyword, failKeyword, - typeDescriptor, - failErrorName, + typedBindingPattern, blockStatement); } } diff --git a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/TreeModifier.java b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/TreeModifier.java index 46aa97d15e8e..3542775b2b92 100644 --- a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/TreeModifier.java +++ b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/TreeModifier.java @@ -3125,17 +3125,14 @@ public OnFailClauseNode transform( modifyToken(onFailClauseNode.onKeyword()); Token failKeyword = modifyToken(onFailClauseNode.failKeyword()); - TypeDescriptorNode typeDescriptor = - modifyNode(onFailClauseNode.typeDescriptor().orElse(null)); - IdentifierToken failErrorName = - modifyNode(onFailClauseNode.failErrorName().orElse(null)); + TypedBindingPatternNode typedBindingPattern = + modifyNode(onFailClauseNode.typedBindingPattern().orElse(null)); BlockStatementNode blockStatement = modifyNode(onFailClauseNode.blockStatement()); return onFailClauseNode.modify( onKeyword, failKeyword, - typeDescriptor, - failErrorName, + typedBindingPattern, blockStatement); } @@ -3620,7 +3617,8 @@ public ReBracedQuantifierNode transform( mostTimesMatchedDigit, closeBraceToken); } - + + @Override public MemberTypeDescriptorNode transform( MemberTypeDescriptorNode memberTypeDescriptorNode) { NodeList annotations = diff --git a/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/DoStatementTest.java b/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/DoStatementTest.java index 83951517fe51..fa6e0d6f27de 100644 --- a/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/DoStatementTest.java +++ b/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/DoStatementTest.java @@ -46,6 +46,26 @@ public void testDoWithOnFailClauseWithoutVariable() { testFile("do-stmt/do_stmt_source_09.bal", "do-stmt/do_stmt_assert_09.json"); } + @Test + public void testDoWithOnFailClauseHavingErrorBPWithVar() { + testFile("do-stmt/do_stmt_source_10", "do-stmt/do_stmt_assert_10.json"); + } + + @Test + public void testDoWithOnFailClauseHavingErrorBPWithType() { + testFile("do-stmt/do_stmt_source_11", "do-stmt/do_stmt_assert_11.json"); + } + + @Test + public void testDoWithOnFailClauseHavingErrorBPWithUserDefinedError() { + testFile("do-stmt/do_stmt_source_12", "do-stmt/do_stmt_assert_12.json"); + } + + @Test + public void testDoWithOnFailClauseHavingErrorBPWithUserDefinedErrorWithVar() { + testFile("do-stmt/do_stmt_source_13", "do-stmt/do_stmt_assert_13.json"); + } + // Recovery test @Test @@ -57,6 +77,10 @@ public void testDoWithMissingOpenCloseBraces() { @Test public void testDoOnFailClauseRecovery() { testFile("do-stmt/do_stmt_source_06.bal", "do-stmt/do_stmt_assert_06.json"); + testFile("do-stmt/do_stmt_source_14", "do-stmt/do_stmt_assert_14.json"); + testFile("do-stmt/do_stmt_source_15", "do-stmt/do_stmt_assert_15.json"); + testFile("do-stmt/do_stmt_source_16", "do-stmt/do_stmt_assert_16.json"); + testFile("do-stmt/do_stmt_source_17", "do-stmt/do_stmt_assert_17.json"); } @Test diff --git a/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/ForEachStatementTest.java b/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/ForEachStatementTest.java index 513eab7c836d..7806b970244d 100644 --- a/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/ForEachStatementTest.java +++ b/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/ForEachStatementTest.java @@ -92,12 +92,32 @@ public void testForEachStmtWithOnFailClauseWithoutVariable() { "forEach-stmt/forEach_stmt_assert_26.json"); } + @Test + public void testForEachWithOnFailClauseHavingErrorBPWithVar() { + testFile("forEach-stmt/forEach_stmt_source_27", "forEach-stmt/forEach_stmt_assert_27.json"); + } + + @Test + public void testForEachWithOnFailClauseHavingErrorBPWithType() { + testFile("forEach-stmt/forEach_stmt_source_28", "forEach-stmt/forEach_stmt_assert_28.json"); + } + + @Test + public void testForEachWithOnFailClauseHavingErrorBPWithUserDefinedError() { + testFile("forEach-stmt/forEach_stmt_source_29", "forEach-stmt/forEach_stmt_assert_29.json"); + } + + @Test + public void testForEachWithOnFailClauseHavingErrorBPWithUserDefinedErrorWithVar() { + testFile("forEach-stmt/forEach_stmt_source_30", "forEach-stmt/forEach_stmt_assert_30.json"); + } + // Recovery tests @Test public void testForEachStmtWithMissingClosingBraces() { testFile("forEach-stmt/forEach_stmt_source_04.bal", - "forEach-stmt/forEach_stmt_assert_04.json"); + "forEach-stmt/forEach_stmt_source_04.json"); } @Test @@ -181,5 +201,9 @@ public void testMappingBindingPatternMissingCloseBraceForEachStmt() { @Test public void testForEachOnFailClauseRecovery() { testFile("forEach-stmt/forEach_stmt_source_25.bal", "forEach-stmt/forEach_stmt_assert_25.json"); + testFile("forEach-stmt/forEach_stmt_source_31.bal", "forEach-stmt/forEach_stmt_assert_31.json"); + testFile("forEach-stmt/forEach_stmt_source_32.bal", "forEach-stmt/forEach_stmt_assert_32.json"); + testFile("forEach-stmt/forEach_stmt_source_33.bal", "forEach-stmt/forEach_stmt_assert_33.json"); + testFile("forEach-stmt/forEach_stmt_source_34.bal", "forEach-stmt/forEach_stmt_assert_34.json"); } } diff --git a/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/LockStatementTest.java b/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/LockStatementTest.java index 4f2b899857c7..a51a478d2fc5 100644 --- a/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/LockStatementTest.java +++ b/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/LockStatementTest.java @@ -56,6 +56,26 @@ public void testLockStmtWithOnFailClauseWithoutVariable() { "lock-stmt/lock_stmt_assert_10.json"); } + public void testLockWithOnFailClauseHavingErrorBPWithVar() { + testFile("lock-stmt/lock_stmt_source_11.bal", + "lock-stmt/lock_stmt_assert_11.json"); + } + + public void testLockWithOnFailClauseHavingErrorBPWithType() { + testFile("lock-stmt/lock_stmt_source_12.bal", + "lock-stmt/lock_stmt_assert_12.json"); + } + + public void testLockWithOnFailClauseHavingErrorBPWithUserDefinedError() { + testFile("lock-stmt/lock_stmt_source_13.bal", + "lock-stmt/lock_stmt_assert_13.json"); + } + + public void testLockWithOnFailClauseHavingErrorBPWithUserDefinedErrorWithVar() { + testFile("lock-stmt/lock_stmt_source_14.bal", + "lock-stmt/lock_stmt_assert_14.json"); + } + // Recovery tests @Test @@ -85,5 +105,9 @@ public void testMissingCloseBrace() { @Test public void testLockOnFailClauseRecovery() { testFile("lock-stmt/lock_stmt_source_09.bal", "lock-stmt/lock_stmt_assert_09.json"); + testFile("lock-stmt/lock_stmt_source_15.bal", "lock-stmt/lock_stmt_assert_15.json"); + testFile("lock-stmt/lock_stmt_source_16.bal", "lock-stmt/lock_stmt_assert_16.json"); + testFile("lock-stmt/lock_stmt_source_17.bal", "lock-stmt/lock_stmt_assert_17.json"); + testFile("lock-stmt/lock_stmt_source_18.bal", "lock-stmt/lock_stmt_assert_18.json"); } } diff --git a/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/MatchStatementTest.java b/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/MatchStatementTest.java index 71f949646c01..5e509859fe54 100644 --- a/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/MatchStatementTest.java +++ b/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/MatchStatementTest.java @@ -73,6 +73,26 @@ public void testConstPatternWithPreDeclaredPrefix() { testFile("match-stmt/match_stmt_source_22.bal", "match-stmt/match_stmt_assert_22.json"); } + @Test + public void testSimpleMatchStatementWithOnFailClauseHavingErrorBPWithVar() { + testFile("match-stmt/match_stmt_source_24.bal", "match-stmt/match_stmt_assert_24.json"); + } + + @Test + public void testSimpleMatchStatementWithOnFailClauseHavingErrorBPWithType() { + testFile("match-stmt/match_stmt_source_25.bal", "match-stmt/match_stmt_assert_25.json"); + } + + @Test + public void testSimpleMatchStatementWithOnFailClauseHavingErrorBPWithUserDefinedError() { + testFile("match-stmt/match_stmt_source_26.bal", "match-stmt/match_stmt_assert_26.json"); + } + + @Test + public void testSimpleMatchStatementWithOnFailClauseHavingErrorBPWithUserDefinedErrorWithVar() { + testFile("match-stmt/match_stmt_source_27.bal", "match-stmt/match_stmt_assert_27.json"); + } + // Recovery tests @Test @@ -115,6 +135,10 @@ public void testMatchStmtRecoveryInvalidErrorMatchPatterns() { @Test public void testMatchStatementOnFailClauseRecovery() { testFile("match-stmt/match_stmt_source_15.bal", "match-stmt/match_stmt_assert_15.json"); + testFile("match-stmt/match_stmt_source_28.bal", "match-stmt/match_stmt_assert_28.json"); + testFile("match-stmt/match_stmt_source_29.bal", "match-stmt/match_stmt_assert_29.json"); + testFile("match-stmt/match_stmt_source_30.bal", "match-stmt/match_stmt_assert_30.json"); + testFile("match-stmt/match_stmt_source_31.bal", "match-stmt/match_stmt_assert_31.json"); } @Test diff --git a/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/TransactionStatementTest.java b/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/TransactionStatementTest.java index 4296530cac13..7ab7f3267683 100644 --- a/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/TransactionStatementTest.java +++ b/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/TransactionStatementTest.java @@ -63,6 +63,54 @@ public void testRetryStatementWithOnFailClauseWithoutVariable() { testFile("transaction-stmt/retry_stmt_source_07.bal", "transaction-stmt/retry_stmt_assert_07.json"); } + @Test + public void testRetryWithOnFailClauseHavingErrorBPWithVar() { + testFile("transaction-stmt/retry_stmt_source_08.bal", + "transaction-stmt/retry_stmt_assert_08.json"); + } + + @Test + public void testRetryWithOnFailClauseHavingErrorBPWithType() { + testFile("transaction-stmt/retry_stmt_source_09.bal", + "transaction-stmt/retry_stmt_assert_09.json"); + } + + @Test + public void testRetryWithOnFailClauseHavingErrorBPWithUserDefinedError() { + testFile("transaction-stmt/retry_stmt_source_10.bal", + "transaction-stmt/retry_stmt_assert_10.json"); + } + + @Test + public void testRetryWithOnFailClauseHavingErrorBPWithUserDefinedErrorWithVar() { + testFile("transaction-stmt/retry_stmt_source_11.bal", + "transaction-stmt/retry_stmt_assert_11.json"); + } + + @Test + public void testTransactionWithOnFailClauseHavingErrorBPWithVar() { + testFile("transaction-stmt/transaction_stmt_source_05.bal", + "transaction-stmt/transaction_stmt_assert_05.json"); + } + + @Test + public void testTransactionWithOnFailClauseHavingErrorBPWithType() { + testFile("transaction-stmt/transaction_stmt_source_06.bal", + "transaction-stmt/transaction_stmt_assert_06.json"); + } + + @Test + public void testTransactionWithOnFailClauseHavingErrorBPWithUserDefinedError() { + testFile("transaction-stmt/transaction_stmt_source_07.bal", + "transaction-stmt/transaction_stmt_assert_07.json"); + } + + @Test + public void testTransactionWithOnFailClauseHavingErrorBPWithUserDefinedErrorWithVar() { + testFile("transaction-stmt/transaction_stmt_source_08.bal", + "transaction-stmt/transaction_stmt_assert_08.json"); + } + @Test public void testTransactionalWorker() { testFile("transaction-stmt/transactional_worker_source_01.bal", @@ -94,10 +142,18 @@ public void testRetryTransactionStatementRecovery() { @Test public void testTransactionOnFailClauseRecovery() { testFile("transaction-stmt/transaction_stmt_source_04.bal", "transaction-stmt/transaction_stmt_assert_04.json"); + testFile("transaction-stmt/transaction_stmt_source_09.bal", "transaction-stmt/transaction_stmt_assert_09.json"); + testFile("transaction-stmt/transaction_stmt_source_10.bal", "transaction-stmt/transaction_stmt_assert_10.json"); + testFile("transaction-stmt/transaction_stmt_source_11.bal", "transaction-stmt/transaction_stmt_assert_11.json"); + testFile("transaction-stmt/transaction_stmt_source_12.bal", "transaction-stmt/transaction_stmt_assert_12.json"); } @Test public void testRetryOnFailClauseRecovery() { testFile("transaction-stmt/retry_stmt_source_06.bal", "transaction-stmt/retry_stmt_assert_06.json"); + testFile("transaction-stmt/retry_stmt_source_12.bal", "transaction-stmt/retry_stmt_assert_12.json"); + testFile("transaction-stmt/retry_stmt_source_13.bal", "transaction-stmt/retry_stmt_assert_13.json"); + testFile("transaction-stmt/retry_stmt_source_14.bal", "transaction-stmt/retry_stmt_assert_14.json"); + testFile("transaction-stmt/retry_stmt_source_15.bal", "transaction-stmt/retry_stmt_assert_15.json"); } } diff --git a/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/WhileStatementTest.java b/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/WhileStatementTest.java index b1a49e4207fc..0337e951f1c8 100644 --- a/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/WhileStatementTest.java +++ b/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/WhileStatementTest.java @@ -46,6 +46,26 @@ public void testWhileWithOnFailClauseWithoutVariable() { testFile("while-stmt/while_stmt_source_06.bal", "while-stmt/while_stmt_assert_06.json"); } + @Test + public void testWhileWithOnFailClauseHavingErrorBPWithVar() { + testFile("while-stmt/while_stmt_source_07.bal", "while-stmt/while_stmt_assert_07.json"); + } + + @Test + public void testWhileWithOnFailClauseHavingErrorBPWithType() { + testFile("while-stmt/while_stmt_source_08.bal", "while-stmt/while_stmt_assert_08.json"); + } + + @Test + public void testWhileWithOnFailClauseHavingErrorBPWithUserDefinedError() { + testFile("while-stmt/while_stmt_source_09.bal", "while-stmt/while_stmt_assert_09.json"); + } + + @Test + public void testWhileWithOnFailClauseHavingErrorBPWithUserDefinedErrorWithVar() { + testFile("while-stmt/while_stmt_source_10.bal", "while-stmt/while_stmt_assert_10.json"); + } + // Recovery tests @Test @@ -56,5 +76,9 @@ public void testWhileStmtRecovery() { @Test public void testWhileOnFailClauseRecovery() { testFile("while-stmt/while_stmt_source_05.bal", "while-stmt/while_stmt_assert_05.json"); + testFile("while-stmt/while_stmt_source_11.bal", "while-stmt/while_stmt_assert_11.json"); + testFile("while-stmt/while_stmt_source_12.bal", "while-stmt/while_stmt_assert_12.json"); + testFile("while-stmt/while_stmt_source_13.bal", "while-stmt/while_stmt_assert_13.json"); + testFile("while-stmt/while_stmt_source_14.bal", "while-stmt/while_stmt_assert_14.json"); } } diff --git a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_10.json b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_10.json new file mode 100644 index 000000000000..0ed8150341aa --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_10.json @@ -0,0 +1,377 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "DO_STATEMENT", + "children": [ + { + "kind": "DO_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "VAR_TYPE_DESC", + "children": [ + { + "kind": "VAR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_11.json b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_11.json new file mode 100644 index 000000000000..f41563ec84c6 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_11.json @@ -0,0 +1,377 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "DO_STATEMENT", + "children": [ + { + "kind": "DO_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_12.json b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_12.json new file mode 100644 index 000000000000..e833953dc383 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_12.json @@ -0,0 +1,1132 @@ +{ + "kind": "MODULE_PART", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TYPE_DEFINITION", + "children": [ + { + "kind": "TYPE_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleErrorData", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "RECORD_TYPE_DESC", + "children": [ + { + "kind": "RECORD_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "OPEN_BRACE_PIPE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "RECORD_FIELD", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode" + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "RECORD_FIELD", + "children": [ + { + "kind": "STRING_TYPE_DESC", + "children": [ + { + "kind": "STRING_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "userReason" + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_PIPE_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "TYPE_DEFINITION", + "children": [ + { + "kind": "TYPE_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "TYPE_PARAMETER", + "children": [ + { + "kind": "LT_TOKEN" + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleErrorData" + } + ] + }, + { + "kind": "GT_TOKEN" + } + ] + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "DO_STATEMENT", + "children": [ + { + "kind": "DO_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Transaction Failure" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Database Error" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "20" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userReason", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "deadlock condition" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "cause" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userReason", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "reason" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "cause" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "reason" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "EOF_TOKEN" + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_13.json b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_13.json new file mode 100644 index 000000000000..18baab981a82 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_13.json @@ -0,0 +1,1131 @@ +{ + "kind": "MODULE_PART", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TYPE_DEFINITION", + "children": [ + { + "kind": "TYPE_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleErrorData", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "RECORD_TYPE_DESC", + "children": [ + { + "kind": "RECORD_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "OPEN_BRACE_PIPE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "RECORD_FIELD", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode" + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "RECORD_FIELD", + "children": [ + { + "kind": "STRING_TYPE_DESC", + "children": [ + { + "kind": "STRING_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "userReason" + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_PIPE_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "TYPE_DEFINITION", + "children": [ + { + "kind": "TYPE_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "TYPE_PARAMETER", + "children": [ + { + "kind": "LT_TOKEN" + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleErrorData" + } + ] + }, + { + "kind": "GT_TOKEN" + } + ] + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "DO_STATEMENT", + "children": [ + { + "kind": "DO_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Transaction Failure" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Database Error" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "20" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userReason", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "deadlock condition" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "VAR_TYPE_DESC", + "children": [ + { + "kind": "VAR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "cause" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userReason", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "reason" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "cause" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "reason" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "EOF_TOKEN" + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_14.json b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_14.json new file mode 100644 index 000000000000..c5258118eef6 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_14.json @@ -0,0 +1,525 @@ +{ + "kind": "FUNCTION_DEFINITION", + "hasDiagnostics": true, + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "DO_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "DO_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "hasDiagnostics": true, + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_IDENTIFIER" + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_OPEN_BRACE_TOKEN" + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "hasDiagnostics": true, + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "TUPLE_TYPE_DESC", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "MEMBER_TYPE_DESC", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "MAPPING_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "FIELD_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "ERROR_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "ERROR_KEYWORD", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_ERROR_KEYWORD" + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_COMMA_TOKEN" + ] + }, + { + "kind": "FIELD_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "hasDiagnostics": true, + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_IDENTIFIER" + ], + "leadingMinutiae": [ + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "hasDiagnostics": true, + "children": [ + { + "kind": "SEMICOLON_TOKEN", + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_INVALID_TOKEN" + ] + } + ] + } + }, + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_VARIABLE_DECL_HAVING_BP_MUST_BE_INITIALIZED" + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_SEMICOLON_TOKEN" + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_CLOSE_BRACE_TOKEN" + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_15.json b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_15.json new file mode 100644 index 000000000000..216aa16b30cc --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_15.json @@ -0,0 +1,401 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "DO_STATEMENT", + "children": [ + { + "kind": "DO_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "VAR_TYPE_DESC", + "children": [ + { + "kind": "VAR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_16.json b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_16.json new file mode 100644 index 000000000000..30f6f22d6070 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_16.json @@ -0,0 +1,456 @@ +{ + "kind": "FUNCTION_DEFINITION", + "hasDiagnostics": true, + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "DO_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "DO_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "hasDiagnostics": true, + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD" + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_IDENTIFIER" + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_OPEN_BRACE_TOKEN" + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "hasDiagnostics": true, + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "PARENTHESISED_TYPE_DESC", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "MAPPING_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "FIELD_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "ERROR_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "ERROR_KEYWORD", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_ERROR_KEYWORD" + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_CLOSE_BRACE_TOKEN" + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_VARIABLE_DECL_HAVING_BP_MUST_BE_INITIALIZED" + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_17.json b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_17.json new file mode 100644 index 000000000000..1cfe59b81593 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_17.json @@ -0,0 +1,462 @@ +{ + "kind": "FUNCTION_DEFINITION", + "hasDiagnostics": true, + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "DO_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "DO_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "hasDiagnostics": true, + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "VAR_TYPE_DESC", + "children": [ + { + "kind": "VAR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_IDENTIFIER" + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_OPEN_BRACE_TOKEN" + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "hasDiagnostics": true, + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "PARENTHESISED_TYPE_DESC", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "MAPPING_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "FIELD_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "ERROR_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "ERROR_KEYWORD", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_ERROR_KEYWORD" + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_CLOSE_BRACE_TOKEN" + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_VARIABLE_DECL_HAVING_BP_MUST_BE_INITIALIZED" + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_10.bal b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_10.bal new file mode 100644 index 000000000000..0f18f5a55640 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_10.bal @@ -0,0 +1,7 @@ +public function test() { + do { + fail error("error!"); + } on fail var error(m) { + io:println(m); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_11.bal b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_11.bal new file mode 100644 index 000000000000..514462e05e99 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_11.bal @@ -0,0 +1,7 @@ +public function test() { + do { + fail error("error!"); + } on fail error error(m) { + io:println(m); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_12.bal b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_12.bal new file mode 100644 index 000000000000..f565a531e292 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_12.bal @@ -0,0 +1,19 @@ +type SampleErrorData record {| + int userCode; + string userReason; +|}; + +type SampleError error; + +public function test() { + do { + SampleError err = error("Transaction Failure", error("Database Error"), userCode = 20, + userReason = "deadlock condition"); + fail err; + } on fail SampleError error(message, cause, userCode = code, userReason = reason) { + io:println(message); + io:println(cause); + io:println(code); + io:println(reason); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_13.bal b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_13.bal new file mode 100644 index 000000000000..adcbc299df20 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_13.bal @@ -0,0 +1,19 @@ +type SampleErrorData record {| + int userCode; + string userReason; +|}; + +type SampleError error; + +public function test() { + do { + SampleError err = error("Transaction Failure", error("Database Error"), userCode = 20, + userReason = "deadlock condition"); + fail err; + } on fail var error(message, cause, userCode = code, userReason = reason) { + io:println(message); + io:println(cause); + io:println(code); + io:println(reason); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_14.bal b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_14.bal new file mode 100644 index 000000000000..725afc22b8d3 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_14.bal @@ -0,0 +1,7 @@ +public function test() { + do { + fail error("error!"); + } on fail error [err] { + io:println(err); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_15.bal b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_15.bal new file mode 100644 index 000000000000..8be28a824ace --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_15.bal @@ -0,0 +1,7 @@ +public function test() { + do { + fail error("error!"); + } on fail var error(message = m) { + io:println(m); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_16.bal b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_16.bal new file mode 100644 index 000000000000..c5fd66d29027 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_16.bal @@ -0,0 +1,7 @@ +public function test() { + do { + fail error("error!"); + } on fail error(m) { + io:println(m); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_17.bal b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_17.bal new file mode 100644 index 000000000000..ec00613ad721 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_17.bal @@ -0,0 +1,7 @@ +public function test() { + do { + fail error("error!"); + } on fail var (m) { + io:println(m); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_27.json b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_27.json new file mode 100644 index 000000000000..e1230dc044f4 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_27.json @@ -0,0 +1,435 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FOREACH_STATEMENT", + "children": [ + { + "kind": "FOREACH_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "VAR_TYPE_DESC", + "children": [ + { + "kind": "VAR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "v", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "IN_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "membersList", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "VAR_TYPE_DESC", + "children": [ + { + "kind": "VAR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_28.json b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_28.json new file mode 100644 index 000000000000..060ec3428e86 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_28.json @@ -0,0 +1,435 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FOREACH_STATEMENT", + "children": [ + { + "kind": "FOREACH_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "VAR_TYPE_DESC", + "children": [ + { + "kind": "VAR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "v", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "IN_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "membersList", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_29.json b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_29.json new file mode 100644 index 000000000000..6b71a2f7ed99 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_29.json @@ -0,0 +1,1190 @@ +{ + "kind": "MODULE_PART", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TYPE_DEFINITION", + "children": [ + { + "kind": "TYPE_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleErrorData", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "RECORD_TYPE_DESC", + "children": [ + { + "kind": "RECORD_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "OPEN_BRACE_PIPE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "RECORD_FIELD", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode" + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "RECORD_FIELD", + "children": [ + { + "kind": "STRING_TYPE_DESC", + "children": [ + { + "kind": "STRING_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "userReason" + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_PIPE_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "TYPE_DEFINITION", + "children": [ + { + "kind": "TYPE_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "TYPE_PARAMETER", + "children": [ + { + "kind": "LT_TOKEN" + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleErrorData" + } + ] + }, + { + "kind": "GT_TOKEN" + } + ] + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FOREACH_STATEMENT", + "children": [ + { + "kind": "FOREACH_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "VAR_TYPE_DESC", + "children": [ + { + "kind": "VAR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "v", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "IN_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "membersList", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Transaction Failure" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Database Error" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "20" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userReason", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "deadlock condition" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "cause" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userReason", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "reason" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "cause" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "reason" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "EOF_TOKEN" + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_30.json b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_30.json new file mode 100644 index 000000000000..750132592b64 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_30.json @@ -0,0 +1,1189 @@ +{ + "kind": "MODULE_PART", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TYPE_DEFINITION", + "children": [ + { + "kind": "TYPE_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleErrorData", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "RECORD_TYPE_DESC", + "children": [ + { + "kind": "RECORD_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "OPEN_BRACE_PIPE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "RECORD_FIELD", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode" + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "RECORD_FIELD", + "children": [ + { + "kind": "STRING_TYPE_DESC", + "children": [ + { + "kind": "STRING_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "userReason" + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_PIPE_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "TYPE_DEFINITION", + "children": [ + { + "kind": "TYPE_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "TYPE_PARAMETER", + "children": [ + { + "kind": "LT_TOKEN" + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleErrorData" + } + ] + }, + { + "kind": "GT_TOKEN" + } + ] + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FOREACH_STATEMENT", + "children": [ + { + "kind": "FOREACH_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "VAR_TYPE_DESC", + "children": [ + { + "kind": "VAR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "v", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "IN_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "membersList", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Transaction Failure" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Database Error" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "20" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userReason", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "deadlock condition" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "VAR_TYPE_DESC", + "children": [ + { + "kind": "VAR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "cause" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userReason", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "reason" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "cause" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "reason" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "EOF_TOKEN" + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_31.json b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_31.json new file mode 100644 index 000000000000..41fd6ac1add9 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_31.json @@ -0,0 +1,583 @@ +{ + "kind": "FUNCTION_DEFINITION", + "hasDiagnostics": true, + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "FOREACH_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "FOREACH_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "VAR_TYPE_DESC", + "children": [ + { + "kind": "VAR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "v", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "IN_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "membersList", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "hasDiagnostics": true, + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_IDENTIFIER" + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_OPEN_BRACE_TOKEN" + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "hasDiagnostics": true, + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "TUPLE_TYPE_DESC", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "MEMBER_TYPE_DESC", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "MAPPING_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "FIELD_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "ERROR_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "ERROR_KEYWORD", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_ERROR_KEYWORD" + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_COMMA_TOKEN" + ] + }, + { + "kind": "FIELD_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "hasDiagnostics": true, + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_IDENTIFIER" + ], + "leadingMinutiae": [ + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "hasDiagnostics": true, + "children": [ + { + "kind": "SEMICOLON_TOKEN", + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_INVALID_TOKEN" + ] + } + ] + } + }, + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_VARIABLE_DECL_HAVING_BP_MUST_BE_INITIALIZED" + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_SEMICOLON_TOKEN" + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_CLOSE_BRACE_TOKEN" + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_32.json b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_32.json new file mode 100644 index 000000000000..e611a62d1ba6 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_32.json @@ -0,0 +1,459 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FOREACH_STATEMENT", + "children": [ + { + "kind": "FOREACH_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "VAR_TYPE_DESC", + "children": [ + { + "kind": "VAR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "v", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "IN_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "membersList", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "VAR_TYPE_DESC", + "children": [ + { + "kind": "VAR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_33.json b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_33.json new file mode 100644 index 000000000000..33e9105b5dc5 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_33.json @@ -0,0 +1,514 @@ +{ + "kind": "FUNCTION_DEFINITION", + "hasDiagnostics": true, + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "FOREACH_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "FOREACH_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "VAR_TYPE_DESC", + "children": [ + { + "kind": "VAR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "v", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "IN_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "membersList", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "hasDiagnostics": true, + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD" + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_IDENTIFIER" + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_OPEN_BRACE_TOKEN" + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "hasDiagnostics": true, + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "PARENTHESISED_TYPE_DESC", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "MAPPING_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "FIELD_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "ERROR_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "ERROR_KEYWORD", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_ERROR_KEYWORD" + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_CLOSE_BRACE_TOKEN" + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_VARIABLE_DECL_HAVING_BP_MUST_BE_INITIALIZED" + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_34.json b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_34.json new file mode 100644 index 000000000000..54474bc3191a --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_34.json @@ -0,0 +1,520 @@ +{ + "kind": "FUNCTION_DEFINITION", + "hasDiagnostics": true, + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "FOREACH_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "FOREACH_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "VAR_TYPE_DESC", + "children": [ + { + "kind": "VAR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "v", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "IN_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "membersList", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "hasDiagnostics": true, + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "VAR_TYPE_DESC", + "children": [ + { + "kind": "VAR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_IDENTIFIER" + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_OPEN_BRACE_TOKEN" + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "hasDiagnostics": true, + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "PARENTHESISED_TYPE_DESC", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "MAPPING_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "FIELD_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "ERROR_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "ERROR_KEYWORD", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_ERROR_KEYWORD" + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_CLOSE_BRACE_TOKEN" + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_VARIABLE_DECL_HAVING_BP_MUST_BE_INITIALIZED" + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_27.bal b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_27.bal new file mode 100644 index 000000000000..d8f6bd68b446 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_27.bal @@ -0,0 +1,7 @@ +public function test() { + foreach var v in membersList { + fail error("error!"); + } on fail var error(m) { + io:println(m); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_28.bal b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_28.bal new file mode 100644 index 000000000000..467a93a49001 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_28.bal @@ -0,0 +1,7 @@ +public function test() { + foreach var v in membersList { + fail error("error!"); + } on fail error error(m) { + io:println(m); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_29.bal b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_29.bal new file mode 100644 index 000000000000..5493ce57b7c4 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_29.bal @@ -0,0 +1,19 @@ +type SampleErrorData record {| + int userCode; + string userReason; +|}; + +type SampleError error; + +public function test() { + foreach var v in membersList { + SampleError err = error("Transaction Failure", error("Database Error"), userCode = 20, + userReason = "deadlock condition"); + fail err; + } on fail SampleError error(message, cause, userCode = code, userReason = reason) { + io:println(message); + io:println(cause); + io:println(code); + io:println(reason); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_30.bal b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_30.bal new file mode 100644 index 000000000000..aba15960d9e3 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_30.bal @@ -0,0 +1,19 @@ +type SampleErrorData record {| + int userCode; + string userReason; +|}; + +type SampleError error; + +public function test() { + foreach var v in membersList { + SampleError err = error("Transaction Failure", error("Database Error"), userCode = 20, + userReason = "deadlock condition"); + fail err; + } on fail var error(message, cause, userCode = code, userReason = reason) { + io:println(message); + io:println(cause); + io:println(code); + io:println(reason); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_31.bal b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_31.bal new file mode 100644 index 000000000000..c3d73eb51d6b --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_31.bal @@ -0,0 +1,7 @@ +public function test() { + foreach var v in membersList { + fail error("error!"); + } on fail error [err] { + io:println(err); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_32.bal b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_32.bal new file mode 100644 index 000000000000..efc77d513606 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_32.bal @@ -0,0 +1,7 @@ +public function test() { + foreach var v in membersList { + fail error("error!"); + } on fail var error(message = m) { + io:println(m); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_33.bal b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_33.bal new file mode 100644 index 000000000000..a9c9041805a4 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_33.bal @@ -0,0 +1,7 @@ +public function test() { + foreach var v in membersList { + fail error("error!"); + } on fail error(m) { + io:println(m); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_34.bal b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_34.bal new file mode 100644 index 000000000000..379e6c854d45 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_34.bal @@ -0,0 +1,7 @@ +public function test() { + foreach var v in membersList { + fail error("error!"); + } on fail var (m) { + io:println(m); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_11.json b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_11.json new file mode 100644 index 000000000000..001568eef164 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_11.json @@ -0,0 +1,377 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCK_STATEMENT", + "children": [ + { + "kind": "LOCK_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "VAR_TYPE_DESC", + "children": [ + { + "kind": "VAR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_12.json b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_12.json new file mode 100644 index 000000000000..123cb9e119d8 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_12.json @@ -0,0 +1,377 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCK_STATEMENT", + "children": [ + { + "kind": "LOCK_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_13.json b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_13.json new file mode 100644 index 000000000000..e041b3162c54 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_13.json @@ -0,0 +1,1132 @@ +{ + "kind": "MODULE_PART", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TYPE_DEFINITION", + "children": [ + { + "kind": "TYPE_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleErrorData", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "RECORD_TYPE_DESC", + "children": [ + { + "kind": "RECORD_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "OPEN_BRACE_PIPE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "RECORD_FIELD", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode" + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "RECORD_FIELD", + "children": [ + { + "kind": "STRING_TYPE_DESC", + "children": [ + { + "kind": "STRING_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "userReason" + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_PIPE_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "TYPE_DEFINITION", + "children": [ + { + "kind": "TYPE_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "TYPE_PARAMETER", + "children": [ + { + "kind": "LT_TOKEN" + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleErrorData" + } + ] + }, + { + "kind": "GT_TOKEN" + } + ] + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCK_STATEMENT", + "children": [ + { + "kind": "LOCK_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Transaction Failure" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Database Error" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "20" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userReason", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "deadlock condition" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "cause" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userReason", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "reason" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "cause" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "reason" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "EOF_TOKEN" + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_14.json b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_14.json new file mode 100644 index 000000000000..825714620a85 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_14.json @@ -0,0 +1,1131 @@ +{ + "kind": "MODULE_PART", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TYPE_DEFINITION", + "children": [ + { + "kind": "TYPE_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleErrorData", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "RECORD_TYPE_DESC", + "children": [ + { + "kind": "RECORD_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "OPEN_BRACE_PIPE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "RECORD_FIELD", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode" + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "RECORD_FIELD", + "children": [ + { + "kind": "STRING_TYPE_DESC", + "children": [ + { + "kind": "STRING_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "userReason" + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_PIPE_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "TYPE_DEFINITION", + "children": [ + { + "kind": "TYPE_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "TYPE_PARAMETER", + "children": [ + { + "kind": "LT_TOKEN" + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleErrorData" + } + ] + }, + { + "kind": "GT_TOKEN" + } + ] + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCK_STATEMENT", + "children": [ + { + "kind": "LOCK_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Transaction Failure" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Database Error" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "20" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userReason", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "deadlock condition" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "VAR_TYPE_DESC", + "children": [ + { + "kind": "VAR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "cause" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userReason", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "reason" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "cause" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "reason" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "EOF_TOKEN" + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_15.json b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_15.json new file mode 100644 index 000000000000..c196a52c928b --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_15.json @@ -0,0 +1,525 @@ +{ + "kind": "FUNCTION_DEFINITION", + "hasDiagnostics": true, + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "LOCK_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "LOCK_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "hasDiagnostics": true, + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_IDENTIFIER" + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_OPEN_BRACE_TOKEN" + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "hasDiagnostics": true, + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "TUPLE_TYPE_DESC", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "MEMBER_TYPE_DESC", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "MAPPING_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "FIELD_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "ERROR_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "ERROR_KEYWORD", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_ERROR_KEYWORD" + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_COMMA_TOKEN" + ] + }, + { + "kind": "FIELD_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "hasDiagnostics": true, + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_IDENTIFIER" + ], + "leadingMinutiae": [ + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "hasDiagnostics": true, + "children": [ + { + "kind": "SEMICOLON_TOKEN", + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_INVALID_TOKEN" + ] + } + ] + } + }, + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_VARIABLE_DECL_HAVING_BP_MUST_BE_INITIALIZED" + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_SEMICOLON_TOKEN" + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_CLOSE_BRACE_TOKEN" + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_16.json b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_16.json new file mode 100644 index 000000000000..b4ff724274d3 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_16.json @@ -0,0 +1,401 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCK_STATEMENT", + "children": [ + { + "kind": "LOCK_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "VAR_TYPE_DESC", + "children": [ + { + "kind": "VAR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_17.json b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_17.json new file mode 100644 index 000000000000..c28d9c826b2b --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_17.json @@ -0,0 +1,456 @@ +{ + "kind": "FUNCTION_DEFINITION", + "hasDiagnostics": true, + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "LOCK_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "LOCK_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "hasDiagnostics": true, + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD" + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_IDENTIFIER" + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_OPEN_BRACE_TOKEN" + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "hasDiagnostics": true, + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "PARENTHESISED_TYPE_DESC", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "MAPPING_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "FIELD_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "ERROR_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "ERROR_KEYWORD", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_ERROR_KEYWORD" + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_CLOSE_BRACE_TOKEN" + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_VARIABLE_DECL_HAVING_BP_MUST_BE_INITIALIZED" + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_18.json b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_18.json new file mode 100644 index 000000000000..ccf86216afa8 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_18.json @@ -0,0 +1,462 @@ +{ + "kind": "FUNCTION_DEFINITION", + "hasDiagnostics": true, + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "LOCK_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "LOCK_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "hasDiagnostics": true, + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "VAR_TYPE_DESC", + "children": [ + { + "kind": "VAR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_IDENTIFIER" + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_OPEN_BRACE_TOKEN" + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "hasDiagnostics": true, + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "PARENTHESISED_TYPE_DESC", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "MAPPING_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "FIELD_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "ERROR_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "ERROR_KEYWORD", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_ERROR_KEYWORD" + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_CLOSE_BRACE_TOKEN" + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_VARIABLE_DECL_HAVING_BP_MUST_BE_INITIALIZED" + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_11.bal b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_11.bal new file mode 100644 index 000000000000..96ed212a3caf --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_11.bal @@ -0,0 +1,7 @@ +public function test() { + lock { + fail error("error!"); + } on fail var error(m) { + io:println(m); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_12.bal b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_12.bal new file mode 100644 index 000000000000..cdb24b459957 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_12.bal @@ -0,0 +1,7 @@ +public function test() { + lock { + fail error("error!"); + } on fail error error(m) { + io:println(m); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_13.bal b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_13.bal new file mode 100644 index 000000000000..c41fb2f5f718 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_13.bal @@ -0,0 +1,19 @@ +type SampleErrorData record {| + int userCode; + string userReason; +|}; + +type SampleError error; + +public function test() { + lock { + SampleError err = error("Transaction Failure", error("Database Error"), userCode = 20, + userReason = "deadlock condition"); + fail err; + } on fail SampleError error(message, cause, userCode = code, userReason = reason) { + io:println(message); + io:println(cause); + io:println(code); + io:println(reason); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_14.bal b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_14.bal new file mode 100644 index 000000000000..efc2a8996bc7 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_14.bal @@ -0,0 +1,19 @@ +type SampleErrorData record {| + int userCode; + string userReason; +|}; + +type SampleError error; + +public function test() { + lock { + SampleError err = error("Transaction Failure", error("Database Error"), userCode = 20, + userReason = "deadlock condition"); + fail err; + } on fail var error(message, cause, userCode = code, userReason = reason) { + io:println(message); + io:println(cause); + io:println(code); + io:println(reason); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_15.bal b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_15.bal new file mode 100644 index 000000000000..c0021433b763 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_15.bal @@ -0,0 +1,7 @@ +public function test() { + lock { + fail error("error!"); + } on fail error [err] { + io:println(err); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_16.bal b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_16.bal new file mode 100644 index 000000000000..435e9635b488 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_16.bal @@ -0,0 +1,7 @@ +public function test() { + lock { + fail error("error!"); + } on fail var error(message = m) { + io:println(m); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_17.bal b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_17.bal new file mode 100644 index 000000000000..38487a2f35a4 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_17.bal @@ -0,0 +1,7 @@ +public function test() { + lock { + fail error("error!"); + } on fail error(m) { + io:println(m); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_18.bal b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_18.bal new file mode 100644 index 000000000000..17471d0e979e --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_18.bal @@ -0,0 +1,7 @@ +public function test() { + lock { + fail error("error!"); + } on fail var (m) { + io:println(m); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_24.json b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_24.json new file mode 100644 index 000000000000..1c3304fc3878 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_24.json @@ -0,0 +1,536 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "MATCH_STATEMENT", + "children": [ + { + "kind": "MATCH_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "bar", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "MATCH_CLAUSE", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "NIL_LITERAL", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "RIGHT_DOUBLE_ARROW_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "MATCH_CLAUSE", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "east", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "RIGHT_DOUBLE_ARROW_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "VAR_TYPE_DESC", + "children": [ + { + "kind": "VAR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_25.json b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_25.json new file mode 100644 index 000000000000..02f07ce9298a --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_25.json @@ -0,0 +1,536 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "MATCH_STATEMENT", + "children": [ + { + "kind": "MATCH_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "bar", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "MATCH_CLAUSE", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "NIL_LITERAL", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "RIGHT_DOUBLE_ARROW_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "MATCH_CLAUSE", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "east", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "RIGHT_DOUBLE_ARROW_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_26.json b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_26.json new file mode 100644 index 000000000000..c6a1ab6c71aa --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_26.json @@ -0,0 +1,1291 @@ +{ + "kind": "MODULE_PART", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TYPE_DEFINITION", + "children": [ + { + "kind": "TYPE_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleErrorData", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "RECORD_TYPE_DESC", + "children": [ + { + "kind": "RECORD_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "OPEN_BRACE_PIPE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "RECORD_FIELD", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode" + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "RECORD_FIELD", + "children": [ + { + "kind": "STRING_TYPE_DESC", + "children": [ + { + "kind": "STRING_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "userReason" + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_PIPE_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "TYPE_DEFINITION", + "children": [ + { + "kind": "TYPE_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "TYPE_PARAMETER", + "children": [ + { + "kind": "LT_TOKEN" + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleErrorData" + } + ] + }, + { + "kind": "GT_TOKEN" + } + ] + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "MATCH_STATEMENT", + "children": [ + { + "kind": "MATCH_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "bar", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "MATCH_CLAUSE", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "NIL_LITERAL", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "RIGHT_DOUBLE_ARROW_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "MATCH_CLAUSE", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "east", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "RIGHT_DOUBLE_ARROW_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Transaction Failure" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Database Error" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "20" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userReason", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "deadlock condition" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "cause" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userReason", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "reason" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "cause" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "reason" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "EOF_TOKEN" + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_27.json b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_27.json new file mode 100644 index 000000000000..b96cd5f66cc1 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_27.json @@ -0,0 +1,1290 @@ +{ + "kind": "MODULE_PART", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TYPE_DEFINITION", + "children": [ + { + "kind": "TYPE_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleErrorData", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "RECORD_TYPE_DESC", + "children": [ + { + "kind": "RECORD_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "OPEN_BRACE_PIPE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "RECORD_FIELD", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode" + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "RECORD_FIELD", + "children": [ + { + "kind": "STRING_TYPE_DESC", + "children": [ + { + "kind": "STRING_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "userReason" + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_PIPE_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "TYPE_DEFINITION", + "children": [ + { + "kind": "TYPE_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "TYPE_PARAMETER", + "children": [ + { + "kind": "LT_TOKEN" + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleErrorData" + } + ] + }, + { + "kind": "GT_TOKEN" + } + ] + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "MATCH_STATEMENT", + "children": [ + { + "kind": "MATCH_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "bar", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "MATCH_CLAUSE", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "NIL_LITERAL", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "RIGHT_DOUBLE_ARROW_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "MATCH_CLAUSE", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "east", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "RIGHT_DOUBLE_ARROW_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Transaction Failure" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Database Error" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "20" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userReason", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "deadlock condition" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "VAR_TYPE_DESC", + "children": [ + { + "kind": "VAR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "cause" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userReason", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "reason" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "cause" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "reason" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "EOF_TOKEN" + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_28.json b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_28.json new file mode 100644 index 000000000000..5e0fdb8e824c --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_28.json @@ -0,0 +1,684 @@ +{ + "kind": "FUNCTION_DEFINITION", + "hasDiagnostics": true, + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "MATCH_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "MATCH_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "bar", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "MATCH_CLAUSE", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "NIL_LITERAL", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "RIGHT_DOUBLE_ARROW_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "MATCH_CLAUSE", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "east", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "RIGHT_DOUBLE_ARROW_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "hasDiagnostics": true, + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_IDENTIFIER" + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_OPEN_BRACE_TOKEN" + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "hasDiagnostics": true, + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "TUPLE_TYPE_DESC", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "MEMBER_TYPE_DESC", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "MAPPING_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "FIELD_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "ERROR_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "ERROR_KEYWORD", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_ERROR_KEYWORD" + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_COMMA_TOKEN" + ] + }, + { + "kind": "FIELD_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "hasDiagnostics": true, + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_IDENTIFIER" + ], + "leadingMinutiae": [ + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "hasDiagnostics": true, + "children": [ + { + "kind": "SEMICOLON_TOKEN", + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_INVALID_TOKEN" + ] + } + ] + } + }, + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_VARIABLE_DECL_HAVING_BP_MUST_BE_INITIALIZED" + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_SEMICOLON_TOKEN" + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_CLOSE_BRACE_TOKEN" + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_29.json b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_29.json new file mode 100644 index 000000000000..2dbe4e51ac6e --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_29.json @@ -0,0 +1,560 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "MATCH_STATEMENT", + "children": [ + { + "kind": "MATCH_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "bar", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "MATCH_CLAUSE", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "NIL_LITERAL", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "RIGHT_DOUBLE_ARROW_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "MATCH_CLAUSE", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "east", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "RIGHT_DOUBLE_ARROW_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "VAR_TYPE_DESC", + "children": [ + { + "kind": "VAR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_30.json b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_30.json new file mode 100644 index 000000000000..ebc40268787b --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_30.json @@ -0,0 +1,615 @@ +{ + "kind": "FUNCTION_DEFINITION", + "hasDiagnostics": true, + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "MATCH_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "MATCH_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "bar", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "MATCH_CLAUSE", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "NIL_LITERAL", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "RIGHT_DOUBLE_ARROW_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "MATCH_CLAUSE", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "east", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "RIGHT_DOUBLE_ARROW_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "hasDiagnostics": true, + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD" + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_IDENTIFIER" + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_OPEN_BRACE_TOKEN" + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "hasDiagnostics": true, + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "PARENTHESISED_TYPE_DESC", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "MAPPING_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "FIELD_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "ERROR_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "ERROR_KEYWORD", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_ERROR_KEYWORD" + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_CLOSE_BRACE_TOKEN" + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_VARIABLE_DECL_HAVING_BP_MUST_BE_INITIALIZED" + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_31.json b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_31.json new file mode 100644 index 000000000000..04dc79ac829b --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_31.json @@ -0,0 +1,621 @@ +{ + "kind": "FUNCTION_DEFINITION", + "hasDiagnostics": true, + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "MATCH_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "MATCH_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "bar", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "MATCH_CLAUSE", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "NIL_LITERAL", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "RIGHT_DOUBLE_ARROW_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "MATCH_CLAUSE", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "east", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "RIGHT_DOUBLE_ARROW_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "hasDiagnostics": true, + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "VAR_TYPE_DESC", + "children": [ + { + "kind": "VAR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_IDENTIFIER" + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_OPEN_BRACE_TOKEN" + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "hasDiagnostics": true, + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "PARENTHESISED_TYPE_DESC", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "MAPPING_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "FIELD_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "ERROR_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "ERROR_KEYWORD", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_ERROR_KEYWORD" + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_CLOSE_BRACE_TOKEN" + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_VARIABLE_DECL_HAVING_BP_MUST_BE_INITIALIZED" + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_24.bal b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_24.bal new file mode 100644 index 000000000000..5c8cb5142f5d --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_24.bal @@ -0,0 +1,11 @@ +public function test() { + match bar { + () => { + } + "east" => { + fail error("error!"); + } + } on fail var error(m) { + io:println(m); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_25.bal b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_25.bal new file mode 100644 index 000000000000..29e0957c6c53 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_25.bal @@ -0,0 +1,11 @@ +public function test() { + match bar { + () => { + } + "east" => { + fail error("error!"); + } + } on fail error error(m) { + io:println(m); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_26.bal b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_26.bal new file mode 100644 index 000000000000..211defb86782 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_26.bal @@ -0,0 +1,23 @@ +type SampleErrorData record {| + int userCode; + string userReason; +|}; + +type SampleError error; + +public function test() { + match bar { + () => { + } + "east" => { + SampleError err = error("Transaction Failure", error("Database Error"), userCode = 20, + userReason = "deadlock condition"); + fail err; + } + } on fail SampleError error(message, cause, userCode = code, userReason = reason) { + io:println(message); + io:println(cause); + io:println(code); + io:println(reason); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_27.bal b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_27.bal new file mode 100644 index 000000000000..8a88304140f0 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_27.bal @@ -0,0 +1,23 @@ +type SampleErrorData record {| + int userCode; + string userReason; +|}; + +type SampleError error; + +public function test() { + match bar { + () => { + } + "east" => { + SampleError err = error("Transaction Failure", error("Database Error"), userCode = 20, + userReason = "deadlock condition"); + fail err; + } + } on fail var error(message, cause, userCode = code, userReason = reason) { + io:println(message); + io:println(cause); + io:println(code); + io:println(reason); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_28.bal b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_28.bal new file mode 100644 index 000000000000..d67694e1c690 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_28.bal @@ -0,0 +1,11 @@ +public function test() { + match bar { + () => { + } + "east" => { + fail error("error!"); + } + } on fail error [err] { + io:println(err); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_29.bal b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_29.bal new file mode 100644 index 000000000000..0d31cc7268ce --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_29.bal @@ -0,0 +1,11 @@ +public function test() { + match bar { + () => { + } + "east" => { + fail error("error!"); + } + } on fail var error(message = m) { + io:println(m); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_30.bal b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_30.bal new file mode 100644 index 000000000000..a4f4f1f0933a --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_30.bal @@ -0,0 +1,11 @@ +public function test() { + match bar { + () => { + } + "east" => { + fail error("error!"); + } + } on fail error(m) { + io:println(m); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_31.bal b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_31.bal new file mode 100644 index 000000000000..701a6b487a6b --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_31.bal @@ -0,0 +1,11 @@ +public function test() { + match bar { + () => { + } + "east" => { + fail error("error!"); + } + } on fail var (m) { + io:println(m); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_08.json b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_08.json new file mode 100644 index 000000000000..db5289a0ca36 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_08.json @@ -0,0 +1,318 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "RETRY_STATEMENT", + "children": [ + { + "kind": "RETRY_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "VAR_TYPE_DESC", + "children": [ + { + "kind": "VAR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_09.json b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_09.json new file mode 100644 index 000000000000..0322efa214c0 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_09.json @@ -0,0 +1,318 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "RETRY_STATEMENT", + "children": [ + { + "kind": "RETRY_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_10.json b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_10.json new file mode 100644 index 000000000000..4184595b348b --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_10.json @@ -0,0 +1,619 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "RETRY_STATEMENT", + "children": [ + { + "kind": "RETRY_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "cause" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userReason", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "reason" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "cause" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "reason" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_11.json b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_11.json new file mode 100644 index 000000000000..178a22ef2b55 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_11.json @@ -0,0 +1,618 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "RETRY_STATEMENT", + "children": [ + { + "kind": "RETRY_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "VAR_TYPE_DESC", + "children": [ + { + "kind": "VAR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "cause" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userReason", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "reason" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "cause" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "reason" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_12.json b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_12.json new file mode 100644 index 000000000000..4f3a71411ddf --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_12.json @@ -0,0 +1,466 @@ +{ + "kind": "FUNCTION_DEFINITION", + "hasDiagnostics": true, + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "RETRY_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "RETRY_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "hasDiagnostics": true, + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_IDENTIFIER" + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_OPEN_BRACE_TOKEN" + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "hasDiagnostics": true, + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "TUPLE_TYPE_DESC", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "MEMBER_TYPE_DESC", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "MAPPING_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "FIELD_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "ERROR_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "ERROR_KEYWORD", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_ERROR_KEYWORD" + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_COMMA_TOKEN" + ] + }, + { + "kind": "FIELD_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "hasDiagnostics": true, + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_IDENTIFIER" + ], + "leadingMinutiae": [ + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "hasDiagnostics": true, + "children": [ + { + "kind": "SEMICOLON_TOKEN", + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_INVALID_TOKEN" + ] + } + ] + } + }, + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_VARIABLE_DECL_HAVING_BP_MUST_BE_INITIALIZED" + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_SEMICOLON_TOKEN" + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_CLOSE_BRACE_TOKEN" + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_13.json b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_13.json new file mode 100644 index 000000000000..839b8791b6a7 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_13.json @@ -0,0 +1,342 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "RETRY_STATEMENT", + "children": [ + { + "kind": "RETRY_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "VAR_TYPE_DESC", + "children": [ + { + "kind": "VAR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_14.json b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_14.json new file mode 100644 index 000000000000..ab732d14a47a --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_14.json @@ -0,0 +1,397 @@ +{ + "kind": "FUNCTION_DEFINITION", + "hasDiagnostics": true, + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "RETRY_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "RETRY_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "hasDiagnostics": true, + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD" + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_IDENTIFIER" + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_OPEN_BRACE_TOKEN" + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "hasDiagnostics": true, + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "PARENTHESISED_TYPE_DESC", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "MAPPING_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "FIELD_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "ERROR_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "ERROR_KEYWORD", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_ERROR_KEYWORD" + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_CLOSE_BRACE_TOKEN" + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_VARIABLE_DECL_HAVING_BP_MUST_BE_INITIALIZED" + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_15.json b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_15.json new file mode 100644 index 000000000000..28300f5b59af --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_15.json @@ -0,0 +1,403 @@ +{ + "kind": "FUNCTION_DEFINITION", + "hasDiagnostics": true, + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "RETRY_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "RETRY_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "hasDiagnostics": true, + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "VAR_TYPE_DESC", + "children": [ + { + "kind": "VAR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_IDENTIFIER" + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_OPEN_BRACE_TOKEN" + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "hasDiagnostics": true, + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "PARENTHESISED_TYPE_DESC", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "MAPPING_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "FIELD_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "ERROR_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "ERROR_KEYWORD", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_ERROR_KEYWORD" + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_CLOSE_BRACE_TOKEN" + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_VARIABLE_DECL_HAVING_BP_MUST_BE_INITIALIZED" + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_08.bal b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_08.bal new file mode 100644 index 000000000000..207f8dfbcb93 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_08.bal @@ -0,0 +1,7 @@ +public function test() { + retry { + + } on fail var error(m) { + io:println(m); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_09.bal b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_09.bal new file mode 100644 index 000000000000..f0a656ea64fd --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_09.bal @@ -0,0 +1,7 @@ +public function test() { + retry { + + } on fail error error(m) { + io:println(m); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_10.bal b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_10.bal new file mode 100644 index 000000000000..9ef2af2ff0d9 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_10.bal @@ -0,0 +1,10 @@ +public function test() { + retry { + + } on fail SampleError error(message, cause, userCode = code, userReason = reason) { + io:println(message); + io:println(cause); + io:println(code); + io:println(reason); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_11.bal b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_11.bal new file mode 100644 index 000000000000..6eae67aebe99 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_11.bal @@ -0,0 +1,10 @@ +public function test() { + retry { + + } on fail var error(message, cause, userCode = code, userReason = reason) { + io:println(message); + io:println(cause); + io:println(code); + io:println(reason); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_12.bal b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_12.bal new file mode 100644 index 000000000000..6776d372bb64 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_12.bal @@ -0,0 +1,7 @@ +public function test() { + retry { + + } on fail error [err] { + io:println(err); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_13.bal b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_13.bal new file mode 100644 index 000000000000..76cf2062480c --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_13.bal @@ -0,0 +1,7 @@ +public function test() { + retry { + + } on fail var error(message = m) { + io:println(m); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_14.bal b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_14.bal new file mode 100644 index 000000000000..2c2af2f7e24b --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_14.bal @@ -0,0 +1,7 @@ +public function test() { + retry { + + } on fail error(m) { + io:println(m); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_15.bal b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_15.bal new file mode 100644 index 000000000000..70601aa984a8 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_15.bal @@ -0,0 +1,7 @@ +public function test() { + retry { + + } on fail var (m) { + io:println(m); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_05.json b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_05.json new file mode 100644 index 000000000000..330bfb29be29 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_05.json @@ -0,0 +1,1578 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "foo" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "VAR_TYPE_DESC", + "children": [ + { + "kind": "VAR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "a", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "5" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "VAR_TYPE_DESC", + "children": [ + { + "kind": "VAR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "STRING_TYPE_DESC", + "children": [ + { + "kind": "STRING_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "b" + } + ] + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "VAR_TYPE_DESC", + "children": [ + { + "kind": "VAR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "STRING_TYPE_DESC", + "children": [ + { + "kind": "STRING_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "b" + } + ] + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "VAR_TYPE_DESC", + "children": [ + { + "kind": "VAR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "VAR_TYPE_DESC", + "children": [ + { + "kind": "VAR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_06.json b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_06.json new file mode 100644 index 000000000000..9c13a1d520b5 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_06.json @@ -0,0 +1,1578 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "foo" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "a", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "5" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "STRING_TYPE_DESC", + "children": [ + { + "kind": "STRING_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "b" + } + ] + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "STRING_TYPE_DESC", + "children": [ + { + "kind": "STRING_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "b" + } + ] + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_07.json b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_07.json new file mode 100644 index 000000000000..8a42c39b91f2 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_07.json @@ -0,0 +1,3083 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "foo" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "cause" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userReason", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "reason" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "cause" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "reason" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "a", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "5" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "cause" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userReason", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "reason" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "cause" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "reason" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "STRING_TYPE_DESC", + "children": [ + { + "kind": "STRING_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "b" + } + ] + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "cause" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userReason", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "reason" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "cause" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "reason" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "STRING_TYPE_DESC", + "children": [ + { + "kind": "STRING_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "b" + } + ] + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "cause" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userReason", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "reason" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "cause" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "reason" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "cause" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userReason", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "reason" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "cause" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "reason" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_08.json b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_08.json new file mode 100644 index 000000000000..6417eea794d8 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_08.json @@ -0,0 +1,3078 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "foo" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "VAR_TYPE_DESC", + "children": [ + { + "kind": "VAR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "cause" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userReason", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "reason" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "cause" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "reason" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "a", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "5" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "VAR_TYPE_DESC", + "children": [ + { + "kind": "VAR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "cause" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userReason", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "reason" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "cause" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "reason" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "STRING_TYPE_DESC", + "children": [ + { + "kind": "STRING_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "b" + } + ] + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "VAR_TYPE_DESC", + "children": [ + { + "kind": "VAR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "cause" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userReason", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "reason" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "cause" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "reason" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "STRING_TYPE_DESC", + "children": [ + { + "kind": "STRING_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "b" + } + ] + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "VAR_TYPE_DESC", + "children": [ + { + "kind": "VAR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "cause" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userReason", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "reason" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "cause" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "reason" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "VAR_TYPE_DESC", + "children": [ + { + "kind": "VAR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "cause" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userReason", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "reason" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "cause" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "reason" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_09.json b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_09.json new file mode 100644 index 000000000000..8c70f0e203d8 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_09.json @@ -0,0 +1,2311 @@ +{ + "kind": "FUNCTION_DEFINITION", + "hasDiagnostics": true, + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "foo" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "hasDiagnostics": true, + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_IDENTIFIER" + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_OPEN_BRACE_TOKEN" + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "hasDiagnostics": true, + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "TUPLE_TYPE_DESC", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "MEMBER_TYPE_DESC", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "MAPPING_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "FIELD_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "ERROR_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "ERROR_KEYWORD", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_ERROR_KEYWORD" + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_COMMA_TOKEN" + ] + }, + { + "kind": "FIELD_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "hasDiagnostics": true, + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_IDENTIFIER" + ], + "leadingMinutiae": [ + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "hasDiagnostics": true, + "children": [ + { + "kind": "SEMICOLON_TOKEN", + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_INVALID_TOKEN" + ] + } + ] + } + }, + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_VARIABLE_DECL_HAVING_BP_MUST_BE_INITIALIZED" + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_SEMICOLON_TOKEN" + ] + } + ] + }, + { + "kind": "TRANSACTION_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "a", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "5" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "hasDiagnostics": true, + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_IDENTIFIER" + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_OPEN_BRACE_TOKEN" + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "hasDiagnostics": true, + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "TUPLE_TYPE_DESC", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "MEMBER_TYPE_DESC", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "MAPPING_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "FIELD_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "ERROR_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "ERROR_KEYWORD", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_ERROR_KEYWORD" + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_COMMA_TOKEN" + ] + }, + { + "kind": "FIELD_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "hasDiagnostics": true, + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_IDENTIFIER" + ], + "leadingMinutiae": [ + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "hasDiagnostics": true, + "children": [ + { + "kind": "SEMICOLON_TOKEN", + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_INVALID_TOKEN" + ] + } + ] + } + }, + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_VARIABLE_DECL_HAVING_BP_MUST_BE_INITIALIZED" + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_SEMICOLON_TOKEN" + ] + } + ] + }, + { + "kind": "TRANSACTION_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "STRING_TYPE_DESC", + "children": [ + { + "kind": "STRING_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "b" + } + ] + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "hasDiagnostics": true, + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_IDENTIFIER" + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_OPEN_BRACE_TOKEN" + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "hasDiagnostics": true, + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "TUPLE_TYPE_DESC", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "MEMBER_TYPE_DESC", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "MAPPING_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "FIELD_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "ERROR_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "ERROR_KEYWORD", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_ERROR_KEYWORD" + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_COMMA_TOKEN" + ] + }, + { + "kind": "FIELD_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "hasDiagnostics": true, + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_IDENTIFIER" + ], + "leadingMinutiae": [ + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "hasDiagnostics": true, + "children": [ + { + "kind": "SEMICOLON_TOKEN", + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_INVALID_TOKEN" + ] + } + ] + } + }, + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_VARIABLE_DECL_HAVING_BP_MUST_BE_INITIALIZED" + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_SEMICOLON_TOKEN" + ] + } + ] + }, + { + "kind": "TRANSACTION_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "STRING_TYPE_DESC", + "children": [ + { + "kind": "STRING_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "b" + } + ] + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "hasDiagnostics": true, + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_IDENTIFIER" + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_OPEN_BRACE_TOKEN" + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "hasDiagnostics": true, + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "TUPLE_TYPE_DESC", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "MEMBER_TYPE_DESC", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "MAPPING_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "FIELD_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "ERROR_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "ERROR_KEYWORD", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_ERROR_KEYWORD" + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_COMMA_TOKEN" + ] + }, + { + "kind": "FIELD_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "hasDiagnostics": true, + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_IDENTIFIER" + ], + "leadingMinutiae": [ + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "hasDiagnostics": true, + "children": [ + { + "kind": "SEMICOLON_TOKEN", + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_INVALID_TOKEN" + ] + } + ] + } + }, + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_VARIABLE_DECL_HAVING_BP_MUST_BE_INITIALIZED" + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_SEMICOLON_TOKEN" + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "hasDiagnostics": true, + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_IDENTIFIER" + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_OPEN_BRACE_TOKEN" + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "hasDiagnostics": true, + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "TUPLE_TYPE_DESC", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "MEMBER_TYPE_DESC", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "MAPPING_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "FIELD_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "ERROR_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "ERROR_KEYWORD", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_ERROR_KEYWORD" + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_COMMA_TOKEN" + ] + }, + { + "kind": "FIELD_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "hasDiagnostics": true, + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_IDENTIFIER" + ], + "leadingMinutiae": [ + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "hasDiagnostics": true, + "children": [ + { + "kind": "SEMICOLON_TOKEN", + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_INVALID_TOKEN" + ] + } + ] + } + }, + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_VARIABLE_DECL_HAVING_BP_MUST_BE_INITIALIZED" + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_SEMICOLON_TOKEN" + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_CLOSE_BRACE_TOKEN" + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_CLOSE_BRACE_TOKEN" + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_CLOSE_BRACE_TOKEN" + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_CLOSE_BRACE_TOKEN" + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_CLOSE_BRACE_TOKEN" + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_10.json b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_10.json new file mode 100644 index 000000000000..27bf8f0441bb --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_10.json @@ -0,0 +1,1698 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "foo" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "VAR_TYPE_DESC", + "children": [ + { + "kind": "VAR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "a", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "5" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "VAR_TYPE_DESC", + "children": [ + { + "kind": "VAR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "STRING_TYPE_DESC", + "children": [ + { + "kind": "STRING_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "b" + } + ] + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "VAR_TYPE_DESC", + "children": [ + { + "kind": "VAR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "STRING_TYPE_DESC", + "children": [ + { + "kind": "STRING_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "b" + } + ] + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "VAR_TYPE_DESC", + "children": [ + { + "kind": "VAR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "VAR_TYPE_DESC", + "children": [ + { + "kind": "VAR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_11.json b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_11.json new file mode 100644 index 000000000000..d41c2b9bffec --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_11.json @@ -0,0 +1,1966 @@ +{ + "kind": "FUNCTION_DEFINITION", + "hasDiagnostics": true, + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "foo" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "hasDiagnostics": true, + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD" + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_IDENTIFIER" + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_OPEN_BRACE_TOKEN" + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "hasDiagnostics": true, + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "PARENTHESISED_TYPE_DESC", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "MAPPING_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "FIELD_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "ERROR_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "ERROR_KEYWORD", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_ERROR_KEYWORD" + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_CLOSE_BRACE_TOKEN" + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_VARIABLE_DECL_HAVING_BP_MUST_BE_INITIALIZED" + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "TRANSACTION_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "a", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "5" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "hasDiagnostics": true, + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD" + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_IDENTIFIER" + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_OPEN_BRACE_TOKEN" + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "hasDiagnostics": true, + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "PARENTHESISED_TYPE_DESC", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "MAPPING_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "FIELD_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "ERROR_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "ERROR_KEYWORD", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_ERROR_KEYWORD" + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_CLOSE_BRACE_TOKEN" + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_VARIABLE_DECL_HAVING_BP_MUST_BE_INITIALIZED" + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "TRANSACTION_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "STRING_TYPE_DESC", + "children": [ + { + "kind": "STRING_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "b" + } + ] + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "hasDiagnostics": true, + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD" + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_IDENTIFIER" + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_OPEN_BRACE_TOKEN" + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "hasDiagnostics": true, + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "PARENTHESISED_TYPE_DESC", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "MAPPING_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "FIELD_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "ERROR_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "ERROR_KEYWORD", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_ERROR_KEYWORD" + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_CLOSE_BRACE_TOKEN" + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_VARIABLE_DECL_HAVING_BP_MUST_BE_INITIALIZED" + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "TRANSACTION_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "STRING_TYPE_DESC", + "children": [ + { + "kind": "STRING_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "b" + } + ] + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "hasDiagnostics": true, + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD" + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_IDENTIFIER" + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_OPEN_BRACE_TOKEN" + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "hasDiagnostics": true, + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "PARENTHESISED_TYPE_DESC", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "MAPPING_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "FIELD_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "ERROR_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "ERROR_KEYWORD", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_ERROR_KEYWORD" + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_CLOSE_BRACE_TOKEN" + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_VARIABLE_DECL_HAVING_BP_MUST_BE_INITIALIZED" + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "hasDiagnostics": true, + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD" + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_IDENTIFIER" + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_OPEN_BRACE_TOKEN" + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "hasDiagnostics": true, + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "PARENTHESISED_TYPE_DESC", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "MAPPING_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "FIELD_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "ERROR_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "ERROR_KEYWORD", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_ERROR_KEYWORD" + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_CLOSE_BRACE_TOKEN" + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_VARIABLE_DECL_HAVING_BP_MUST_BE_INITIALIZED" + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_12.json b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_12.json new file mode 100644 index 000000000000..7bd24a397b07 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_12.json @@ -0,0 +1,1996 @@ +{ + "kind": "FUNCTION_DEFINITION", + "hasDiagnostics": true, + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "foo" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "hasDiagnostics": true, + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "VAR_TYPE_DESC", + "children": [ + { + "kind": "VAR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_IDENTIFIER" + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_OPEN_BRACE_TOKEN" + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "hasDiagnostics": true, + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "PARENTHESISED_TYPE_DESC", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "MAPPING_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "FIELD_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "ERROR_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "ERROR_KEYWORD", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_ERROR_KEYWORD" + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_CLOSE_BRACE_TOKEN" + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_VARIABLE_DECL_HAVING_BP_MUST_BE_INITIALIZED" + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "TRANSACTION_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "a", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "5" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "hasDiagnostics": true, + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "VAR_TYPE_DESC", + "children": [ + { + "kind": "VAR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_IDENTIFIER" + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_OPEN_BRACE_TOKEN" + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "hasDiagnostics": true, + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "PARENTHESISED_TYPE_DESC", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "MAPPING_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "FIELD_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "ERROR_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "ERROR_KEYWORD", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_ERROR_KEYWORD" + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_CLOSE_BRACE_TOKEN" + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_VARIABLE_DECL_HAVING_BP_MUST_BE_INITIALIZED" + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "TRANSACTION_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "STRING_TYPE_DESC", + "children": [ + { + "kind": "STRING_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "b" + } + ] + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "hasDiagnostics": true, + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "VAR_TYPE_DESC", + "children": [ + { + "kind": "VAR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_IDENTIFIER" + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_OPEN_BRACE_TOKEN" + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "hasDiagnostics": true, + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "PARENTHESISED_TYPE_DESC", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "MAPPING_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "FIELD_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "ERROR_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "ERROR_KEYWORD", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_ERROR_KEYWORD" + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_CLOSE_BRACE_TOKEN" + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_VARIABLE_DECL_HAVING_BP_MUST_BE_INITIALIZED" + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "TRANSACTION_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "STRING_TYPE_DESC", + "children": [ + { + "kind": "STRING_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "b" + } + ] + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "hasDiagnostics": true, + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "VAR_TYPE_DESC", + "children": [ + { + "kind": "VAR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_IDENTIFIER" + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_OPEN_BRACE_TOKEN" + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "hasDiagnostics": true, + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "PARENTHESISED_TYPE_DESC", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "MAPPING_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "FIELD_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "ERROR_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "ERROR_KEYWORD", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_ERROR_KEYWORD" + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_CLOSE_BRACE_TOKEN" + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_VARIABLE_DECL_HAVING_BP_MUST_BE_INITIALIZED" + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "hasDiagnostics": true, + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "VAR_TYPE_DESC", + "children": [ + { + "kind": "VAR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_IDENTIFIER" + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_OPEN_BRACE_TOKEN" + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "hasDiagnostics": true, + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "PARENTHESISED_TYPE_DESC", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "MAPPING_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "FIELD_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "ERROR_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "ERROR_KEYWORD", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_ERROR_KEYWORD" + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_CLOSE_BRACE_TOKEN" + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_VARIABLE_DECL_HAVING_BP_MUST_BE_INITIALIZED" + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_05.bal b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_05.bal new file mode 100644 index 000000000000..5ffb99bb582f --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_05.bal @@ -0,0 +1,34 @@ +function foo() { + transaction { + } on fail var error(m) { + io:println(m); + } + + transaction { + int a = 5; + } on fail var error(m) { + io:println(m); + } + + transaction { + transaction { + transaction { + string b; + } + } + } on fail var error(m) { + io:println(m); + } + + transaction { + transaction { + transaction { + string b; + } on fail var error(m) { + io:println(m); + } + } + } on fail var error(m) { + io:println(m); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_06.bal b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_06.bal new file mode 100644 index 000000000000..b4df79d84968 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_06.bal @@ -0,0 +1,34 @@ +function foo() { + transaction { + } on fail error error(m) { + io:println(m); + } + + transaction { + int a = 5; + } on fail error error(m) { + io:println(m); + } + + transaction { + transaction { + transaction { + string b; + } + } + } on fail error error(m) { + io:println(m); + } + + transaction { + transaction { + transaction { + string b; + } on fail error error(m) { + io:println(m); + } + } + } on fail error error(m) { + io:println(m); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_07.bal b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_07.bal new file mode 100644 index 000000000000..aa8987c4ad00 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_07.bal @@ -0,0 +1,49 @@ +function foo() { + transaction { + } on fail SampleError error(message, cause, userCode = code, userReason = reason) { + io:println(message); + io:println(cause); + io:println(code); + io:println(reason); + } + + transaction { + int a = 5; + } on fail SampleError error(message, cause, userCode = code, userReason = reason) { + io:println(message); + io:println(cause); + io:println(code); + io:println(reason); + } + + transaction { + transaction { + transaction { + string b; + } + } + } on fail SampleError error(message, cause, userCode = code, userReason = reason) { + io:println(message); + io:println(cause); + io:println(code); + io:println(reason); + } + + transaction { + transaction { + transaction { + string b; + } on fail SampleError error(message, cause, userCode = code, userReason = reason) { + io:println(message); + io:println(cause); + io:println(code); + io:println(reason); + } + } + } on fail SampleError error(message, cause, userCode = code, userReason = reason) { + io:println(message); + io:println(cause); + io:println(code); + io:println(reason); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_08.bal b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_08.bal new file mode 100644 index 000000000000..54c6451d9eb3 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_08.bal @@ -0,0 +1,49 @@ +function foo() { + transaction { + } on fail var error(message, cause, userCode = code, userReason = reason) { + io:println(message); + io:println(cause); + io:println(code); + io:println(reason); + } + + transaction { + int a = 5; + } on fail var error(message, cause, userCode = code, userReason = reason) { + io:println(message); + io:println(cause); + io:println(code); + io:println(reason); + } + + transaction { + transaction { + transaction { + string b; + } + } + } on fail var error(message, cause, userCode = code, userReason = reason) { + io:println(message); + io:println(cause); + io:println(code); + io:println(reason); + } + + transaction { + transaction { + transaction { + string b; + } on fail var error(message, cause, userCode = code, userReason = reason) { + io:println(message); + io:println(cause); + io:println(code); + io:println(reason); + } + } + } on fail var error(message, cause, userCode = code, userReason = reason) { + io:println(message); + io:println(cause); + io:println(code); + io:println(reason); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_09.bal b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_09.bal new file mode 100644 index 000000000000..edc275af9635 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_09.bal @@ -0,0 +1,34 @@ +function foo() { + transaction { + } on fail error [err] { + io:println(err); + } + + transaction { + int a = 5; + } on fail error [err] { + io:println(err); + } + + transaction { + transaction { + transaction { + string b; + } + } + } on fail error [err] { + io:println(err); + } + + transaction { + transaction { + transaction { + string b; + } on fail error [err] { + io:println(err); + } + } + } on fail error [err] { + io:println(err); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_10.bal b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_10.bal new file mode 100644 index 000000000000..46739327f745 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_10.bal @@ -0,0 +1,34 @@ +function foo() { + transaction { + } on fail var error(message = m) { + io:println(m); + } + + transaction { + int a = 5; + } on fail var error(message = m) { + io:println(m); + } + + transaction { + transaction { + transaction { + string b; + } + } + } on fail var error(message = m) { + io:println(m); + } + + transaction { + transaction { + transaction { + string b; + } on fail var error(message = m) { + io:println(m); + } + } + } on fail var error(message = m) { + io:println(m); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_11.bal b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_11.bal new file mode 100644 index 000000000000..e39796bd0c1a --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_11.bal @@ -0,0 +1,34 @@ +function foo() { + transaction { + } on fail error(m) { + io:println(m); + } + + transaction { + int a = 5; + } on fail error(m) { + io:println(m); + } + + transaction { + transaction { + transaction { + string b; + } + } + } on fail error(m) { + io:println(m); + } + + transaction { + transaction { + transaction { + string b; + } on fail error(m) { + io:println(m); + } + } + } on fail error(m) { + io:println(m); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_12.bal b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_12.bal new file mode 100644 index 000000000000..12302fec6103 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_12.bal @@ -0,0 +1,34 @@ +function foo() { + transaction { + } on fail var (m) { + io:println(m); + } + + transaction { + int a = 5; + } on fail var (m) { + io:println(m); + } + + transaction { + transaction { + transaction { + string b; + } + } + } on fail var (m) { + io:println(m); + } + + transaction { + transaction { + transaction { + string b; + } on fail var (m) { + io:println(m); + } + } + } on fail var (m) { + io:println(m); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_07.json b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_07.json new file mode 100644 index 000000000000..1dba6d30743e --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_07.json @@ -0,0 +1,579 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "0" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "WHILE_STATEMENT", + "children": [ + { + "kind": "WHILE_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BINARY_EXPRESSION", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "LT_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "3", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "ASSIGNMENT_STATEMENT", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BINARY_EXPRESSION", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "PLUS_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "1" + } + ] + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "VAR_TYPE_DESC", + "children": [ + { + "kind": "VAR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_08.json b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_08.json new file mode 100644 index 000000000000..9e3d1432f7fa --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_08.json @@ -0,0 +1,579 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "0" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "WHILE_STATEMENT", + "children": [ + { + "kind": "WHILE_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BINARY_EXPRESSION", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "LT_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "3", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "ASSIGNMENT_STATEMENT", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BINARY_EXPRESSION", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "PLUS_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "1" + } + ] + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_09.json b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_09.json new file mode 100644 index 000000000000..0f17859fc822 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_09.json @@ -0,0 +1,1334 @@ +{ + "kind": "MODULE_PART", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TYPE_DEFINITION", + "children": [ + { + "kind": "TYPE_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleErrorData", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "RECORD_TYPE_DESC", + "children": [ + { + "kind": "RECORD_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "OPEN_BRACE_PIPE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "RECORD_FIELD", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode" + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "RECORD_FIELD", + "children": [ + { + "kind": "STRING_TYPE_DESC", + "children": [ + { + "kind": "STRING_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "userReason" + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_PIPE_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "TYPE_DEFINITION", + "children": [ + { + "kind": "TYPE_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "TYPE_PARAMETER", + "children": [ + { + "kind": "LT_TOKEN" + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleErrorData" + } + ] + }, + { + "kind": "GT_TOKEN" + } + ] + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "0" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "WHILE_STATEMENT", + "children": [ + { + "kind": "WHILE_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BINARY_EXPRESSION", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "LT_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "3", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "ASSIGNMENT_STATEMENT", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BINARY_EXPRESSION", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "PLUS_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "1" + } + ] + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Transaction Failure" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Database Error" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "20" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userReason", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "deadlock condition" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "cause" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userReason", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "reason" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "cause" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "reason" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "EOF_TOKEN" + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_10.json b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_10.json new file mode 100644 index 000000000000..402bb8dfd873 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_10.json @@ -0,0 +1,1333 @@ +{ + "kind": "MODULE_PART", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TYPE_DEFINITION", + "children": [ + { + "kind": "TYPE_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleErrorData", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "RECORD_TYPE_DESC", + "children": [ + { + "kind": "RECORD_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "OPEN_BRACE_PIPE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "RECORD_FIELD", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode" + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "RECORD_FIELD", + "children": [ + { + "kind": "STRING_TYPE_DESC", + "children": [ + { + "kind": "STRING_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "userReason" + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_PIPE_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "TYPE_DEFINITION", + "children": [ + { + "kind": "TYPE_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "TYPE_PARAMETER", + "children": [ + { + "kind": "LT_TOKEN" + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleErrorData" + } + ] + }, + { + "kind": "GT_TOKEN" + } + ] + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "0" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "WHILE_STATEMENT", + "children": [ + { + "kind": "WHILE_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BINARY_EXPRESSION", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "LT_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "3", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "ASSIGNMENT_STATEMENT", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BINARY_EXPRESSION", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "PLUS_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "1" + } + ] + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Transaction Failure" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Database Error" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "20" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userReason", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "deadlock condition" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "VAR_TYPE_DESC", + "children": [ + { + "kind": "VAR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "cause" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userReason", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "reason" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "cause" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "reason" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "EOF_TOKEN" + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_11.json b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_11.json new file mode 100644 index 000000000000..fb1d1e7d8505 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_11.json @@ -0,0 +1,727 @@ +{ + "kind": "FUNCTION_DEFINITION", + "hasDiagnostics": true, + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "0" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "WHILE_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "WHILE_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BINARY_EXPRESSION", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "LT_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "3", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "ASSIGNMENT_STATEMENT", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BINARY_EXPRESSION", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "PLUS_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "1" + } + ] + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "hasDiagnostics": true, + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_IDENTIFIER" + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_OPEN_BRACE_TOKEN" + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "hasDiagnostics": true, + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "TUPLE_TYPE_DESC", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "MEMBER_TYPE_DESC", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "MAPPING_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "FIELD_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "ERROR_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "ERROR_KEYWORD", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_ERROR_KEYWORD" + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_COMMA_TOKEN" + ] + }, + { + "kind": "FIELD_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "hasDiagnostics": true, + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_IDENTIFIER" + ], + "leadingMinutiae": [ + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "hasDiagnostics": true, + "children": [ + { + "kind": "SEMICOLON_TOKEN", + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_INVALID_TOKEN" + ] + } + ] + } + }, + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_VARIABLE_DECL_HAVING_BP_MUST_BE_INITIALIZED" + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_SEMICOLON_TOKEN" + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_CLOSE_BRACE_TOKEN" + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_12.json b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_12.json new file mode 100644 index 000000000000..df8ccfcb2916 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_12.json @@ -0,0 +1,603 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "0" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "WHILE_STATEMENT", + "children": [ + { + "kind": "WHILE_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BINARY_EXPRESSION", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "LT_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "3", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "ASSIGNMENT_STATEMENT", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BINARY_EXPRESSION", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "PLUS_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "1" + } + ] + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "VAR_TYPE_DESC", + "children": [ + { + "kind": "VAR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_13.json b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_13.json new file mode 100644 index 000000000000..031d9fe1b0ff --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_13.json @@ -0,0 +1,658 @@ +{ + "kind": "FUNCTION_DEFINITION", + "hasDiagnostics": true, + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "0" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "WHILE_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "WHILE_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BINARY_EXPRESSION", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "LT_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "3", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "ASSIGNMENT_STATEMENT", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BINARY_EXPRESSION", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "PLUS_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "1" + } + ] + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "hasDiagnostics": true, + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD" + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_IDENTIFIER" + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_OPEN_BRACE_TOKEN" + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "hasDiagnostics": true, + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "PARENTHESISED_TYPE_DESC", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "MAPPING_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "FIELD_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "ERROR_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "ERROR_KEYWORD", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_ERROR_KEYWORD" + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_CLOSE_BRACE_TOKEN" + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_VARIABLE_DECL_HAVING_BP_MUST_BE_INITIALIZED" + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_14.json b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_14.json new file mode 100644 index 000000000000..b13d37599bbd --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_14.json @@ -0,0 +1,664 @@ +{ + "kind": "FUNCTION_DEFINITION", + "hasDiagnostics": true, + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "0" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "WHILE_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "WHILE_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BINARY_EXPRESSION", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "LT_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "3", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "ASSIGNMENT_STATEMENT", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BINARY_EXPRESSION", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "PLUS_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "1" + } + ] + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "hasDiagnostics": true, + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "VAR_TYPE_DESC", + "children": [ + { + "kind": "VAR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_IDENTIFIER" + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_OPEN_BRACE_TOKEN" + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "hasDiagnostics": true, + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "PARENTHESISED_TYPE_DESC", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "MAPPING_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "FIELD_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "ERROR_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "ERROR_KEYWORD", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_ERROR_KEYWORD" + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_CLOSE_BRACE_TOKEN" + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_VARIABLE_DECL_HAVING_BP_MUST_BE_INITIALIZED" + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_07.bal b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_07.bal new file mode 100644 index 000000000000..d1405d3bf36c --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_07.bal @@ -0,0 +1,9 @@ +public function test() { + int i = 0; + while i < 3 { + i = i + 1; + fail error("error!"); + } on fail var error(m) { + io:println(m); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_08.bal b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_08.bal new file mode 100644 index 000000000000..656025fae952 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_08.bal @@ -0,0 +1,9 @@ +public function test() { + int i = 0; + while i < 3 { + i = i + 1; + fail error("error!"); + } on fail error error(m) { + io:println(m); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_09.bal b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_09.bal new file mode 100644 index 000000000000..90630166b3f4 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_09.bal @@ -0,0 +1,21 @@ +type SampleErrorData record {| + int userCode; + string userReason; +|}; + +type SampleError error; + +public function test() { + int i = 0; + while i < 3 { + i = i + 1; + SampleError err = error("Transaction Failure", error("Database Error"), userCode = 20, + userReason = "deadlock condition"); + fail err; + } on fail SampleError error(message, cause, userCode = code, userReason = reason) { + io:println(message); + io:println(cause); + io:println(code); + io:println(reason); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_10.bal b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_10.bal new file mode 100644 index 000000000000..1ad041418f07 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_10.bal @@ -0,0 +1,21 @@ +type SampleErrorData record {| + int userCode; + string userReason; +|}; + +type SampleError error; + +public function test() { + int i = 0; + while i < 3 { + i = i + 1; + SampleError err = error("Transaction Failure", error("Database Error"), userCode = 20, + userReason = "deadlock condition"); + fail err; + } on fail var error(message, cause, userCode = code, userReason = reason) { + io:println(message); + io:println(cause); + io:println(code); + io:println(reason); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_11.bal b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_11.bal new file mode 100644 index 000000000000..f9b99010a816 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_11.bal @@ -0,0 +1,9 @@ +public function test() { + int i = 0; + while i < 3 { + i = i + 1; + fail error("error!"); + } on fail error [err] { + io:println(err); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_12.bal b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_12.bal new file mode 100644 index 000000000000..2431f4c32aa9 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_12.bal @@ -0,0 +1,9 @@ +public function test() { + int i = 0; + while i < 3 { + i = i + 1; + fail error("error!"); + } on fail var error(message = m) { + io:println(m); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_13.bal b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_13.bal new file mode 100644 index 000000000000..4facab1a8dbd --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_13.bal @@ -0,0 +1,9 @@ +public function test() { + int i = 0; + while i < 3 { + i = i + 1; + fail error("error!"); + } on fail error(m) { + io:println(m); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_14.bal b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_14.bal new file mode 100644 index 000000000000..e285c1e14e78 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_14.bal @@ -0,0 +1,9 @@ +public function test() { + int i = 0; + while i < 3 { + i = i + 1; + fail error("error!"); + } on fail var (m) { + io:println(m); + } +} diff --git a/compiler/ballerina-treegen/src/main/resources/syntax_tree_descriptor.json b/compiler/ballerina-treegen/src/main/resources/syntax_tree_descriptor.json index bbd2b4f2b9c8..5befcf5e5039 100644 --- a/compiler/ballerina-treegen/src/main/resources/syntax_tree_descriptor.json +++ b/compiler/ballerina-treegen/src/main/resources/syntax_tree_descriptor.json @@ -4209,13 +4209,8 @@ "type": "Token" }, { - "name": "typeDescriptor", - "type": "TypeDescriptorNode", - "isOptional": true - }, - { - "name": "failErrorName", - "type": "IdentifierToken", + "name": "typedBindingPattern", + "type": "TypedBindingPatternNode", "isOptional": true }, { diff --git a/misc/formatter/modules/formatter-core/src/main/java/org/ballerinalang/formatter/core/FormattingTreeModifier.java b/misc/formatter/modules/formatter-core/src/main/java/org/ballerinalang/formatter/core/FormattingTreeModifier.java index 8b7487ac1d7b..ced690e44001 100644 --- a/misc/formatter/modules/formatter-core/src/main/java/org/ballerinalang/formatter/core/FormattingTreeModifier.java +++ b/misc/formatter/modules/formatter-core/src/main/java/org/ballerinalang/formatter/core/FormattingTreeModifier.java @@ -1021,16 +1021,14 @@ public BinaryExpressionNode transform(BinaryExpressionNode binaryExpressionNode) public OnFailClauseNode transform(OnFailClauseNode onFailClauseNode) { Token onKeyword = formatToken(onFailClauseNode.onKeyword(), 1, 0); Token failKeyword = formatToken(onFailClauseNode.failKeyword(), 1, 0); - TypeDescriptorNode typeDescriptor = formatNode(onFailClauseNode.typeDescriptor().orElse(null), 1, 0); - IdentifierToken failErrorName = formatToken(onFailClauseNode.failErrorName().orElse(null), 1, 0); + TypedBindingPatternNode typeBindingPattern = formatNode(onFailClauseNode.typedBindingPattern().orElse(null), 1, 0); BlockStatementNode blockStatement = formatNode(onFailClauseNode.blockStatement(), env.trailingWS, env.trailingNL); return onFailClauseNode.modify() .withOnKeyword(onKeyword) .withFailKeyword(failKeyword) - .withTypeDescriptor(typeDescriptor) - .withFailErrorName(failErrorName) + .withTypedBindingPattern(typeBindingPattern) .withBlockStatement(blockStatement) .apply(); } diff --git a/misc/syntax-api-calls-gen/src/main/resources/api_gen_syntax_tree_descriptor.json b/misc/syntax-api-calls-gen/src/main/resources/api_gen_syntax_tree_descriptor.json index 1ccf370c526a..3552019d5b93 100644 --- a/misc/syntax-api-calls-gen/src/main/resources/api_gen_syntax_tree_descriptor.json +++ b/misc/syntax-api-calls-gen/src/main/resources/api_gen_syntax_tree_descriptor.json @@ -4209,13 +4209,8 @@ "type": "Token" }, { - "name": "typeDescriptor", - "type": "TypeDescriptorNode", - "isOptional": true - }, - { - "name": "failErrorName", - "type": "IdentifierToken", + "name": "typedBindingPattern", + "type": "TypedBindingPatternNode", "isOptional": true }, { From 72fa0e2c1c8b1ebd2afae9e1680e4ec30ecc7d0d Mon Sep 17 00:00:00 2001 From: Suleka Helmini Date: Thu, 13 Apr 2023 10:13:17 +0530 Subject: [PATCH 02/33] Update pull_request_ubuntu_build.yml --- .github/workflows/pull_request_ubuntu_build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pull_request_ubuntu_build.yml b/.github/workflows/pull_request_ubuntu_build.yml index 1cd75639c9b8..eaa15edfebac 100644 --- a/.github/workflows/pull_request_ubuntu_build.yml +++ b/.github/workflows/pull_request_ubuntu_build.yml @@ -14,6 +14,7 @@ on: - 2201.[0-9]+.[0-9]+-stage - native-build - revert-client-decl-master + - on-fail-error-bp jobs: ubuntu_build: From d30d0c59db63bae3504b5c50ec3651d1e06b6a9a Mon Sep 17 00:00:00 2001 From: Suleka Helmini Date: Thu, 13 Apr 2023 10:14:00 +0530 Subject: [PATCH 03/33] Update pull_request_windows_build.yml --- .github/workflows/pull_request_windows_build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pull_request_windows_build.yml b/.github/workflows/pull_request_windows_build.yml index 1739a67f4f81..9c95f9f905aa 100644 --- a/.github/workflows/pull_request_windows_build.yml +++ b/.github/workflows/pull_request_windows_build.yml @@ -14,6 +14,7 @@ on: - 2201.[0-9]+.[0-9]+-stage - native-build - revert-client-decl-master + - on-fail-error-bp jobs: windows_build: From 9df8d27a54e84eb5eed0d41fa482f944d2a4f407 Mon Sep 17 00:00:00 2001 From: suleka96 Date: Tue, 18 Apr 2023 17:04:41 +0530 Subject: [PATCH 04/33] Update parser logic and tests --- .../internal/parser/BallerinaParser.java | 14 +- .../compiler/syntax/tree/NodeFactory.java | 3 +- .../syntax/statements/DoStatementTest.java | 17 +- .../statements/ForEachStatementTest.java | 8 +- .../misc/completion/completion_assert_07.json | 38 +- .../statements/do-stmt/do_stmt_assert_03.json | 38 +- .../statements/do-stmt/do_stmt_assert_05.json | 38 +- .../statements/do-stmt/do_stmt_assert_06.json | 86 +- .../statements/do-stmt/do_stmt_assert_12.json | 1454 +++++------- .../statements/do-stmt/do_stmt_assert_13.json | 1452 +++++------- .../statements/do-stmt/do_stmt_assert_14.json | 414 ++-- .../statements/do-stmt/do_stmt_assert_15.json | 38 +- .../statements/do-stmt/do_stmt_assert_16.json | 187 +- .../statements/do-stmt/do_stmt_assert_17.json | 187 +- .../statements/do-stmt/do_stmt_source_12.bal | 7 - .../statements/do-stmt/do_stmt_source_13.bal | 7 - .../statements/do-stmt/do_stmt_source_14.bal | 2 +- .../statements/do-stmt/do_stmt_source_15.bal | 2 +- .../forEach-stmt/forEach_stmt_assert_24.json | 38 +- .../forEach-stmt/forEach_stmt_assert_25.json | 86 +- .../forEach-stmt/forEach_stmt_assert_29.json | 1200 +--------- .../forEach-stmt/forEach_stmt_assert_30.json | 1199 +--------- .../forEach-stmt/forEach_stmt_assert_31.json | 414 ++-- .../forEach-stmt/forEach_stmt_assert_32.json | 38 +- .../forEach-stmt/forEach_stmt_assert_33.json | 187 +- .../forEach-stmt/forEach_stmt_assert_34.json | 187 +- .../forEach-stmt/forEach_stmt_source_31.bal | 2 +- .../forEach-stmt/forEach_stmt_source_32.bal | 2 +- .../lock-stmt/lock_stmt_assert_08.json | 38 +- .../lock-stmt/lock_stmt_assert_09.json | 86 +- .../lock-stmt/lock_stmt_assert_15.json | 414 ++-- .../lock-stmt/lock_stmt_assert_16.json | 38 +- .../lock-stmt/lock_stmt_assert_17.json | 187 +- .../lock-stmt/lock_stmt_assert_18.json | 187 +- .../lock-stmt/lock_stmt_source_15.bal | 2 +- .../lock-stmt/lock_stmt_source_16.bal | 2 +- .../match-stmt/match_stmt_assert_14.json | 38 +- .../match-stmt/match_stmt_assert_15.json | 86 +- .../match-stmt/match_stmt_assert_26.json | 1301 +--------- .../match-stmt/match_stmt_assert_27.json | 1300 +--------- .../match-stmt/match_stmt_assert_28.json | 414 ++-- .../match-stmt/match_stmt_assert_29.json | 38 +- .../match-stmt/match_stmt_assert_30.json | 187 +- .../match-stmt/match_stmt_assert_31.json | 187 +- .../match-stmt/match_stmt_source_28.bal | 2 +- .../match-stmt/match_stmt_source_29.bal | 2 +- .../retry_stmt_assert_05.json | 38 +- .../retry_stmt_assert_06.json | 86 +- .../retry_stmt_assert_12.json | 414 ++-- .../retry_stmt_assert_13.json | 38 +- .../retry_stmt_assert_14.json | 187 +- .../retry_stmt_assert_15.json | 187 +- .../transaction-stmt/retry_stmt_source_12.bal | 2 +- .../transaction-stmt/retry_stmt_source_13.bal | 2 +- .../transaction_stmt_assert_03.json | 190 +- .../transaction_stmt_assert_04.json | 430 ++-- .../transaction_stmt_assert_09.json | 2094 +++++++---------- .../transaction_stmt_assert_10.json | 183 +- .../transaction_stmt_assert_11.json | 949 +++----- .../transaction_stmt_assert_12.json | 949 +++----- .../transaction_stmt_source_09.bal | 10 +- .../transaction_stmt_source_10.bal | 10 +- .../while-stmt/while_stmt_assert_04.json | 38 +- .../while-stmt/while_stmt_assert_05.json | 86 +- .../while-stmt/while_stmt_assert_09.json | 1342 +---------- .../while-stmt/while_stmt_assert_10.json | 1341 +---------- .../while-stmt/while_stmt_assert_11.json | 414 ++-- .../while-stmt/while_stmt_assert_12.json | 38 +- .../while-stmt/while_stmt_assert_13.json | 187 +- .../while-stmt/while_stmt_assert_14.json | 187 +- .../while-stmt/while_stmt_source_11.bal | 2 +- .../while-stmt/while_stmt_source_12.bal | 2 +- 72 files changed, 5897 insertions(+), 15363 deletions(-) diff --git a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/BallerinaParser.java b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/BallerinaParser.java index 1057187b4fa3..4681e60cd126 100644 --- a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/BallerinaParser.java +++ b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/BallerinaParser.java @@ -13845,7 +13845,7 @@ private STNode parseOnFailClause() { STToken token = peek(); STNode typedBindingPattern = STNodeFactory.createEmptyNode(); if (token.kind != SyntaxKind.OPEN_BRACE_TOKEN) { - typedBindingPattern = addTypedBp(); + typedBindingPattern = parseTypedBindingPattern(); } STNode blockStatement = parseBlockNode(); endContext(); @@ -13853,17 +13853,11 @@ private STNode parseOnFailClause() { blockStatement); } - private STNode addTypedBp() { + private STNode parseTypedBindingPattern() { STNode typeDescriptor = parseTypeDescriptor(ParserRuleContext.TYPE_DESC_IN_TYPE_BINDING_PATTERN, true, false, TypePrecedence.DEFAULT); - STToken token = peek(); - if (token.kind == SyntaxKind.ERROR_KEYWORD) { - STNode errorBP = parseErrorBindingPattern(); - return STNodeFactory.createTypedBindingPatternNode(typeDescriptor, errorBP); - } - STNode captureBP = - STNodeFactory.createCaptureBindingPatternNode(parseIdentifier(ParserRuleContext.VARIABLE_NAME)); - return STNodeFactory.createTypedBindingPatternNode(typeDescriptor, captureBP); + STNode bindingPattern = parseBindingPattern(); + return STNodeFactory.createTypedBindingPatternNode(typeDescriptor, bindingPattern); } /** diff --git a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/NodeFactory.java b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/NodeFactory.java index 743c2a0a1583..53af63a9f546 100644 --- a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/NodeFactory.java +++ b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/NodeFactory.java @@ -3415,7 +3415,8 @@ public static ReCharSetAtomNoDashWithReCharSetNoDashNode createReCharSetAtomNoDa Objects.requireNonNull(reCharSetAtomNoDash, "reCharSetAtomNoDash must not be null"); Objects.requireNonNull(reCharSetNoDash, "reCharSetNoDash must not be null"); - STNode stReCharSetAtomNoDashWithReCharSetNoDashNode = STNodeFactory.createReCharSetAtomNoDashWithReCharSetNoDashNode( + STNode stReCharSetAtomNoDashWithReCharSetNoDashNode = + STNodeFactory.createReCharSetAtomNoDashWithReCharSetNoDashNode( reCharSetAtomNoDash.internalNode(), reCharSetNoDash.internalNode()); return stReCharSetAtomNoDashWithReCharSetNoDashNode.createUnlinkedFacade(); diff --git a/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/DoStatementTest.java b/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/DoStatementTest.java index fa6e0d6f27de..fe43c959581e 100644 --- a/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/DoStatementTest.java +++ b/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/DoStatementTest.java @@ -48,22 +48,23 @@ public void testDoWithOnFailClauseWithoutVariable() { @Test public void testDoWithOnFailClauseHavingErrorBPWithVar() { - testFile("do-stmt/do_stmt_source_10", "do-stmt/do_stmt_assert_10.json"); + testFile("do-stmt/do_stmt_source_10.bal", "do-stmt/do_stmt_assert_10.json"); } @Test public void testDoWithOnFailClauseHavingErrorBPWithType() { - testFile("do-stmt/do_stmt_source_11", "do-stmt/do_stmt_assert_11.json"); + testFile("do-stmt/do_stmt_source_11.bal", "do-stmt/do_stmt_assert_11.json"); } @Test public void testDoWithOnFailClauseHavingErrorBPWithUserDefinedError() { - testFile("do-stmt/do_stmt_source_12", "do-stmt/do_stmt_assert_12.json"); + testFile("do-stmt/do_stmt_source_12.bal", "do-stmt/do_stmt_assert_12.json"); + } @Test public void testDoWithOnFailClauseHavingErrorBPWithUserDefinedErrorWithVar() { - testFile("do-stmt/do_stmt_source_13", "do-stmt/do_stmt_assert_13.json"); + testFile("do-stmt/do_stmt_source_13.bal", "do-stmt/do_stmt_assert_13.json"); } // Recovery test @@ -77,10 +78,10 @@ public void testDoWithMissingOpenCloseBraces() { @Test public void testDoOnFailClauseRecovery() { testFile("do-stmt/do_stmt_source_06.bal", "do-stmt/do_stmt_assert_06.json"); - testFile("do-stmt/do_stmt_source_14", "do-stmt/do_stmt_assert_14.json"); - testFile("do-stmt/do_stmt_source_15", "do-stmt/do_stmt_assert_15.json"); - testFile("do-stmt/do_stmt_source_16", "do-stmt/do_stmt_assert_16.json"); - testFile("do-stmt/do_stmt_source_17", "do-stmt/do_stmt_assert_17.json"); + testFile("do-stmt/do_stmt_source_14.bal", "do-stmt/do_stmt_assert_14.json"); + testFile("do-stmt/do_stmt_source_15.bal", "do-stmt/do_stmt_assert_15.json"); + testFile("do-stmt/do_stmt_source_16.bal", "do-stmt/do_stmt_assert_16.json"); + testFile("do-stmt/do_stmt_source_17.bal", "do-stmt/do_stmt_assert_17.json"); } @Test diff --git a/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/ForEachStatementTest.java b/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/ForEachStatementTest.java index 7806b970244d..5c58fbfbd621 100644 --- a/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/ForEachStatementTest.java +++ b/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/ForEachStatementTest.java @@ -94,22 +94,22 @@ public void testForEachStmtWithOnFailClauseWithoutVariable() { @Test public void testForEachWithOnFailClauseHavingErrorBPWithVar() { - testFile("forEach-stmt/forEach_stmt_source_27", "forEach-stmt/forEach_stmt_assert_27.json"); + testFile("forEach-stmt/forEach_stmt_source_27.bal", "forEach-stmt/forEach_stmt_assert_27.json"); } @Test public void testForEachWithOnFailClauseHavingErrorBPWithType() { - testFile("forEach-stmt/forEach_stmt_source_28", "forEach-stmt/forEach_stmt_assert_28.json"); + testFile("forEach-stmt/forEach_stmt_source_28.bal", "forEach-stmt/forEach_stmt_assert_28.json"); } @Test public void testForEachWithOnFailClauseHavingErrorBPWithUserDefinedError() { - testFile("forEach-stmt/forEach_stmt_source_29", "forEach-stmt/forEach_stmt_assert_29.json"); + testFile("forEach-stmt/forEach_stmt_source_29.bal", "forEach-stmt/forEach_stmt_assert_29.json"); } @Test public void testForEachWithOnFailClauseHavingErrorBPWithUserDefinedErrorWithVar() { - testFile("forEach-stmt/forEach_stmt_source_30", "forEach-stmt/forEach_stmt_assert_30.json"); + testFile("forEach-stmt/forEach_stmt_source_30.bal", "forEach-stmt/forEach_stmt_assert_30.json"); } // Recovery tests diff --git a/compiler/ballerina-parser/src/test/resources/misc/completion/completion_assert_07.json b/compiler/ballerina-parser/src/test/resources/misc/completion/completion_assert_07.json index 62794b77ea54..26c58789b4e6 100644 --- a/compiler/ballerina-parser/src/test/resources/misc/completion/completion_assert_07.json +++ b/compiler/ballerina-parser/src/test/resources/misc/completion/completion_assert_07.json @@ -590,27 +590,39 @@ ] }, { - "kind": "SIMPLE_NAME_REFERENCE", + "kind": "TYPED_BINDING_PATTERN", "hasDiagnostics": true, "children": [ { - "kind": "IDENTIFIER_TOKEN", - "isMissing": true, + "kind": "SIMPLE_NAME_REFERENCE", "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_TYPE_DESC" + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_TYPE_DESC" + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_IDENTIFIER" + ] + } ] } ] }, - { - "kind": "IDENTIFIER_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_IDENTIFIER" - ] - }, { "kind": "BLOCK_STATEMENT", "hasDiagnostics": true, diff --git a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_03.json b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_03.json index dc8b196f4c62..7eab771de7ea 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_03.json +++ b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_03.json @@ -438,26 +438,36 @@ ] }, { - "kind": "ERROR_TYPE_DESC", + "kind": "TYPED_BINDING_PATTERN", "children": [ { - "kind": "ERROR_KEYWORD", - "trailingMinutiae": [ + "kind": "ERROR_TYPE_DESC", + "children": [ { - "kind": "WHITESPACE_MINUTIAE", - "value": " " + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] } ] - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "e", - "trailingMinutiae": [ + }, { - "kind": "WHITESPACE_MINUTIAE", - "value": " " + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "e", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] } ] }, diff --git a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_05.json b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_05.json index 6967ed504cce..a0837fc6c948 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_05.json +++ b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_05.json @@ -441,26 +441,36 @@ ] }, { - "kind": "ERROR_TYPE_DESC", + "kind": "TYPED_BINDING_PATTERN", "children": [ { - "kind": "ERROR_KEYWORD", - "trailingMinutiae": [ + "kind": "ERROR_TYPE_DESC", + "children": [ { - "kind": "WHITESPACE_MINUTIAE", - "value": " " + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] } ] - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "e", - "trailingMinutiae": [ + }, { - "kind": "WHITESPACE_MINUTIAE", - "value": " " + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "e", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] } ] }, diff --git a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_06.json b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_06.json index e6c85a1ac364..b95711e1ccab 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_06.json +++ b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_06.json @@ -459,50 +459,62 @@ ] }, { - "kind": "SIMPLE_NAME_REFERENCE", + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, "children": [ { - "kind": "IDENTIFIER_TOKEN", - "value": "extra", - "trailingMinutiae": [ + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ { - "kind": "WHITESPACE_MINUTIAE", - "value": " " + "kind": "IDENTIFIER_TOKEN", + "value": "extra", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] } ] - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "hasDiagnostics": true, - "value": "e", - "leadingMinutiae": [ - { - "kind": "INVALID_NODE_MINUTIAE", - "invalidNode": { - "kind": "INVALID_TOKEN_MINUTIAE_NODE", - "hasDiagnostics": true, - "children": [ - { - "kind": "TYPEDESC_KEYWORD", - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_INVALID_TOKEN" - ] - } - ] - } }, { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " + "kind": "CAPTURE_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "hasDiagnostics": true, + "value": "e", + "leadingMinutiae": [ + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "hasDiagnostics": true, + "children": [ + { + "kind": "TYPEDESC_KEYWORD", + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_INVALID_TOKEN" + ] + } + ] + } + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] } ] }, diff --git a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_12.json b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_12.json index e833953dc383..45b69bcec56b 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_12.json +++ b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_12.json @@ -1,232 +1,82 @@ { - "kind": "MODULE_PART", + "kind": "FUNCTION_DEFINITION", "children": [ { "kind": "LIST", - "children": [] + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" }, { "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", "children": [ { - "kind": "TYPE_DEFINITION", - "children": [ - { - "kind": "TYPE_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "SampleErrorData", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "RECORD_TYPE_DESC", - "children": [ - { - "kind": "RECORD_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "OPEN_BRACE_PIPE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "children": [ - { - "kind": "RECORD_FIELD", - "children": [ - { - "kind": "INT_TYPE_DESC", - "children": [ - { - "kind": "INT_KEYWORD", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "userCode" - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "RECORD_FIELD", - "children": [ - { - "kind": "STRING_TYPE_DESC", - "children": [ - { - "kind": "STRING_KEYWORD", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "userReason" - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_BRACE_PIPE_TOKEN" - } - ] - }, + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] - }, + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ { - "kind": "TYPE_DEFINITION", - "children": [ - { - "kind": "TYPE_KEYWORD", - "leadingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "SampleError", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ { - "kind": "ERROR_TYPE_DESC", - "children": [ - { - "kind": "ERROR_KEYWORD" - }, - { - "kind": "TYPE_PARAMETER", - "children": [ - { - "kind": "LT_TOKEN" - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "SampleErrorData" - } - ] - }, - { - "kind": "GT_TOKEN" - } - ] - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" } ] }, { - "kind": "FUNCTION_DEFINITION", + "kind": "LIST", "children": [ { - "kind": "LIST", + "kind": "DO_STATEMENT", "children": [ { - "kind": "PUBLIC_KEYWORD", + "kind": "DO_KEYWORD", "leadingMinutiae": [ { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ], "trailingMinutiae": [ @@ -235,145 +85,107 @@ "value": " " } ] - } - ] - }, - { - "kind": "FUNCTION_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "test" - }, - { - "kind": "LIST", - "children": [] - }, - { - "kind": "FUNCTION_SIGNATURE", - "children": [ - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [] }, { - "kind": "CLOSE_PAREN_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "FUNCTION_BODY_BLOCK", - "children": [ - { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", + "kind": "BLOCK_STATEMENT", "children": [ { - "kind": "DO_STATEMENT", + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", "children": [ { - "kind": "DO_KEYWORD", - "leadingMinutiae": [ + "kind": "LOCAL_VAR_DECL", + "children": [ { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ + "kind": "LIST", + "children": [] + }, { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "BLOCK_STATEMENT", - "children": [ + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, { - "kind": "OPEN_BRACE_TOKEN", + "kind": "EQUAL_TOKEN", "trailingMinutiae": [ { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] }, { - "kind": "LIST", + "kind": "ERROR_CONSTRUCTOR", "children": [ { - "kind": "LOCAL_VAR_DECL", + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", "children": [ { - "kind": "LIST", - "children": [] - }, - { - "kind": "TYPED_BINDING_PATTERN", + "kind": "POSITIONAL_ARG", "children": [ { - "kind": "SIMPLE_NAME_REFERENCE", + "kind": "STRING_LITERAL", "children": [ { - "kind": "IDENTIFIER_TOKEN", - "value": "SampleError", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "err", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] + "kind": "STRING_LITERAL_TOKEN", + "value": "Transaction Failure" } ] } ] }, { - "kind": "EQUAL_TOKEN", + "kind": "COMMA_TOKEN", "trailingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", @@ -382,207 +194,353 @@ ] }, { - "kind": "ERROR_CONSTRUCTOR", + "kind": "POSITIONAL_ARG", "children": [ { - "kind": "ERROR_KEYWORD" - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", + "kind": "ERROR_CONSTRUCTOR", "children": [ { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "STRING_LITERAL", - "children": [ - { - "kind": "STRING_LITERAL_TOKEN", - "value": "Transaction Failure" - } - ] - } - ] + "kind": "ERROR_KEYWORD" }, { - "kind": "COMMA_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] + "kind": "OPEN_PAREN_TOKEN" }, { - "kind": "POSITIONAL_ARG", + "kind": "LIST", "children": [ { - "kind": "ERROR_CONSTRUCTOR", + "kind": "POSITIONAL_ARG", "children": [ { - "kind": "ERROR_KEYWORD" - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", + "kind": "STRING_LITERAL", "children": [ { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "STRING_LITERAL", - "children": [ - { - "kind": "STRING_LITERAL_TOKEN", - "value": "Database Error" - } - ] - } - ] + "kind": "STRING_LITERAL_TOKEN", + "value": "Database Error" } ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" } ] } ] }, { - "kind": "COMMA_TOKEN", + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", "trailingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", "value": " " } ] - }, + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ { - "kind": "NAMED_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "userCode", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "20" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userReason", + "leadingMinutiae": [ { - "kind": "NUMERIC_LITERAL", - "children": [ - { - "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", - "value": "20" - } - ] + "kind": "WHITESPACE_MINUTIAE", + "value": " " } - ] - }, - { - "kind": "COMMA_TOKEN", + ], "trailingMinutiae": [ { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] - }, + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ { - "kind": "NAMED_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "userReason", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "STRING_LITERAL", - "children": [ - { - "kind": "STRING_LITERAL_TOKEN", - "value": "deadlock condition" - } - ] - } - ] + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] }, { - "kind": "CLOSE_PAREN_TOKEN" + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "deadlock condition" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "cause" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] }, { - "kind": "SEMICOLON_TOKEN", + "kind": "EQUAL_TOKEN", "trailingMinutiae": [ { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" } ] } ] }, { - "kind": "FAIL_STATEMENT", + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", "children": [ { - "kind": "FAIL_KEYWORD", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], + "kind": "IDENTIFIER_TOKEN", + "value": "userReason", "trailingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", @@ -591,20 +549,20 @@ ] }, { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ { - "kind": "IDENTIFIER_TOKEN", - "value": "err" + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] }, { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" + "kind": "IDENTIFIER_TOKEN", + "value": "reason" } ] } @@ -613,13 +571,7 @@ ] }, { - "kind": "CLOSE_BRACE_TOKEN", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], + "kind": "CLOSE_PAREN_TOKEN", "trailingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", @@ -628,164 +580,133 @@ ] } ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] }, { - "kind": "ON_FAIL_CLAUSE", + "kind": "LIST", "children": [ { - "kind": "ON_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "FAIL_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "TYPED_BINDING_PATTERN", + "kind": "CALL_STATEMENT", "children": [ { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "SampleError", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "ERROR_BINDING_PATTERN", + "kind": "FUNCTION_CALL", "children": [ { - "kind": "ERROR_KEYWORD" - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", + "kind": "QUALIFIED_NAME_REFERENCE", "children": [ { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "message" - } - ] - }, - { - "kind": "COMMA_TOKEN", - "trailingMinutiae": [ + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", - "value": " " + "value": " " } ] }, { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "cause" - } - ] + "kind": "COLON_TOKEN" }, { - "kind": "COMMA_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ { - "kind": "NAMED_ARG_BINDING_PATTERN", + "kind": "POSITIONAL_ARG", "children": [ { - "kind": "IDENTIFIER_TOKEN", - "value": "userCode", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "CAPTURE_BINDING_PATTERN", + "kind": "SIMPLE_NAME_REFERENCE", "children": [ { "kind": "IDENTIFIER_TOKEN", - "value": "code" + "value": "message" } ] } ] - }, + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ { - "kind": "COMMA_TOKEN", - "trailingMinutiae": [ + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", - "value": " " + "value": " " } ] }, { - "kind": "NAMED_ARG_BINDING_PATTERN", + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", "children": [ { - "kind": "IDENTIFIER_TOKEN", - "value": "userReason", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "CAPTURE_BINDING_PATTERN", + "kind": "SIMPLE_NAME_REFERENCE", "children": [ { "kind": "IDENTIFIER_TOKEN", - "value": "reason" + "value": "cause" } ] } @@ -794,307 +715,144 @@ ] }, { - "kind": "CLOSE_PAREN_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] + "kind": "CLOSE_PAREN_TOKEN" } ] - } - ] - }, - { - "kind": "BLOCK_STATEMENT", - "children": [ + }, { - "kind": "OPEN_BRACE_TOKEN", + "kind": "SEMICOLON_TOKEN", "trailingMinutiae": [ { "kind": "END_OF_LINE_MINUTIAE", "value": "\n" } ] - }, + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ { - "kind": "LIST", + "kind": "FUNCTION_CALL", "children": [ { - "kind": "CALL_STATEMENT", + "kind": "QUALIFIED_NAME_REFERENCE", "children": [ { - "kind": "FUNCTION_CALL", - "children": [ - { - "kind": "QUALIFIED_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "message" - } - ] - } - ] - } - ] - }, + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ { - "kind": "CLOSE_PAREN_TOKEN" + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] }, { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" } ] }, { - "kind": "CALL_STATEMENT", + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", "children": [ { - "kind": "FUNCTION_CALL", + "kind": "POSITIONAL_ARG", "children": [ { - "kind": "QUALIFIED_NAME_REFERENCE", + "kind": "SIMPLE_NAME_REFERENCE", "children": [ { "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "cause" - } - ] - } - ] + "value": "code" } ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" } ] } ] }, { - "kind": "CALL_STATEMENT", + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", "children": [ { - "kind": "FUNCTION_CALL", - "children": [ - { - "kind": "QUALIFIED_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "code" - } - ] - } - ] - } - ] - }, + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ { - "kind": "CLOSE_PAREN_TOKEN" + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] }, { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" } ] }, { - "kind": "CALL_STATEMENT", + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", "children": [ { - "kind": "FUNCTION_CALL", + "kind": "POSITIONAL_ARG", "children": [ { - "kind": "QUALIFIED_NAME_REFERENCE", + "kind": "SIMPLE_NAME_REFERENCE", "children": [ { "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "reason" - } - ] - } - ] + "value": "reason" } ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" } ] } ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" } ] }, { - "kind": "CLOSE_BRACE_TOKEN", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], + "kind": "SEMICOLON_TOKEN", "trailingMinutiae": [ { "kind": "END_OF_LINE_MINUTIAE", @@ -1105,28 +863,40 @@ ] } ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] } ] } ] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] } ] } ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] } ] - }, - { - "kind": "EOF_TOKEN" } ] } diff --git a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_13.json b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_13.json index 18baab981a82..41b502e72569 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_13.json +++ b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_13.json @@ -1,379 +1,191 @@ { - "kind": "MODULE_PART", + "kind": "FUNCTION_DEFINITION", "children": [ { "kind": "LIST", - "children": [] + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" }, { "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", "children": [ { - "kind": "TYPE_DEFINITION", - "children": [ - { - "kind": "TYPE_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "SampleErrorData", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "RECORD_TYPE_DESC", - "children": [ - { - "kind": "RECORD_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "OPEN_BRACE_PIPE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "children": [ - { - "kind": "RECORD_FIELD", - "children": [ - { - "kind": "INT_TYPE_DESC", - "children": [ - { - "kind": "INT_KEYWORD", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "userCode" - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "RECORD_FIELD", - "children": [ - { - "kind": "STRING_TYPE_DESC", - "children": [ - { - "kind": "STRING_KEYWORD", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "userReason" - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_BRACE_PIPE_TOKEN" - } - ] - }, + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] - }, + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ { - "kind": "TYPE_DEFINITION", - "children": [ - { - "kind": "TYPE_KEYWORD", - "leadingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "SampleError", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ { - "kind": "ERROR_TYPE_DESC", - "children": [ - { - "kind": "ERROR_KEYWORD" - }, - { - "kind": "TYPE_PARAMETER", - "children": [ - { - "kind": "LT_TOKEN" - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "SampleErrorData" - } - ] - }, - { - "kind": "GT_TOKEN" - } - ] - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" } ] }, { - "kind": "FUNCTION_DEFINITION", + "kind": "LIST", "children": [ { - "kind": "LIST", + "kind": "DO_STATEMENT", "children": [ { - "kind": "PUBLIC_KEYWORD", + "kind": "DO_KEYWORD", "leadingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ], - "trailingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", - "value": " " + "value": " " } - ] - } - ] - }, - { - "kind": "FUNCTION_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "test" - }, - { - "kind": "LIST", - "children": [] - }, - { - "kind": "FUNCTION_SIGNATURE", - "children": [ - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [] - }, - { - "kind": "CLOSE_PAREN_TOKEN", + ], "trailingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", "value": " " } ] - } - ] - }, - { - "kind": "FUNCTION_BODY_BLOCK", - "children": [ - { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] }, { - "kind": "LIST", + "kind": "BLOCK_STATEMENT", "children": [ { - "kind": "DO_STATEMENT", + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", "children": [ { - "kind": "DO_KEYWORD", - "leadingMinutiae": [ + "kind": "LOCAL_VAR_DECL", + "children": [ { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ + "kind": "LIST", + "children": [] + }, { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "BLOCK_STATEMENT", - "children": [ + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, { - "kind": "OPEN_BRACE_TOKEN", + "kind": "EQUAL_TOKEN", "trailingMinutiae": [ { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] }, { - "kind": "LIST", + "kind": "ERROR_CONSTRUCTOR", "children": [ { - "kind": "LOCAL_VAR_DECL", + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", "children": [ { - "kind": "LIST", - "children": [] - }, - { - "kind": "TYPED_BINDING_PATTERN", + "kind": "POSITIONAL_ARG", "children": [ { - "kind": "SIMPLE_NAME_REFERENCE", + "kind": "STRING_LITERAL", "children": [ { - "kind": "IDENTIFIER_TOKEN", - "value": "SampleError", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "err", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] + "kind": "STRING_LITERAL_TOKEN", + "value": "Transaction Failure" } ] } ] }, { - "kind": "EQUAL_TOKEN", + "kind": "COMMA_TOKEN", "trailingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", @@ -382,207 +194,352 @@ ] }, { - "kind": "ERROR_CONSTRUCTOR", + "kind": "POSITIONAL_ARG", "children": [ { - "kind": "ERROR_KEYWORD" - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", + "kind": "ERROR_CONSTRUCTOR", "children": [ { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "STRING_LITERAL", - "children": [ - { - "kind": "STRING_LITERAL_TOKEN", - "value": "Transaction Failure" - } - ] - } - ] + "kind": "ERROR_KEYWORD" }, { - "kind": "COMMA_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] + "kind": "OPEN_PAREN_TOKEN" }, { - "kind": "POSITIONAL_ARG", + "kind": "LIST", "children": [ { - "kind": "ERROR_CONSTRUCTOR", + "kind": "POSITIONAL_ARG", "children": [ { - "kind": "ERROR_KEYWORD" - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", + "kind": "STRING_LITERAL", "children": [ { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "STRING_LITERAL", - "children": [ - { - "kind": "STRING_LITERAL_TOKEN", - "value": "Database Error" - } - ] - } - ] + "kind": "STRING_LITERAL_TOKEN", + "value": "Database Error" } ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" } ] } ] }, { - "kind": "COMMA_TOKEN", + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", "trailingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", "value": " " } ] - }, + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ { - "kind": "NAMED_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "userCode", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "20" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userReason", + "leadingMinutiae": [ { - "kind": "NUMERIC_LITERAL", - "children": [ - { - "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", - "value": "20" - } - ] + "kind": "WHITESPACE_MINUTIAE", + "value": " " } - ] - }, - { - "kind": "COMMA_TOKEN", + ], "trailingMinutiae": [ { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] - }, + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ { - "kind": "NAMED_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "userReason", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "STRING_LITERAL", - "children": [ - { - "kind": "STRING_LITERAL_TOKEN", - "value": "deadlock condition" - } - ] - } - ] + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] }, { - "kind": "CLOSE_PAREN_TOKEN" + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "deadlock condition" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "VAR_TYPE_DESC", + "children": [ + { + "kind": "VAR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "cause" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] }, { - "kind": "SEMICOLON_TOKEN", + "kind": "EQUAL_TOKEN", "trailingMinutiae": [ { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" } ] } ] }, { - "kind": "FAIL_STATEMENT", + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", "children": [ { - "kind": "FAIL_KEYWORD", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], + "kind": "IDENTIFIER_TOKEN", + "value": "userReason", "trailingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", @@ -591,20 +548,20 @@ ] }, { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ { - "kind": "IDENTIFIER_TOKEN", - "value": "err" + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] }, { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" + "kind": "IDENTIFIER_TOKEN", + "value": "reason" } ] } @@ -613,13 +570,7 @@ ] }, { - "kind": "CLOSE_BRACE_TOKEN", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], + "kind": "CLOSE_PAREN_TOKEN", "trailingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", @@ -628,163 +579,133 @@ ] } ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] }, { - "kind": "ON_FAIL_CLAUSE", + "kind": "LIST", "children": [ { - "kind": "ON_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "FAIL_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "TYPED_BINDING_PATTERN", + "kind": "CALL_STATEMENT", "children": [ { - "kind": "VAR_TYPE_DESC", - "children": [ - { - "kind": "VAR_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "ERROR_BINDING_PATTERN", + "kind": "FUNCTION_CALL", "children": [ { - "kind": "ERROR_KEYWORD" - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", + "kind": "QUALIFIED_NAME_REFERENCE", "children": [ { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "message" - } - ] - }, - { - "kind": "COMMA_TOKEN", - "trailingMinutiae": [ + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", - "value": " " + "value": " " } ] }, { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "cause" - } - ] + "kind": "COLON_TOKEN" }, { - "kind": "COMMA_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ { - "kind": "NAMED_ARG_BINDING_PATTERN", + "kind": "POSITIONAL_ARG", "children": [ { - "kind": "IDENTIFIER_TOKEN", - "value": "userCode", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "CAPTURE_BINDING_PATTERN", + "kind": "SIMPLE_NAME_REFERENCE", "children": [ { "kind": "IDENTIFIER_TOKEN", - "value": "code" + "value": "message" } ] } ] - }, + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ { - "kind": "COMMA_TOKEN", - "trailingMinutiae": [ + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", - "value": " " + "value": " " } ] }, { - "kind": "NAMED_ARG_BINDING_PATTERN", + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", "children": [ { - "kind": "IDENTIFIER_TOKEN", - "value": "userReason", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "CAPTURE_BINDING_PATTERN", + "kind": "SIMPLE_NAME_REFERENCE", "children": [ { "kind": "IDENTIFIER_TOKEN", - "value": "reason" + "value": "cause" } ] } @@ -793,307 +714,144 @@ ] }, { - "kind": "CLOSE_PAREN_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] + "kind": "CLOSE_PAREN_TOKEN" } ] - } - ] - }, - { - "kind": "BLOCK_STATEMENT", - "children": [ + }, { - "kind": "OPEN_BRACE_TOKEN", + "kind": "SEMICOLON_TOKEN", "trailingMinutiae": [ { "kind": "END_OF_LINE_MINUTIAE", "value": "\n" } ] - }, + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ { - "kind": "LIST", + "kind": "FUNCTION_CALL", "children": [ { - "kind": "CALL_STATEMENT", + "kind": "QUALIFIED_NAME_REFERENCE", "children": [ { - "kind": "FUNCTION_CALL", - "children": [ - { - "kind": "QUALIFIED_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "message" - } - ] - } - ] - } - ] - }, + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ { - "kind": "CLOSE_PAREN_TOKEN" + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] }, { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" } ] }, { - "kind": "CALL_STATEMENT", + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", "children": [ { - "kind": "FUNCTION_CALL", + "kind": "POSITIONAL_ARG", "children": [ { - "kind": "QUALIFIED_NAME_REFERENCE", + "kind": "SIMPLE_NAME_REFERENCE", "children": [ { "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "cause" - } - ] - } - ] + "value": "code" } ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" } ] } ] }, { - "kind": "CALL_STATEMENT", + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", "children": [ { - "kind": "FUNCTION_CALL", - "children": [ - { - "kind": "QUALIFIED_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "code" - } - ] - } - ] - } - ] - }, + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ { - "kind": "CLOSE_PAREN_TOKEN" + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] }, { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" } ] }, { - "kind": "CALL_STATEMENT", + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", "children": [ { - "kind": "FUNCTION_CALL", + "kind": "POSITIONAL_ARG", "children": [ { - "kind": "QUALIFIED_NAME_REFERENCE", + "kind": "SIMPLE_NAME_REFERENCE", "children": [ { "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "reason" - } - ] - } - ] + "value": "reason" } ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" } ] } ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" } ] }, { - "kind": "CLOSE_BRACE_TOKEN", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], + "kind": "SEMICOLON_TOKEN", "trailingMinutiae": [ { "kind": "END_OF_LINE_MINUTIAE", @@ -1104,28 +862,40 @@ ] } ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] } ] } ] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] } ] } ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] } ] - }, - { - "kind": "EOF_TOKEN" } ] } diff --git a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_14.json b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_14.json index c5258118eef6..6a316de48e3d 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_14.json +++ b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_14.json @@ -227,15 +227,185 @@ ] }, { - "kind": "CAPTURE_BINDING_PATTERN", + "kind": "ERROR_BINDING_PATTERN", "hasDiagnostics": true, "children": [ { - "kind": "IDENTIFIER_TOKEN", + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_OPEN_PAREN_TOKEN" + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", "isMissing": true, "hasDiagnostics": true, "diagnostics": [ - "ERROR_MISSING_IDENTIFIER" + "ERROR_MISSING_CLOSE_PAREN_TOKEN" + ], + "leadingMinutiae": [ + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_BINDING_PATTERN_NOT_ALLOWED" + ] + } + ] + } + }, + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io" + } + ] + } + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "COLON_TOKEN" + } + ] + } + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + } + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + } + ] + } + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "hasDiagnostics": true, + "children": [ + { + "kind": "SEMICOLON_TOKEN", + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_INVALID_TOKEN" + ] + } + ] + } + }, + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "CLOSE_BRACE_TOKEN" + } + ] + } + }, + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } ] } ] @@ -256,243 +426,7 @@ }, { "kind": "LIST", - "hasDiagnostics": true, - "children": [ - { - "kind": "LOCAL_VAR_DECL", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "TYPED_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "TUPLE_TYPE_DESC", - "children": [ - { - "kind": "OPEN_BRACKET_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "MEMBER_TYPE_DESC", - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "err" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_BRACKET_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "MAPPING_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "hasDiagnostics": true, - "children": [ - { - "kind": "FIELD_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "ERROR_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "ERROR_KEYWORD", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_ERROR_KEYWORD" - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "err" - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - } - ] - }, - { - "kind": "COMMA_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_COMMA_TOKEN" - ] - }, - { - "kind": "FIELD_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "hasDiagnostics": true, - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_IDENTIFIER" - ], - "leadingMinutiae": [ - { - "kind": "INVALID_NODE_MINUTIAE", - "invalidNode": { - "kind": "INVALID_TOKEN_MINUTIAE_NODE", - "hasDiagnostics": true, - "children": [ - { - "kind": "SEMICOLON_TOKEN", - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_INVALID_TOKEN" - ] - } - ] - } - }, - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_VARIABLE_DECL_HAVING_BP_MUST_BE_INITIALIZED" - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "isMissing": true - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_SEMICOLON_TOKEN" - ] - } - ] - } - ] + "children": [] }, { "kind": "CLOSE_BRACE_TOKEN", diff --git a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_15.json b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_15.json index 216aa16b30cc..4725f6271b46 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_15.json +++ b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_15.json @@ -1,5 +1,6 @@ { "kind": "FUNCTION_DEFINITION", + "hasDiagnostics": true, "children": [ { "kind": "LIST", @@ -55,6 +56,7 @@ }, { "kind": "FUNCTION_BODY_BLOCK", + "hasDiagnostics": true, "children": [ { "kind": "OPEN_BRACE_TOKEN", @@ -67,9 +69,11 @@ }, { "kind": "LIST", + "hasDiagnostics": true, "children": [ { "kind": "DO_STATEMENT", + "hasDiagnostics": true, "children": [ { "kind": "DO_KEYWORD", @@ -184,6 +188,7 @@ }, { "kind": "ON_FAIL_CLAUSE", + "hasDiagnostics": true, "children": [ { "kind": "ON_KEYWORD", @@ -205,6 +210,7 @@ }, { "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, "children": [ { "kind": "VAR_TYPE_DESC", @@ -222,6 +228,7 @@ }, { "kind": "ERROR_BINDING_PATTERN", + "hasDiagnostics": true, "children": [ { "kind": "ERROR_KEYWORD" @@ -233,35 +240,17 @@ "kind": "LIST", "children": [ { - "kind": "NAMED_ARG_BINDING_PATTERN", + "kind": "CAPTURE_BINDING_PATTERN", "children": [ { "kind": "IDENTIFIER_TOKEN", - "value": "message", + "value": "m", "trailingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", "value": " " } ] - }, - { - "kind": "EQUAL_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "m" - } - ] } ] } @@ -269,11 +258,10 @@ }, { "kind": "CLOSE_PAREN_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_CLOSE_PAREN_TOKEN" ] } ] diff --git a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_16.json b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_16.json index 30f6f22d6070..75ca7a37b414 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_16.json +++ b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_16.json @@ -221,15 +221,41 @@ ] }, { - "kind": "CAPTURE_BINDING_PATTERN", + "kind": "ERROR_BINDING_PATTERN", "hasDiagnostics": true, "children": [ { - "kind": "IDENTIFIER_TOKEN", + "kind": "ERROR_KEYWORD", "isMissing": true, "hasDiagnostics": true, "diagnostics": [ - "ERROR_MISSING_IDENTIFIER" + "ERROR_MISSING_ERROR_KEYWORD" + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } ] } ] @@ -238,170 +264,71 @@ }, { "kind": "BLOCK_STATEMENT", - "hasDiagnostics": true, "children": [ { "kind": "OPEN_BRACE_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_OPEN_BRACE_TOKEN" + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } ] }, { "kind": "LIST", - "hasDiagnostics": true, "children": [ { - "kind": "LOCAL_VAR_DECL", - "hasDiagnostics": true, + "kind": "CALL_STATEMENT", "children": [ { - "kind": "LIST", - "children": [] - }, - { - "kind": "TYPED_BINDING_PATTERN", - "hasDiagnostics": true, + "kind": "FUNCTION_CALL", "children": [ { - "kind": "PARENTHESISED_TYPE_DESC", + "kind": "QUALIFIED_NAME_REFERENCE", "children": [ { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ { - "kind": "IDENTIFIER_TOKEN", - "value": "m" + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] }, { - "kind": "CLOSE_PAREN_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" } ] }, { - "kind": "MAPPING_BINDING_PATTERN", - "hasDiagnostics": true, + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", "children": [ { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "hasDiagnostics": true, + "kind": "POSITIONAL_ARG", "children": [ { - "kind": "FIELD_BINDING_PATTERN", - "hasDiagnostics": true, + "kind": "SIMPLE_NAME_REFERENCE", "children": [ { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "ERROR_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "ERROR_KEYWORD", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_ERROR_KEYWORD" - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "m" - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] + "kind": "IDENTIFIER_TOKEN", + "value": "m" } ] } ] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_CLOSE_BRACE_TOKEN" - ] } ] - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_VARIABLE_DECL_HAVING_BP_MUST_BE_INITIALIZED" - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ + }, { - "kind": "IDENTIFIER_TOKEN", - "isMissing": true + "kind": "CLOSE_PAREN_TOKEN" } ] }, diff --git a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_17.json b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_17.json index 1cfe59b81593..1d7fcbc036e6 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_17.json +++ b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_17.json @@ -227,15 +227,41 @@ ] }, { - "kind": "CAPTURE_BINDING_PATTERN", + "kind": "ERROR_BINDING_PATTERN", "hasDiagnostics": true, "children": [ { - "kind": "IDENTIFIER_TOKEN", + "kind": "ERROR_KEYWORD", "isMissing": true, "hasDiagnostics": true, "diagnostics": [ - "ERROR_MISSING_IDENTIFIER" + "ERROR_MISSING_ERROR_KEYWORD" + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } ] } ] @@ -244,170 +270,71 @@ }, { "kind": "BLOCK_STATEMENT", - "hasDiagnostics": true, "children": [ { "kind": "OPEN_BRACE_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_OPEN_BRACE_TOKEN" + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } ] }, { "kind": "LIST", - "hasDiagnostics": true, "children": [ { - "kind": "LOCAL_VAR_DECL", - "hasDiagnostics": true, + "kind": "CALL_STATEMENT", "children": [ { - "kind": "LIST", - "children": [] - }, - { - "kind": "TYPED_BINDING_PATTERN", - "hasDiagnostics": true, + "kind": "FUNCTION_CALL", "children": [ { - "kind": "PARENTHESISED_TYPE_DESC", + "kind": "QUALIFIED_NAME_REFERENCE", "children": [ { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ { - "kind": "IDENTIFIER_TOKEN", - "value": "m" + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] }, { - "kind": "CLOSE_PAREN_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" } ] }, { - "kind": "MAPPING_BINDING_PATTERN", - "hasDiagnostics": true, + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", "children": [ { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "hasDiagnostics": true, + "kind": "POSITIONAL_ARG", "children": [ { - "kind": "FIELD_BINDING_PATTERN", - "hasDiagnostics": true, + "kind": "SIMPLE_NAME_REFERENCE", "children": [ { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "ERROR_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "ERROR_KEYWORD", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_ERROR_KEYWORD" - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "m" - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] + "kind": "IDENTIFIER_TOKEN", + "value": "m" } ] } ] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_CLOSE_BRACE_TOKEN" - ] } ] - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_VARIABLE_DECL_HAVING_BP_MUST_BE_INITIALIZED" - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ + }, { - "kind": "IDENTIFIER_TOKEN", - "isMissing": true + "kind": "CLOSE_PAREN_TOKEN" } ] }, diff --git a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_12.bal b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_12.bal index f565a531e292..56d2c1019201 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_12.bal +++ b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_12.bal @@ -1,10 +1,3 @@ -type SampleErrorData record {| - int userCode; - string userReason; -|}; - -type SampleError error; - public function test() { do { SampleError err = error("Transaction Failure", error("Database Error"), userCode = 20, diff --git a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_13.bal b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_13.bal index adcbc299df20..f56d1a8ec891 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_13.bal +++ b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_13.bal @@ -1,10 +1,3 @@ -type SampleErrorData record {| - int userCode; - string userReason; -|}; - -type SampleError error; - public function test() { do { SampleError err = error("Transaction Failure", error("Database Error"), userCode = 20, diff --git a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_14.bal b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_14.bal index 725afc22b8d3..7cebfd2bcf0a 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_14.bal +++ b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_14.bal @@ -1,7 +1,7 @@ public function test() { do { fail error("error!"); - } on fail error [err] { + } on fail error error err { io:println(err); } } diff --git a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_15.bal b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_15.bal index 8be28a824ace..477555ccc9ae 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_15.bal +++ b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_15.bal @@ -1,7 +1,7 @@ public function test() { do { fail error("error!"); - } on fail var error(message = m) { + } on fail var error(m { io:println(m); } } diff --git a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_24.json b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_24.json index fc8b1635f412..40c02ab5b7c5 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_24.json +++ b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_24.json @@ -336,26 +336,36 @@ ] }, { - "kind": "ERROR_TYPE_DESC", + "kind": "TYPED_BINDING_PATTERN", "children": [ { - "kind": "ERROR_KEYWORD", - "trailingMinutiae": [ + "kind": "ERROR_TYPE_DESC", + "children": [ { - "kind": "WHITESPACE_MINUTIAE", - "value": " " + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] } ] - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "e", - "trailingMinutiae": [ + }, { - "kind": "WHITESPACE_MINUTIAE", - "value": " " + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "e", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] } ] }, diff --git a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_25.json b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_25.json index e4038e71f6fc..c2830820fa7a 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_25.json +++ b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_25.json @@ -357,50 +357,62 @@ ] }, { - "kind": "SIMPLE_NAME_REFERENCE", + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, "children": [ { - "kind": "IDENTIFIER_TOKEN", - "value": "extra", - "trailingMinutiae": [ + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ { - "kind": "WHITESPACE_MINUTIAE", - "value": " " + "kind": "IDENTIFIER_TOKEN", + "value": "extra", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] } ] - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "hasDiagnostics": true, - "value": "e", - "leadingMinutiae": [ - { - "kind": "INVALID_NODE_MINUTIAE", - "invalidNode": { - "kind": "INVALID_TOKEN_MINUTIAE_NODE", - "hasDiagnostics": true, - "children": [ - { - "kind": "TYPEDESC_KEYWORD", - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_INVALID_TOKEN" - ] - } - ] - } }, { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " + "kind": "CAPTURE_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "hasDiagnostics": true, + "value": "e", + "leadingMinutiae": [ + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "hasDiagnostics": true, + "children": [ + { + "kind": "TYPEDESC_KEYWORD", + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_INVALID_TOKEN" + ] + } + ] + } + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] } ] }, diff --git a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_29.json b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_29.json index 6b71a2f7ed99..1a8e198af7b4 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_29.json +++ b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_29.json @@ -1,1175 +1,116 @@ { - "kind": "MODULE_PART", + "kind": "TYPE_DEFINITION", "children": [ { - "kind": "LIST", - "children": [] + "kind": "TYPE_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] }, { - "kind": "LIST", + "kind": "IDENTIFIER_TOKEN", + "value": "SampleErrorData", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "RECORD_TYPE_DESC", "children": [ { - "kind": "TYPE_DEFINITION", - "children": [ - { - "kind": "TYPE_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "SampleErrorData", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "RECORD_TYPE_DESC", - "children": [ - { - "kind": "RECORD_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "OPEN_BRACE_PIPE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "children": [ - { - "kind": "RECORD_FIELD", - "children": [ - { - "kind": "INT_TYPE_DESC", - "children": [ - { - "kind": "INT_KEYWORD", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "userCode" - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "RECORD_FIELD", - "children": [ - { - "kind": "STRING_TYPE_DESC", - "children": [ - { - "kind": "STRING_KEYWORD", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "userReason" - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_BRACE_PIPE_TOKEN" - } - ] - }, + "kind": "RECORD_KEYWORD", + "trailingMinutiae": [ { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] }, { - "kind": "TYPE_DEFINITION", - "children": [ - { - "kind": "TYPE_KEYWORD", - "leadingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "SampleError", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, + "kind": "OPEN_BRACE_PIPE_TOKEN", + "trailingMinutiae": [ { - "kind": "ERROR_TYPE_DESC", - "children": [ - { - "kind": "ERROR_KEYWORD" - }, - { - "kind": "TYPE_PARAMETER", - "children": [ - { - "kind": "LT_TOKEN" - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "SampleErrorData" - } - ] - }, - { - "kind": "GT_TOKEN" - } - ] - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" } ] }, { - "kind": "FUNCTION_DEFINITION", + "kind": "LIST", "children": [ { - "kind": "LIST", + "kind": "RECORD_FIELD", "children": [ { - "kind": "PUBLIC_KEYWORD", - "leadingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ], - "trailingMinutiae": [ + "kind": "INT_TYPE_DESC", + "children": [ { - "kind": "WHITESPACE_MINUTIAE", - "value": " " + "kind": "INT_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] } ] - } - ] - }, - { - "kind": "FUNCTION_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "test" - }, - { - "kind": "LIST", - "children": [] - }, - { - "kind": "FUNCTION_SIGNATURE", - "children": [ - { - "kind": "OPEN_PAREN_TOKEN" }, { - "kind": "LIST", - "children": [] + "kind": "IDENTIFIER_TOKEN", + "value": "userCode" }, { - "kind": "CLOSE_PAREN_TOKEN", + "kind": "SEMICOLON_TOKEN", "trailingMinutiae": [ { - "kind": "WHITESPACE_MINUTIAE", - "value": " " + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" } ] } ] }, { - "kind": "FUNCTION_BODY_BLOCK", + "kind": "RECORD_FIELD", "children": [ { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", + "kind": "STRING_TYPE_DESC", "children": [ { - "kind": "FOREACH_STATEMENT", - "children": [ - { - "kind": "FOREACH_KEYWORD", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "TYPED_BINDING_PATTERN", - "children": [ - { - "kind": "VAR_TYPE_DESC", - "children": [ - { - "kind": "VAR_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "v", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - } - ] - }, - { - "kind": "IN_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "membersList", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, + "kind": "STRING_KEYWORD", + "leadingMinutiae": [ { - "kind": "BLOCK_STATEMENT", - "children": [ - { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "children": [ - { - "kind": "LOCAL_VAR_DECL", - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "TYPED_BINDING_PATTERN", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "SampleError", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "err", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "ERROR_CONSTRUCTOR", - "children": [ - { - "kind": "ERROR_KEYWORD" - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "STRING_LITERAL", - "children": [ - { - "kind": "STRING_LITERAL_TOKEN", - "value": "Transaction Failure" - } - ] - } - ] - }, - { - "kind": "COMMA_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "ERROR_CONSTRUCTOR", - "children": [ - { - "kind": "ERROR_KEYWORD" - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "STRING_LITERAL", - "children": [ - { - "kind": "STRING_LITERAL_TOKEN", - "value": "Database Error" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - } - ] - }, - { - "kind": "COMMA_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "NAMED_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "userCode", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "NUMERIC_LITERAL", - "children": [ - { - "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", - "value": "20" - } - ] - } - ] - }, - { - "kind": "COMMA_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "NAMED_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "userReason", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "STRING_LITERAL", - "children": [ - { - "kind": "STRING_LITERAL_TOKEN", - "value": "deadlock condition" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "FAIL_STATEMENT", - "children": [ - { - "kind": "FAIL_KEYWORD", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "err" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ { - "kind": "ON_FAIL_CLAUSE", - "children": [ - { - "kind": "ON_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "FAIL_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "TYPED_BINDING_PATTERN", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "SampleError", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "ERROR_BINDING_PATTERN", - "children": [ - { - "kind": "ERROR_KEYWORD" - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "message" - } - ] - }, - { - "kind": "COMMA_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "cause" - } - ] - }, - { - "kind": "COMMA_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "NAMED_ARG_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "userCode", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "code" - } - ] - } - ] - }, - { - "kind": "COMMA_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "NAMED_ARG_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "userReason", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "reason" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - } - ] - }, - { - "kind": "BLOCK_STATEMENT", - "children": [ - { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "children": [ - { - "kind": "CALL_STATEMENT", - "children": [ - { - "kind": "FUNCTION_CALL", - "children": [ - { - "kind": "QUALIFIED_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "message" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "CALL_STATEMENT", - "children": [ - { - "kind": "FUNCTION_CALL", - "children": [ - { - "kind": "QUALIFIED_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "cause" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "CALL_STATEMENT", - "children": [ - { - "kind": "FUNCTION_CALL", - "children": [ - { - "kind": "QUALIFIED_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "code" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "CALL_STATEMENT", - "children": [ - { - "kind": "FUNCTION_CALL", - "children": [ - { - "kind": "QUALIFIED_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "reason" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] } ] }, { - "kind": "CLOSE_BRACE_TOKEN", + "kind": "IDENTIFIER_TOKEN", + "value": "userReason" + }, + { + "kind": "SEMICOLON_TOKEN", "trailingMinutiae": [ { "kind": "END_OF_LINE_MINUTIAE", @@ -1180,11 +121,20 @@ ] } ] + }, + { + "kind": "CLOSE_BRACE_PIPE_TOKEN" } ] }, { - "kind": "EOF_TOKEN" + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] } ] } diff --git a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_30.json b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_30.json index 750132592b64..1a8e198af7b4 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_30.json +++ b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_30.json @@ -1,1174 +1,116 @@ { - "kind": "MODULE_PART", + "kind": "TYPE_DEFINITION", "children": [ { - "kind": "LIST", - "children": [] + "kind": "TYPE_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] }, { - "kind": "LIST", + "kind": "IDENTIFIER_TOKEN", + "value": "SampleErrorData", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "RECORD_TYPE_DESC", "children": [ { - "kind": "TYPE_DEFINITION", - "children": [ - { - "kind": "TYPE_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "SampleErrorData", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "RECORD_TYPE_DESC", - "children": [ - { - "kind": "RECORD_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "OPEN_BRACE_PIPE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "children": [ - { - "kind": "RECORD_FIELD", - "children": [ - { - "kind": "INT_TYPE_DESC", - "children": [ - { - "kind": "INT_KEYWORD", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "userCode" - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "RECORD_FIELD", - "children": [ - { - "kind": "STRING_TYPE_DESC", - "children": [ - { - "kind": "STRING_KEYWORD", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "userReason" - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_BRACE_PIPE_TOKEN" - } - ] - }, + "kind": "RECORD_KEYWORD", + "trailingMinutiae": [ { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] }, { - "kind": "TYPE_DEFINITION", - "children": [ - { - "kind": "TYPE_KEYWORD", - "leadingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "SampleError", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, + "kind": "OPEN_BRACE_PIPE_TOKEN", + "trailingMinutiae": [ { - "kind": "ERROR_TYPE_DESC", - "children": [ - { - "kind": "ERROR_KEYWORD" - }, - { - "kind": "TYPE_PARAMETER", - "children": [ - { - "kind": "LT_TOKEN" - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "SampleErrorData" - } - ] - }, - { - "kind": "GT_TOKEN" - } - ] - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" } ] }, { - "kind": "FUNCTION_DEFINITION", + "kind": "LIST", "children": [ { - "kind": "LIST", + "kind": "RECORD_FIELD", "children": [ { - "kind": "PUBLIC_KEYWORD", - "leadingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ], - "trailingMinutiae": [ + "kind": "INT_TYPE_DESC", + "children": [ { - "kind": "WHITESPACE_MINUTIAE", - "value": " " + "kind": "INT_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] } ] - } - ] - }, - { - "kind": "FUNCTION_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "test" - }, - { - "kind": "LIST", - "children": [] - }, - { - "kind": "FUNCTION_SIGNATURE", - "children": [ - { - "kind": "OPEN_PAREN_TOKEN" }, { - "kind": "LIST", - "children": [] + "kind": "IDENTIFIER_TOKEN", + "value": "userCode" }, { - "kind": "CLOSE_PAREN_TOKEN", + "kind": "SEMICOLON_TOKEN", "trailingMinutiae": [ { - "kind": "WHITESPACE_MINUTIAE", - "value": " " + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" } ] } ] }, { - "kind": "FUNCTION_BODY_BLOCK", + "kind": "RECORD_FIELD", "children": [ { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", + "kind": "STRING_TYPE_DESC", "children": [ { - "kind": "FOREACH_STATEMENT", - "children": [ - { - "kind": "FOREACH_KEYWORD", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "TYPED_BINDING_PATTERN", - "children": [ - { - "kind": "VAR_TYPE_DESC", - "children": [ - { - "kind": "VAR_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "v", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - } - ] - }, - { - "kind": "IN_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "membersList", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, + "kind": "STRING_KEYWORD", + "leadingMinutiae": [ { - "kind": "BLOCK_STATEMENT", - "children": [ - { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "children": [ - { - "kind": "LOCAL_VAR_DECL", - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "TYPED_BINDING_PATTERN", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "SampleError", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "err", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "ERROR_CONSTRUCTOR", - "children": [ - { - "kind": "ERROR_KEYWORD" - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "STRING_LITERAL", - "children": [ - { - "kind": "STRING_LITERAL_TOKEN", - "value": "Transaction Failure" - } - ] - } - ] - }, - { - "kind": "COMMA_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "ERROR_CONSTRUCTOR", - "children": [ - { - "kind": "ERROR_KEYWORD" - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "STRING_LITERAL", - "children": [ - { - "kind": "STRING_LITERAL_TOKEN", - "value": "Database Error" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - } - ] - }, - { - "kind": "COMMA_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "NAMED_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "userCode", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "NUMERIC_LITERAL", - "children": [ - { - "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", - "value": "20" - } - ] - } - ] - }, - { - "kind": "COMMA_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "NAMED_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "userReason", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "STRING_LITERAL", - "children": [ - { - "kind": "STRING_LITERAL_TOKEN", - "value": "deadlock condition" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "FAIL_STATEMENT", - "children": [ - { - "kind": "FAIL_KEYWORD", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "err" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ { - "kind": "ON_FAIL_CLAUSE", - "children": [ - { - "kind": "ON_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "FAIL_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "TYPED_BINDING_PATTERN", - "children": [ - { - "kind": "VAR_TYPE_DESC", - "children": [ - { - "kind": "VAR_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "ERROR_BINDING_PATTERN", - "children": [ - { - "kind": "ERROR_KEYWORD" - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "message" - } - ] - }, - { - "kind": "COMMA_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "cause" - } - ] - }, - { - "kind": "COMMA_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "NAMED_ARG_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "userCode", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "code" - } - ] - } - ] - }, - { - "kind": "COMMA_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "NAMED_ARG_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "userReason", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "reason" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - } - ] - }, - { - "kind": "BLOCK_STATEMENT", - "children": [ - { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "children": [ - { - "kind": "CALL_STATEMENT", - "children": [ - { - "kind": "FUNCTION_CALL", - "children": [ - { - "kind": "QUALIFIED_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "message" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "CALL_STATEMENT", - "children": [ - { - "kind": "FUNCTION_CALL", - "children": [ - { - "kind": "QUALIFIED_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "cause" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "CALL_STATEMENT", - "children": [ - { - "kind": "FUNCTION_CALL", - "children": [ - { - "kind": "QUALIFIED_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "code" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "CALL_STATEMENT", - "children": [ - { - "kind": "FUNCTION_CALL", - "children": [ - { - "kind": "QUALIFIED_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "reason" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] } ] }, { - "kind": "CLOSE_BRACE_TOKEN", + "kind": "IDENTIFIER_TOKEN", + "value": "userReason" + }, + { + "kind": "SEMICOLON_TOKEN", "trailingMinutiae": [ { "kind": "END_OF_LINE_MINUTIAE", @@ -1179,11 +121,20 @@ ] } ] + }, + { + "kind": "CLOSE_BRACE_PIPE_TOKEN" } ] }, { - "kind": "EOF_TOKEN" + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] } ] } diff --git a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_31.json b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_31.json index 41fd6ac1add9..56be005e4e64 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_31.json +++ b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_31.json @@ -285,15 +285,185 @@ ] }, { - "kind": "CAPTURE_BINDING_PATTERN", + "kind": "ERROR_BINDING_PATTERN", "hasDiagnostics": true, "children": [ { - "kind": "IDENTIFIER_TOKEN", + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_OPEN_PAREN_TOKEN" + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", "isMissing": true, "hasDiagnostics": true, "diagnostics": [ - "ERROR_MISSING_IDENTIFIER" + "ERROR_MISSING_CLOSE_PAREN_TOKEN" + ], + "leadingMinutiae": [ + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_BINDING_PATTERN_NOT_ALLOWED" + ] + } + ] + } + }, + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io" + } + ] + } + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "COLON_TOKEN" + } + ] + } + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + } + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + } + ] + } + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "hasDiagnostics": true, + "children": [ + { + "kind": "SEMICOLON_TOKEN", + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_INVALID_TOKEN" + ] + } + ] + } + }, + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "CLOSE_BRACE_TOKEN" + } + ] + } + }, + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } ] } ] @@ -314,243 +484,7 @@ }, { "kind": "LIST", - "hasDiagnostics": true, - "children": [ - { - "kind": "LOCAL_VAR_DECL", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "TYPED_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "TUPLE_TYPE_DESC", - "children": [ - { - "kind": "OPEN_BRACKET_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "MEMBER_TYPE_DESC", - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "err" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_BRACKET_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "MAPPING_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "hasDiagnostics": true, - "children": [ - { - "kind": "FIELD_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "ERROR_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "ERROR_KEYWORD", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_ERROR_KEYWORD" - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "err" - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - } - ] - }, - { - "kind": "COMMA_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_COMMA_TOKEN" - ] - }, - { - "kind": "FIELD_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "hasDiagnostics": true, - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_IDENTIFIER" - ], - "leadingMinutiae": [ - { - "kind": "INVALID_NODE_MINUTIAE", - "invalidNode": { - "kind": "INVALID_TOKEN_MINUTIAE_NODE", - "hasDiagnostics": true, - "children": [ - { - "kind": "SEMICOLON_TOKEN", - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_INVALID_TOKEN" - ] - } - ] - } - }, - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_VARIABLE_DECL_HAVING_BP_MUST_BE_INITIALIZED" - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "isMissing": true - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_SEMICOLON_TOKEN" - ] - } - ] - } - ] + "children": [] }, { "kind": "CLOSE_BRACE_TOKEN", diff --git a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_32.json b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_32.json index e611a62d1ba6..b91064d5cff7 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_32.json +++ b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_32.json @@ -1,5 +1,6 @@ { "kind": "FUNCTION_DEFINITION", + "hasDiagnostics": true, "children": [ { "kind": "LIST", @@ -55,6 +56,7 @@ }, { "kind": "FUNCTION_BODY_BLOCK", + "hasDiagnostics": true, "children": [ { "kind": "OPEN_BRACE_TOKEN", @@ -67,9 +69,11 @@ }, { "kind": "LIST", + "hasDiagnostics": true, "children": [ { "kind": "FOREACH_STATEMENT", + "hasDiagnostics": true, "children": [ { "kind": "FOREACH_KEYWORD", @@ -242,6 +246,7 @@ }, { "kind": "ON_FAIL_CLAUSE", + "hasDiagnostics": true, "children": [ { "kind": "ON_KEYWORD", @@ -263,6 +268,7 @@ }, { "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, "children": [ { "kind": "VAR_TYPE_DESC", @@ -280,6 +286,7 @@ }, { "kind": "ERROR_BINDING_PATTERN", + "hasDiagnostics": true, "children": [ { "kind": "ERROR_KEYWORD" @@ -291,35 +298,17 @@ "kind": "LIST", "children": [ { - "kind": "NAMED_ARG_BINDING_PATTERN", + "kind": "CAPTURE_BINDING_PATTERN", "children": [ { "kind": "IDENTIFIER_TOKEN", - "value": "message", + "value": "m", "trailingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", "value": " " } ] - }, - { - "kind": "EQUAL_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "m" - } - ] } ] } @@ -327,11 +316,10 @@ }, { "kind": "CLOSE_PAREN_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_CLOSE_PAREN_TOKEN" ] } ] diff --git a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_33.json b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_33.json index 33e9105b5dc5..07109f4ff1b9 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_33.json +++ b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_33.json @@ -279,15 +279,41 @@ ] }, { - "kind": "CAPTURE_BINDING_PATTERN", + "kind": "ERROR_BINDING_PATTERN", "hasDiagnostics": true, "children": [ { - "kind": "IDENTIFIER_TOKEN", + "kind": "ERROR_KEYWORD", "isMissing": true, "hasDiagnostics": true, "diagnostics": [ - "ERROR_MISSING_IDENTIFIER" + "ERROR_MISSING_ERROR_KEYWORD" + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } ] } ] @@ -296,170 +322,71 @@ }, { "kind": "BLOCK_STATEMENT", - "hasDiagnostics": true, "children": [ { "kind": "OPEN_BRACE_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_OPEN_BRACE_TOKEN" + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } ] }, { "kind": "LIST", - "hasDiagnostics": true, "children": [ { - "kind": "LOCAL_VAR_DECL", - "hasDiagnostics": true, + "kind": "CALL_STATEMENT", "children": [ { - "kind": "LIST", - "children": [] - }, - { - "kind": "TYPED_BINDING_PATTERN", - "hasDiagnostics": true, + "kind": "FUNCTION_CALL", "children": [ { - "kind": "PARENTHESISED_TYPE_DESC", + "kind": "QUALIFIED_NAME_REFERENCE", "children": [ { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ { - "kind": "IDENTIFIER_TOKEN", - "value": "m" + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] }, { - "kind": "CLOSE_PAREN_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" } ] }, { - "kind": "MAPPING_BINDING_PATTERN", - "hasDiagnostics": true, + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", "children": [ { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "hasDiagnostics": true, + "kind": "POSITIONAL_ARG", "children": [ { - "kind": "FIELD_BINDING_PATTERN", - "hasDiagnostics": true, + "kind": "SIMPLE_NAME_REFERENCE", "children": [ { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "ERROR_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "ERROR_KEYWORD", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_ERROR_KEYWORD" - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "m" - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] + "kind": "IDENTIFIER_TOKEN", + "value": "m" } ] } ] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_CLOSE_BRACE_TOKEN" - ] } ] - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_VARIABLE_DECL_HAVING_BP_MUST_BE_INITIALIZED" - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ + }, { - "kind": "IDENTIFIER_TOKEN", - "isMissing": true + "kind": "CLOSE_PAREN_TOKEN" } ] }, diff --git a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_34.json b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_34.json index 54474bc3191a..b7e81be8d84f 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_34.json +++ b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_34.json @@ -285,15 +285,41 @@ ] }, { - "kind": "CAPTURE_BINDING_PATTERN", + "kind": "ERROR_BINDING_PATTERN", "hasDiagnostics": true, "children": [ { - "kind": "IDENTIFIER_TOKEN", + "kind": "ERROR_KEYWORD", "isMissing": true, "hasDiagnostics": true, "diagnostics": [ - "ERROR_MISSING_IDENTIFIER" + "ERROR_MISSING_ERROR_KEYWORD" + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } ] } ] @@ -302,170 +328,71 @@ }, { "kind": "BLOCK_STATEMENT", - "hasDiagnostics": true, "children": [ { "kind": "OPEN_BRACE_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_OPEN_BRACE_TOKEN" + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } ] }, { "kind": "LIST", - "hasDiagnostics": true, "children": [ { - "kind": "LOCAL_VAR_DECL", - "hasDiagnostics": true, + "kind": "CALL_STATEMENT", "children": [ { - "kind": "LIST", - "children": [] - }, - { - "kind": "TYPED_BINDING_PATTERN", - "hasDiagnostics": true, + "kind": "FUNCTION_CALL", "children": [ { - "kind": "PARENTHESISED_TYPE_DESC", + "kind": "QUALIFIED_NAME_REFERENCE", "children": [ { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ { - "kind": "IDENTIFIER_TOKEN", - "value": "m" + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] }, { - "kind": "CLOSE_PAREN_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" } ] }, { - "kind": "MAPPING_BINDING_PATTERN", - "hasDiagnostics": true, + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", "children": [ { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "hasDiagnostics": true, + "kind": "POSITIONAL_ARG", "children": [ { - "kind": "FIELD_BINDING_PATTERN", - "hasDiagnostics": true, + "kind": "SIMPLE_NAME_REFERENCE", "children": [ { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "ERROR_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "ERROR_KEYWORD", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_ERROR_KEYWORD" - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "m" - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] + "kind": "IDENTIFIER_TOKEN", + "value": "m" } ] } ] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_CLOSE_BRACE_TOKEN" - ] } ] - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_VARIABLE_DECL_HAVING_BP_MUST_BE_INITIALIZED" - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ + }, { - "kind": "IDENTIFIER_TOKEN", - "isMissing": true + "kind": "CLOSE_PAREN_TOKEN" } ] }, diff --git a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_31.bal b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_31.bal index c3d73eb51d6b..2dc698a24358 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_31.bal +++ b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_31.bal @@ -1,7 +1,7 @@ public function test() { foreach var v in membersList { fail error("error!"); - } on fail error [err] { + } on fail error error err { io:println(err); } } diff --git a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_32.bal b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_32.bal index efc77d513606..6a88de6a1689 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_32.bal +++ b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_32.bal @@ -1,7 +1,7 @@ public function test() { foreach var v in membersList { fail error("error!"); - } on fail var error(message = m) { + } on fail var error(m { io:println(m); } } diff --git a/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_08.json b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_08.json index af0c3d9549a2..e92f3030f412 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_08.json +++ b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_08.json @@ -145,26 +145,36 @@ ] }, { - "kind": "ERROR_TYPE_DESC", + "kind": "TYPED_BINDING_PATTERN", "children": [ { - "kind": "ERROR_KEYWORD", - "trailingMinutiae": [ + "kind": "ERROR_TYPE_DESC", + "children": [ { - "kind": "WHITESPACE_MINUTIAE", - "value": " " + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] } ] - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "e", - "trailingMinutiae": [ + }, { - "kind": "WHITESPACE_MINUTIAE", - "value": " " + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "e", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] } ] }, diff --git a/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_09.json b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_09.json index 2a4ab08628c3..61c0c3e81762 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_09.json +++ b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_09.json @@ -170,50 +170,62 @@ ] }, { - "kind": "SIMPLE_NAME_REFERENCE", + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, "children": [ { - "kind": "IDENTIFIER_TOKEN", - "value": "extra", - "trailingMinutiae": [ + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ { - "kind": "WHITESPACE_MINUTIAE", - "value": " " + "kind": "IDENTIFIER_TOKEN", + "value": "extra", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] } ] - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "hasDiagnostics": true, - "value": "e", - "leadingMinutiae": [ - { - "kind": "INVALID_NODE_MINUTIAE", - "invalidNode": { - "kind": "INVALID_TOKEN_MINUTIAE_NODE", - "hasDiagnostics": true, - "children": [ - { - "kind": "TYPEDESC_KEYWORD", - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_INVALID_TOKEN" - ] - } - ] - } }, { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " + "kind": "CAPTURE_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "hasDiagnostics": true, + "value": "e", + "leadingMinutiae": [ + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "hasDiagnostics": true, + "children": [ + { + "kind": "TYPEDESC_KEYWORD", + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_INVALID_TOKEN" + ] + } + ] + } + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] } ] }, diff --git a/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_15.json b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_15.json index c196a52c928b..f0fd352f6e45 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_15.json +++ b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_15.json @@ -227,15 +227,185 @@ ] }, { - "kind": "CAPTURE_BINDING_PATTERN", + "kind": "ERROR_BINDING_PATTERN", "hasDiagnostics": true, "children": [ { - "kind": "IDENTIFIER_TOKEN", + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_OPEN_PAREN_TOKEN" + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", "isMissing": true, "hasDiagnostics": true, "diagnostics": [ - "ERROR_MISSING_IDENTIFIER" + "ERROR_MISSING_CLOSE_PAREN_TOKEN" + ], + "leadingMinutiae": [ + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_BINDING_PATTERN_NOT_ALLOWED" + ] + } + ] + } + }, + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io" + } + ] + } + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "COLON_TOKEN" + } + ] + } + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + } + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + } + ] + } + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "hasDiagnostics": true, + "children": [ + { + "kind": "SEMICOLON_TOKEN", + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_INVALID_TOKEN" + ] + } + ] + } + }, + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "CLOSE_BRACE_TOKEN" + } + ] + } + }, + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } ] } ] @@ -256,243 +426,7 @@ }, { "kind": "LIST", - "hasDiagnostics": true, - "children": [ - { - "kind": "LOCAL_VAR_DECL", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "TYPED_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "TUPLE_TYPE_DESC", - "children": [ - { - "kind": "OPEN_BRACKET_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "MEMBER_TYPE_DESC", - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "err" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_BRACKET_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "MAPPING_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "hasDiagnostics": true, - "children": [ - { - "kind": "FIELD_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "ERROR_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "ERROR_KEYWORD", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_ERROR_KEYWORD" - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "err" - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - } - ] - }, - { - "kind": "COMMA_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_COMMA_TOKEN" - ] - }, - { - "kind": "FIELD_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "hasDiagnostics": true, - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_IDENTIFIER" - ], - "leadingMinutiae": [ - { - "kind": "INVALID_NODE_MINUTIAE", - "invalidNode": { - "kind": "INVALID_TOKEN_MINUTIAE_NODE", - "hasDiagnostics": true, - "children": [ - { - "kind": "SEMICOLON_TOKEN", - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_INVALID_TOKEN" - ] - } - ] - } - }, - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_VARIABLE_DECL_HAVING_BP_MUST_BE_INITIALIZED" - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "isMissing": true - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_SEMICOLON_TOKEN" - ] - } - ] - } - ] + "children": [] }, { "kind": "CLOSE_BRACE_TOKEN", diff --git a/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_16.json b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_16.json index b4ff724274d3..c869e63698e0 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_16.json +++ b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_16.json @@ -1,5 +1,6 @@ { "kind": "FUNCTION_DEFINITION", + "hasDiagnostics": true, "children": [ { "kind": "LIST", @@ -55,6 +56,7 @@ }, { "kind": "FUNCTION_BODY_BLOCK", + "hasDiagnostics": true, "children": [ { "kind": "OPEN_BRACE_TOKEN", @@ -67,9 +69,11 @@ }, { "kind": "LIST", + "hasDiagnostics": true, "children": [ { "kind": "LOCK_STATEMENT", + "hasDiagnostics": true, "children": [ { "kind": "LOCK_KEYWORD", @@ -184,6 +188,7 @@ }, { "kind": "ON_FAIL_CLAUSE", + "hasDiagnostics": true, "children": [ { "kind": "ON_KEYWORD", @@ -205,6 +210,7 @@ }, { "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, "children": [ { "kind": "VAR_TYPE_DESC", @@ -222,6 +228,7 @@ }, { "kind": "ERROR_BINDING_PATTERN", + "hasDiagnostics": true, "children": [ { "kind": "ERROR_KEYWORD" @@ -233,35 +240,17 @@ "kind": "LIST", "children": [ { - "kind": "NAMED_ARG_BINDING_PATTERN", + "kind": "CAPTURE_BINDING_PATTERN", "children": [ { "kind": "IDENTIFIER_TOKEN", - "value": "message", + "value": "m", "trailingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", "value": " " } ] - }, - { - "kind": "EQUAL_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "m" - } - ] } ] } @@ -269,11 +258,10 @@ }, { "kind": "CLOSE_PAREN_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_CLOSE_PAREN_TOKEN" ] } ] diff --git a/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_17.json b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_17.json index c28d9c826b2b..637bf1143407 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_17.json +++ b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_17.json @@ -221,15 +221,41 @@ ] }, { - "kind": "CAPTURE_BINDING_PATTERN", + "kind": "ERROR_BINDING_PATTERN", "hasDiagnostics": true, "children": [ { - "kind": "IDENTIFIER_TOKEN", + "kind": "ERROR_KEYWORD", "isMissing": true, "hasDiagnostics": true, "diagnostics": [ - "ERROR_MISSING_IDENTIFIER" + "ERROR_MISSING_ERROR_KEYWORD" + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } ] } ] @@ -238,170 +264,71 @@ }, { "kind": "BLOCK_STATEMENT", - "hasDiagnostics": true, "children": [ { "kind": "OPEN_BRACE_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_OPEN_BRACE_TOKEN" + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } ] }, { "kind": "LIST", - "hasDiagnostics": true, "children": [ { - "kind": "LOCAL_VAR_DECL", - "hasDiagnostics": true, + "kind": "CALL_STATEMENT", "children": [ { - "kind": "LIST", - "children": [] - }, - { - "kind": "TYPED_BINDING_PATTERN", - "hasDiagnostics": true, + "kind": "FUNCTION_CALL", "children": [ { - "kind": "PARENTHESISED_TYPE_DESC", + "kind": "QUALIFIED_NAME_REFERENCE", "children": [ { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ { - "kind": "IDENTIFIER_TOKEN", - "value": "m" + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] }, { - "kind": "CLOSE_PAREN_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" } ] }, { - "kind": "MAPPING_BINDING_PATTERN", - "hasDiagnostics": true, + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", "children": [ { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "hasDiagnostics": true, + "kind": "POSITIONAL_ARG", "children": [ { - "kind": "FIELD_BINDING_PATTERN", - "hasDiagnostics": true, + "kind": "SIMPLE_NAME_REFERENCE", "children": [ { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "ERROR_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "ERROR_KEYWORD", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_ERROR_KEYWORD" - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "m" - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] + "kind": "IDENTIFIER_TOKEN", + "value": "m" } ] } ] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_CLOSE_BRACE_TOKEN" - ] } ] - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_VARIABLE_DECL_HAVING_BP_MUST_BE_INITIALIZED" - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ + }, { - "kind": "IDENTIFIER_TOKEN", - "isMissing": true + "kind": "CLOSE_PAREN_TOKEN" } ] }, diff --git a/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_18.json b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_18.json index ccf86216afa8..9ef9e43f7079 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_18.json +++ b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_18.json @@ -227,15 +227,41 @@ ] }, { - "kind": "CAPTURE_BINDING_PATTERN", + "kind": "ERROR_BINDING_PATTERN", "hasDiagnostics": true, "children": [ { - "kind": "IDENTIFIER_TOKEN", + "kind": "ERROR_KEYWORD", "isMissing": true, "hasDiagnostics": true, "diagnostics": [ - "ERROR_MISSING_IDENTIFIER" + "ERROR_MISSING_ERROR_KEYWORD" + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } ] } ] @@ -244,170 +270,71 @@ }, { "kind": "BLOCK_STATEMENT", - "hasDiagnostics": true, "children": [ { "kind": "OPEN_BRACE_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_OPEN_BRACE_TOKEN" + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } ] }, { "kind": "LIST", - "hasDiagnostics": true, "children": [ { - "kind": "LOCAL_VAR_DECL", - "hasDiagnostics": true, + "kind": "CALL_STATEMENT", "children": [ { - "kind": "LIST", - "children": [] - }, - { - "kind": "TYPED_BINDING_PATTERN", - "hasDiagnostics": true, + "kind": "FUNCTION_CALL", "children": [ { - "kind": "PARENTHESISED_TYPE_DESC", + "kind": "QUALIFIED_NAME_REFERENCE", "children": [ { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ { - "kind": "IDENTIFIER_TOKEN", - "value": "m" + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] }, { - "kind": "CLOSE_PAREN_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" } ] }, { - "kind": "MAPPING_BINDING_PATTERN", - "hasDiagnostics": true, + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", "children": [ { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "hasDiagnostics": true, + "kind": "POSITIONAL_ARG", "children": [ { - "kind": "FIELD_BINDING_PATTERN", - "hasDiagnostics": true, + "kind": "SIMPLE_NAME_REFERENCE", "children": [ { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "ERROR_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "ERROR_KEYWORD", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_ERROR_KEYWORD" - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "m" - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] + "kind": "IDENTIFIER_TOKEN", + "value": "m" } ] } ] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_CLOSE_BRACE_TOKEN" - ] } ] - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_VARIABLE_DECL_HAVING_BP_MUST_BE_INITIALIZED" - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ + }, { - "kind": "IDENTIFIER_TOKEN", - "isMissing": true + "kind": "CLOSE_PAREN_TOKEN" } ] }, diff --git a/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_15.bal b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_15.bal index c0021433b763..cc26de9a6c5f 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_15.bal +++ b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_15.bal @@ -1,7 +1,7 @@ public function test() { lock { fail error("error!"); - } on fail error [err] { + } on fail error error err { io:println(err); } } diff --git a/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_16.bal b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_16.bal index 435e9635b488..eab76146191e 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_16.bal +++ b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_16.bal @@ -1,7 +1,7 @@ public function test() { lock { fail error("error!"); - } on fail var error(message = m) { + } on fail var error(m { io:println(m); } } diff --git a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_14.json b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_14.json index 0264daccabb7..8deabc9428df 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_14.json +++ b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_14.json @@ -854,26 +854,36 @@ ] }, { - "kind": "ERROR_TYPE_DESC", + "kind": "TYPED_BINDING_PATTERN", "children": [ { - "kind": "ERROR_KEYWORD", - "trailingMinutiae": [ + "kind": "ERROR_TYPE_DESC", + "children": [ { - "kind": "WHITESPACE_MINUTIAE", - "value": " " + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] } ] - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "e", - "trailingMinutiae": [ + }, { - "kind": "WHITESPACE_MINUTIAE", - "value": " " + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "e", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] } ] }, diff --git a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_15.json b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_15.json index bf07648716ee..708d3fc0d2b1 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_15.json +++ b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_15.json @@ -762,50 +762,62 @@ ] }, { - "kind": "SIMPLE_NAME_REFERENCE", + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, "children": [ { - "kind": "IDENTIFIER_TOKEN", - "value": "extra", - "trailingMinutiae": [ + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ { - "kind": "WHITESPACE_MINUTIAE", - "value": " " + "kind": "IDENTIFIER_TOKEN", + "value": "extra", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] } ] - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "hasDiagnostics": true, - "value": "e", - "leadingMinutiae": [ - { - "kind": "INVALID_NODE_MINUTIAE", - "invalidNode": { - "kind": "INVALID_TOKEN_MINUTIAE_NODE", - "hasDiagnostics": true, - "children": [ - { - "kind": "TYPEDESC_KEYWORD", - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_INVALID_TOKEN" - ] - } - ] - } }, { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " + "kind": "CAPTURE_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "hasDiagnostics": true, + "value": "e", + "leadingMinutiae": [ + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "hasDiagnostics": true, + "children": [ + { + "kind": "TYPEDESC_KEYWORD", + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_INVALID_TOKEN" + ] + } + ] + } + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] } ] }, diff --git a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_26.json b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_26.json index c6a1ab6c71aa..1a8e198af7b4 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_26.json +++ b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_26.json @@ -1,1276 +1,116 @@ { - "kind": "MODULE_PART", + "kind": "TYPE_DEFINITION", "children": [ { - "kind": "LIST", - "children": [] + "kind": "TYPE_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] }, { - "kind": "LIST", + "kind": "IDENTIFIER_TOKEN", + "value": "SampleErrorData", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "RECORD_TYPE_DESC", "children": [ { - "kind": "TYPE_DEFINITION", - "children": [ - { - "kind": "TYPE_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "SampleErrorData", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "RECORD_TYPE_DESC", - "children": [ - { - "kind": "RECORD_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "OPEN_BRACE_PIPE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "children": [ - { - "kind": "RECORD_FIELD", - "children": [ - { - "kind": "INT_TYPE_DESC", - "children": [ - { - "kind": "INT_KEYWORD", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "userCode" - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "RECORD_FIELD", - "children": [ - { - "kind": "STRING_TYPE_DESC", - "children": [ - { - "kind": "STRING_KEYWORD", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "userReason" - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_BRACE_PIPE_TOKEN" - } - ] - }, + "kind": "RECORD_KEYWORD", + "trailingMinutiae": [ { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] }, { - "kind": "TYPE_DEFINITION", - "children": [ - { - "kind": "TYPE_KEYWORD", - "leadingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "SampleError", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, + "kind": "OPEN_BRACE_PIPE_TOKEN", + "trailingMinutiae": [ { - "kind": "ERROR_TYPE_DESC", - "children": [ - { - "kind": "ERROR_KEYWORD" - }, - { - "kind": "TYPE_PARAMETER", - "children": [ - { - "kind": "LT_TOKEN" - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "SampleErrorData" - } - ] - }, - { - "kind": "GT_TOKEN" - } - ] - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" } ] }, { - "kind": "FUNCTION_DEFINITION", + "kind": "LIST", "children": [ { - "kind": "LIST", + "kind": "RECORD_FIELD", "children": [ { - "kind": "PUBLIC_KEYWORD", - "leadingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ], - "trailingMinutiae": [ + "kind": "INT_TYPE_DESC", + "children": [ { - "kind": "WHITESPACE_MINUTIAE", - "value": " " + "kind": "INT_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] } ] - } - ] - }, - { - "kind": "FUNCTION_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "test" - }, - { - "kind": "LIST", - "children": [] - }, - { - "kind": "FUNCTION_SIGNATURE", - "children": [ - { - "kind": "OPEN_PAREN_TOKEN" }, { - "kind": "LIST", - "children": [] + "kind": "IDENTIFIER_TOKEN", + "value": "userCode" }, { - "kind": "CLOSE_PAREN_TOKEN", + "kind": "SEMICOLON_TOKEN", "trailingMinutiae": [ { - "kind": "WHITESPACE_MINUTIAE", - "value": " " + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" } ] } ] }, { - "kind": "FUNCTION_BODY_BLOCK", + "kind": "RECORD_FIELD", "children": [ { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", + "kind": "STRING_TYPE_DESC", "children": [ { - "kind": "MATCH_STATEMENT", - "children": [ - { - "kind": "MATCH_KEYWORD", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "bar", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "children": [ - { - "kind": "MATCH_CLAUSE", - "children": [ - { - "kind": "LIST", - "children": [ - { - "kind": "NIL_LITERAL", - "children": [ - { - "kind": "OPEN_PAREN_TOKEN", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - } - ] - }, - { - "kind": "RIGHT_DOUBLE_ARROW_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "BLOCK_STATEMENT", - "children": [ - { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "children": [] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - }, - { - "kind": "MATCH_CLAUSE", - "children": [ - { - "kind": "LIST", - "children": [ - { - "kind": "STRING_LITERAL", - "children": [ - { - "kind": "STRING_LITERAL_TOKEN", - "value": "east", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - } - ] - }, - { - "kind": "RIGHT_DOUBLE_ARROW_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "BLOCK_STATEMENT", - "children": [ - { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "children": [ - { - "kind": "LOCAL_VAR_DECL", - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "TYPED_BINDING_PATTERN", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "SampleError", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "err", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "ERROR_CONSTRUCTOR", - "children": [ - { - "kind": "ERROR_KEYWORD" - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "STRING_LITERAL", - "children": [ - { - "kind": "STRING_LITERAL_TOKEN", - "value": "Transaction Failure" - } - ] - } - ] - }, - { - "kind": "COMMA_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "ERROR_CONSTRUCTOR", - "children": [ - { - "kind": "ERROR_KEYWORD" - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "STRING_LITERAL", - "children": [ - { - "kind": "STRING_LITERAL_TOKEN", - "value": "Database Error" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - } - ] - }, - { - "kind": "COMMA_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "NAMED_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "userCode", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "NUMERIC_LITERAL", - "children": [ - { - "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", - "value": "20" - } - ] - } - ] - }, - { - "kind": "COMMA_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "NAMED_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "userReason", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "STRING_LITERAL", - "children": [ - { - "kind": "STRING_LITERAL_TOKEN", - "value": "deadlock condition" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "FAIL_STATEMENT", - "children": [ - { - "kind": "FAIL_KEYWORD", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "err" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - } - ] - }, + "kind": "STRING_KEYWORD", + "leadingMinutiae": [ { - "kind": "CLOSE_BRACE_TOKEN", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ { - "kind": "ON_FAIL_CLAUSE", - "children": [ - { - "kind": "ON_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "FAIL_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "TYPED_BINDING_PATTERN", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "SampleError", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "ERROR_BINDING_PATTERN", - "children": [ - { - "kind": "ERROR_KEYWORD" - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "message" - } - ] - }, - { - "kind": "COMMA_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "cause" - } - ] - }, - { - "kind": "COMMA_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "NAMED_ARG_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "userCode", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "code" - } - ] - } - ] - }, - { - "kind": "COMMA_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "NAMED_ARG_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "userReason", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "reason" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - } - ] - }, - { - "kind": "BLOCK_STATEMENT", - "children": [ - { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "children": [ - { - "kind": "CALL_STATEMENT", - "children": [ - { - "kind": "FUNCTION_CALL", - "children": [ - { - "kind": "QUALIFIED_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "message" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "CALL_STATEMENT", - "children": [ - { - "kind": "FUNCTION_CALL", - "children": [ - { - "kind": "QUALIFIED_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "cause" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "CALL_STATEMENT", - "children": [ - { - "kind": "FUNCTION_CALL", - "children": [ - { - "kind": "QUALIFIED_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "code" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "CALL_STATEMENT", - "children": [ - { - "kind": "FUNCTION_CALL", - "children": [ - { - "kind": "QUALIFIED_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "reason" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] } ] }, { - "kind": "CLOSE_BRACE_TOKEN", + "kind": "IDENTIFIER_TOKEN", + "value": "userReason" + }, + { + "kind": "SEMICOLON_TOKEN", "trailingMinutiae": [ { "kind": "END_OF_LINE_MINUTIAE", @@ -1281,11 +121,20 @@ ] } ] + }, + { + "kind": "CLOSE_BRACE_PIPE_TOKEN" } ] }, { - "kind": "EOF_TOKEN" + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] } ] } diff --git a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_27.json b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_27.json index b96cd5f66cc1..1a8e198af7b4 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_27.json +++ b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_27.json @@ -1,1275 +1,116 @@ { - "kind": "MODULE_PART", + "kind": "TYPE_DEFINITION", "children": [ { - "kind": "LIST", - "children": [] + "kind": "TYPE_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] }, { - "kind": "LIST", + "kind": "IDENTIFIER_TOKEN", + "value": "SampleErrorData", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "RECORD_TYPE_DESC", "children": [ { - "kind": "TYPE_DEFINITION", - "children": [ - { - "kind": "TYPE_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "SampleErrorData", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "RECORD_TYPE_DESC", - "children": [ - { - "kind": "RECORD_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "OPEN_BRACE_PIPE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "children": [ - { - "kind": "RECORD_FIELD", - "children": [ - { - "kind": "INT_TYPE_DESC", - "children": [ - { - "kind": "INT_KEYWORD", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "userCode" - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "RECORD_FIELD", - "children": [ - { - "kind": "STRING_TYPE_DESC", - "children": [ - { - "kind": "STRING_KEYWORD", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "userReason" - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_BRACE_PIPE_TOKEN" - } - ] - }, + "kind": "RECORD_KEYWORD", + "trailingMinutiae": [ { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] }, { - "kind": "TYPE_DEFINITION", - "children": [ - { - "kind": "TYPE_KEYWORD", - "leadingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "SampleError", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, + "kind": "OPEN_BRACE_PIPE_TOKEN", + "trailingMinutiae": [ { - "kind": "ERROR_TYPE_DESC", - "children": [ - { - "kind": "ERROR_KEYWORD" - }, - { - "kind": "TYPE_PARAMETER", - "children": [ - { - "kind": "LT_TOKEN" - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "SampleErrorData" - } - ] - }, - { - "kind": "GT_TOKEN" - } - ] - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" } ] }, { - "kind": "FUNCTION_DEFINITION", + "kind": "LIST", "children": [ { - "kind": "LIST", + "kind": "RECORD_FIELD", "children": [ { - "kind": "PUBLIC_KEYWORD", - "leadingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ], - "trailingMinutiae": [ + "kind": "INT_TYPE_DESC", + "children": [ { - "kind": "WHITESPACE_MINUTIAE", - "value": " " + "kind": "INT_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] } ] - } - ] - }, - { - "kind": "FUNCTION_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "test" - }, - { - "kind": "LIST", - "children": [] - }, - { - "kind": "FUNCTION_SIGNATURE", - "children": [ - { - "kind": "OPEN_PAREN_TOKEN" }, { - "kind": "LIST", - "children": [] + "kind": "IDENTIFIER_TOKEN", + "value": "userCode" }, { - "kind": "CLOSE_PAREN_TOKEN", + "kind": "SEMICOLON_TOKEN", "trailingMinutiae": [ { - "kind": "WHITESPACE_MINUTIAE", - "value": " " + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" } ] } ] }, { - "kind": "FUNCTION_BODY_BLOCK", + "kind": "RECORD_FIELD", "children": [ { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", + "kind": "STRING_TYPE_DESC", "children": [ { - "kind": "MATCH_STATEMENT", - "children": [ - { - "kind": "MATCH_KEYWORD", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "bar", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "children": [ - { - "kind": "MATCH_CLAUSE", - "children": [ - { - "kind": "LIST", - "children": [ - { - "kind": "NIL_LITERAL", - "children": [ - { - "kind": "OPEN_PAREN_TOKEN", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - } - ] - }, - { - "kind": "RIGHT_DOUBLE_ARROW_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "BLOCK_STATEMENT", - "children": [ - { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "children": [] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - }, - { - "kind": "MATCH_CLAUSE", - "children": [ - { - "kind": "LIST", - "children": [ - { - "kind": "STRING_LITERAL", - "children": [ - { - "kind": "STRING_LITERAL_TOKEN", - "value": "east", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - } - ] - }, - { - "kind": "RIGHT_DOUBLE_ARROW_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "BLOCK_STATEMENT", - "children": [ - { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "children": [ - { - "kind": "LOCAL_VAR_DECL", - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "TYPED_BINDING_PATTERN", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "SampleError", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "err", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "ERROR_CONSTRUCTOR", - "children": [ - { - "kind": "ERROR_KEYWORD" - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "STRING_LITERAL", - "children": [ - { - "kind": "STRING_LITERAL_TOKEN", - "value": "Transaction Failure" - } - ] - } - ] - }, - { - "kind": "COMMA_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "ERROR_CONSTRUCTOR", - "children": [ - { - "kind": "ERROR_KEYWORD" - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "STRING_LITERAL", - "children": [ - { - "kind": "STRING_LITERAL_TOKEN", - "value": "Database Error" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - } - ] - }, - { - "kind": "COMMA_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "NAMED_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "userCode", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "NUMERIC_LITERAL", - "children": [ - { - "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", - "value": "20" - } - ] - } - ] - }, - { - "kind": "COMMA_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "NAMED_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "userReason", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "STRING_LITERAL", - "children": [ - { - "kind": "STRING_LITERAL_TOKEN", - "value": "deadlock condition" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "FAIL_STATEMENT", - "children": [ - { - "kind": "FAIL_KEYWORD", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "err" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - } - ] - }, + "kind": "STRING_KEYWORD", + "leadingMinutiae": [ { - "kind": "CLOSE_BRACE_TOKEN", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ { - "kind": "ON_FAIL_CLAUSE", - "children": [ - { - "kind": "ON_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "FAIL_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "TYPED_BINDING_PATTERN", - "children": [ - { - "kind": "VAR_TYPE_DESC", - "children": [ - { - "kind": "VAR_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "ERROR_BINDING_PATTERN", - "children": [ - { - "kind": "ERROR_KEYWORD" - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "message" - } - ] - }, - { - "kind": "COMMA_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "cause" - } - ] - }, - { - "kind": "COMMA_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "NAMED_ARG_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "userCode", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "code" - } - ] - } - ] - }, - { - "kind": "COMMA_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "NAMED_ARG_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "userReason", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "reason" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - } - ] - }, - { - "kind": "BLOCK_STATEMENT", - "children": [ - { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "children": [ - { - "kind": "CALL_STATEMENT", - "children": [ - { - "kind": "FUNCTION_CALL", - "children": [ - { - "kind": "QUALIFIED_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "message" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "CALL_STATEMENT", - "children": [ - { - "kind": "FUNCTION_CALL", - "children": [ - { - "kind": "QUALIFIED_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "cause" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "CALL_STATEMENT", - "children": [ - { - "kind": "FUNCTION_CALL", - "children": [ - { - "kind": "QUALIFIED_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "code" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "CALL_STATEMENT", - "children": [ - { - "kind": "FUNCTION_CALL", - "children": [ - { - "kind": "QUALIFIED_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "reason" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] } ] }, { - "kind": "CLOSE_BRACE_TOKEN", + "kind": "IDENTIFIER_TOKEN", + "value": "userReason" + }, + { + "kind": "SEMICOLON_TOKEN", "trailingMinutiae": [ { "kind": "END_OF_LINE_MINUTIAE", @@ -1280,11 +121,20 @@ ] } ] + }, + { + "kind": "CLOSE_BRACE_PIPE_TOKEN" } ] }, { - "kind": "EOF_TOKEN" + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] } ] } diff --git a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_28.json b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_28.json index 5e0fdb8e824c..535e3c6f8cc0 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_28.json +++ b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_28.json @@ -386,15 +386,185 @@ ] }, { - "kind": "CAPTURE_BINDING_PATTERN", + "kind": "ERROR_BINDING_PATTERN", "hasDiagnostics": true, "children": [ { - "kind": "IDENTIFIER_TOKEN", + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_OPEN_PAREN_TOKEN" + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", "isMissing": true, "hasDiagnostics": true, "diagnostics": [ - "ERROR_MISSING_IDENTIFIER" + "ERROR_MISSING_CLOSE_PAREN_TOKEN" + ], + "leadingMinutiae": [ + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_BINDING_PATTERN_NOT_ALLOWED" + ] + } + ] + } + }, + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io" + } + ] + } + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "COLON_TOKEN" + } + ] + } + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + } + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + } + ] + } + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "hasDiagnostics": true, + "children": [ + { + "kind": "SEMICOLON_TOKEN", + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_INVALID_TOKEN" + ] + } + ] + } + }, + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "CLOSE_BRACE_TOKEN" + } + ] + } + }, + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } ] } ] @@ -415,243 +585,7 @@ }, { "kind": "LIST", - "hasDiagnostics": true, - "children": [ - { - "kind": "LOCAL_VAR_DECL", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "TYPED_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "TUPLE_TYPE_DESC", - "children": [ - { - "kind": "OPEN_BRACKET_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "MEMBER_TYPE_DESC", - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "err" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_BRACKET_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "MAPPING_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "hasDiagnostics": true, - "children": [ - { - "kind": "FIELD_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "ERROR_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "ERROR_KEYWORD", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_ERROR_KEYWORD" - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "err" - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - } - ] - }, - { - "kind": "COMMA_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_COMMA_TOKEN" - ] - }, - { - "kind": "FIELD_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "hasDiagnostics": true, - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_IDENTIFIER" - ], - "leadingMinutiae": [ - { - "kind": "INVALID_NODE_MINUTIAE", - "invalidNode": { - "kind": "INVALID_TOKEN_MINUTIAE_NODE", - "hasDiagnostics": true, - "children": [ - { - "kind": "SEMICOLON_TOKEN", - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_INVALID_TOKEN" - ] - } - ] - } - }, - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_VARIABLE_DECL_HAVING_BP_MUST_BE_INITIALIZED" - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "isMissing": true - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_SEMICOLON_TOKEN" - ] - } - ] - } - ] + "children": [] }, { "kind": "CLOSE_BRACE_TOKEN", diff --git a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_29.json b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_29.json index 2dbe4e51ac6e..54ba5c3baa9d 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_29.json +++ b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_29.json @@ -1,5 +1,6 @@ { "kind": "FUNCTION_DEFINITION", + "hasDiagnostics": true, "children": [ { "kind": "LIST", @@ -55,6 +56,7 @@ }, { "kind": "FUNCTION_BODY_BLOCK", + "hasDiagnostics": true, "children": [ { "kind": "OPEN_BRACE_TOKEN", @@ -67,9 +69,11 @@ }, { "kind": "LIST", + "hasDiagnostics": true, "children": [ { "kind": "MATCH_STATEMENT", + "hasDiagnostics": true, "children": [ { "kind": "MATCH_KEYWORD", @@ -343,6 +347,7 @@ }, { "kind": "ON_FAIL_CLAUSE", + "hasDiagnostics": true, "children": [ { "kind": "ON_KEYWORD", @@ -364,6 +369,7 @@ }, { "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, "children": [ { "kind": "VAR_TYPE_DESC", @@ -381,6 +387,7 @@ }, { "kind": "ERROR_BINDING_PATTERN", + "hasDiagnostics": true, "children": [ { "kind": "ERROR_KEYWORD" @@ -392,35 +399,17 @@ "kind": "LIST", "children": [ { - "kind": "NAMED_ARG_BINDING_PATTERN", + "kind": "CAPTURE_BINDING_PATTERN", "children": [ { "kind": "IDENTIFIER_TOKEN", - "value": "message", + "value": "m", "trailingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", "value": " " } ] - }, - { - "kind": "EQUAL_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "m" - } - ] } ] } @@ -428,11 +417,10 @@ }, { "kind": "CLOSE_PAREN_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_CLOSE_PAREN_TOKEN" ] } ] diff --git a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_30.json b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_30.json index ebc40268787b..1553515291bb 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_30.json +++ b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_30.json @@ -380,15 +380,41 @@ ] }, { - "kind": "CAPTURE_BINDING_PATTERN", + "kind": "ERROR_BINDING_PATTERN", "hasDiagnostics": true, "children": [ { - "kind": "IDENTIFIER_TOKEN", + "kind": "ERROR_KEYWORD", "isMissing": true, "hasDiagnostics": true, "diagnostics": [ - "ERROR_MISSING_IDENTIFIER" + "ERROR_MISSING_ERROR_KEYWORD" + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } ] } ] @@ -397,170 +423,71 @@ }, { "kind": "BLOCK_STATEMENT", - "hasDiagnostics": true, "children": [ { "kind": "OPEN_BRACE_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_OPEN_BRACE_TOKEN" + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } ] }, { "kind": "LIST", - "hasDiagnostics": true, "children": [ { - "kind": "LOCAL_VAR_DECL", - "hasDiagnostics": true, + "kind": "CALL_STATEMENT", "children": [ { - "kind": "LIST", - "children": [] - }, - { - "kind": "TYPED_BINDING_PATTERN", - "hasDiagnostics": true, + "kind": "FUNCTION_CALL", "children": [ { - "kind": "PARENTHESISED_TYPE_DESC", + "kind": "QUALIFIED_NAME_REFERENCE", "children": [ { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ { - "kind": "IDENTIFIER_TOKEN", - "value": "m" + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] }, { - "kind": "CLOSE_PAREN_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" } ] }, { - "kind": "MAPPING_BINDING_PATTERN", - "hasDiagnostics": true, + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", "children": [ { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "hasDiagnostics": true, + "kind": "POSITIONAL_ARG", "children": [ { - "kind": "FIELD_BINDING_PATTERN", - "hasDiagnostics": true, + "kind": "SIMPLE_NAME_REFERENCE", "children": [ { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "ERROR_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "ERROR_KEYWORD", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_ERROR_KEYWORD" - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "m" - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] + "kind": "IDENTIFIER_TOKEN", + "value": "m" } ] } ] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_CLOSE_BRACE_TOKEN" - ] } ] - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_VARIABLE_DECL_HAVING_BP_MUST_BE_INITIALIZED" - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ + }, { - "kind": "IDENTIFIER_TOKEN", - "isMissing": true + "kind": "CLOSE_PAREN_TOKEN" } ] }, diff --git a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_31.json b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_31.json index 04dc79ac829b..d6225a5620e9 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_31.json +++ b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_31.json @@ -386,15 +386,41 @@ ] }, { - "kind": "CAPTURE_BINDING_PATTERN", + "kind": "ERROR_BINDING_PATTERN", "hasDiagnostics": true, "children": [ { - "kind": "IDENTIFIER_TOKEN", + "kind": "ERROR_KEYWORD", "isMissing": true, "hasDiagnostics": true, "diagnostics": [ - "ERROR_MISSING_IDENTIFIER" + "ERROR_MISSING_ERROR_KEYWORD" + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } ] } ] @@ -403,170 +429,71 @@ }, { "kind": "BLOCK_STATEMENT", - "hasDiagnostics": true, "children": [ { "kind": "OPEN_BRACE_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_OPEN_BRACE_TOKEN" + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } ] }, { "kind": "LIST", - "hasDiagnostics": true, "children": [ { - "kind": "LOCAL_VAR_DECL", - "hasDiagnostics": true, + "kind": "CALL_STATEMENT", "children": [ { - "kind": "LIST", - "children": [] - }, - { - "kind": "TYPED_BINDING_PATTERN", - "hasDiagnostics": true, + "kind": "FUNCTION_CALL", "children": [ { - "kind": "PARENTHESISED_TYPE_DESC", + "kind": "QUALIFIED_NAME_REFERENCE", "children": [ { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ { - "kind": "IDENTIFIER_TOKEN", - "value": "m" + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] }, { - "kind": "CLOSE_PAREN_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" } ] }, { - "kind": "MAPPING_BINDING_PATTERN", - "hasDiagnostics": true, + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", "children": [ { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "hasDiagnostics": true, + "kind": "POSITIONAL_ARG", "children": [ { - "kind": "FIELD_BINDING_PATTERN", - "hasDiagnostics": true, + "kind": "SIMPLE_NAME_REFERENCE", "children": [ { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "ERROR_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "ERROR_KEYWORD", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_ERROR_KEYWORD" - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "m" - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] + "kind": "IDENTIFIER_TOKEN", + "value": "m" } ] } ] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_CLOSE_BRACE_TOKEN" - ] } ] - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_VARIABLE_DECL_HAVING_BP_MUST_BE_INITIALIZED" - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ + }, { - "kind": "IDENTIFIER_TOKEN", - "isMissing": true + "kind": "CLOSE_PAREN_TOKEN" } ] }, diff --git a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_28.bal b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_28.bal index d67694e1c690..4efd220c760c 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_28.bal +++ b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_28.bal @@ -5,7 +5,7 @@ public function test() { "east" => { fail error("error!"); } - } on fail error [err] { + } on fail error error err { io:println(err); } } diff --git a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_29.bal b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_29.bal index 0d31cc7268ce..43242119bec8 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_29.bal +++ b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_29.bal @@ -5,7 +5,7 @@ public function test() { "east" => { fail error("error!"); } - } on fail var error(message = m) { + } on fail var error(m { io:println(m); } } diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_05.json b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_05.json index f61fb51c06d9..f590ed276ba0 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_05.json +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_05.json @@ -135,26 +135,36 @@ ] }, { - "kind": "ERROR_TYPE_DESC", + "kind": "TYPED_BINDING_PATTERN", "children": [ { - "kind": "ERROR_KEYWORD", - "trailingMinutiae": [ + "kind": "ERROR_TYPE_DESC", + "children": [ { - "kind": "WHITESPACE_MINUTIAE", - "value": " " + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] } ] - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "e", - "trailingMinutiae": [ + }, { - "kind": "WHITESPACE_MINUTIAE", - "value": " " + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "e", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] } ] }, diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_06.json b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_06.json index e6a856a9ecb9..da99d8569ffb 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_06.json +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_06.json @@ -160,50 +160,62 @@ ] }, { - "kind": "SIMPLE_NAME_REFERENCE", + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, "children": [ { - "kind": "IDENTIFIER_TOKEN", - "value": "extra", - "trailingMinutiae": [ + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ { - "kind": "WHITESPACE_MINUTIAE", - "value": " " + "kind": "IDENTIFIER_TOKEN", + "value": "extra", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] } ] - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "hasDiagnostics": true, - "value": "e", - "leadingMinutiae": [ - { - "kind": "INVALID_NODE_MINUTIAE", - "invalidNode": { - "kind": "INVALID_TOKEN_MINUTIAE_NODE", - "hasDiagnostics": true, - "children": [ - { - "kind": "TYPEDESC_KEYWORD", - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_INVALID_TOKEN" - ] - } - ] - } }, { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " + "kind": "CAPTURE_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "hasDiagnostics": true, + "value": "e", + "leadingMinutiae": [ + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "hasDiagnostics": true, + "children": [ + { + "kind": "TYPEDESC_KEYWORD", + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_INVALID_TOKEN" + ] + } + ] + } + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] } ] }, diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_12.json b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_12.json index 4f3a71411ddf..f1f7427d7ca1 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_12.json +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_12.json @@ -168,15 +168,185 @@ ] }, { - "kind": "CAPTURE_BINDING_PATTERN", + "kind": "ERROR_BINDING_PATTERN", "hasDiagnostics": true, "children": [ { - "kind": "IDENTIFIER_TOKEN", + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN", "isMissing": true, "hasDiagnostics": true, "diagnostics": [ - "ERROR_MISSING_IDENTIFIER" + "ERROR_MISSING_OPEN_PAREN_TOKEN" + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_CLOSE_PAREN_TOKEN" + ], + "leadingMinutiae": [ + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_BINDING_PATTERN_NOT_ALLOWED" + ] + } + ] + } + }, + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io" + } + ] + } + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "COLON_TOKEN" + } + ] + } + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + } + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + } + ] + } + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "hasDiagnostics": true, + "children": [ + { + "kind": "SEMICOLON_TOKEN", + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_INVALID_TOKEN" + ] + } + ] + } + }, + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "CLOSE_BRACE_TOKEN" + } + ] + } + }, + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } ] } ] @@ -197,243 +367,7 @@ }, { "kind": "LIST", - "hasDiagnostics": true, - "children": [ - { - "kind": "LOCAL_VAR_DECL", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "TYPED_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "TUPLE_TYPE_DESC", - "children": [ - { - "kind": "OPEN_BRACKET_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "MEMBER_TYPE_DESC", - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "err" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_BRACKET_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "MAPPING_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "hasDiagnostics": true, - "children": [ - { - "kind": "FIELD_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "ERROR_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "ERROR_KEYWORD", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_ERROR_KEYWORD" - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "err" - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - } - ] - }, - { - "kind": "COMMA_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_COMMA_TOKEN" - ] - }, - { - "kind": "FIELD_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "hasDiagnostics": true, - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_IDENTIFIER" - ], - "leadingMinutiae": [ - { - "kind": "INVALID_NODE_MINUTIAE", - "invalidNode": { - "kind": "INVALID_TOKEN_MINUTIAE_NODE", - "hasDiagnostics": true, - "children": [ - { - "kind": "SEMICOLON_TOKEN", - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_INVALID_TOKEN" - ] - } - ] - } - }, - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_VARIABLE_DECL_HAVING_BP_MUST_BE_INITIALIZED" - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "isMissing": true - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_SEMICOLON_TOKEN" - ] - } - ] - } - ] + "children": [] }, { "kind": "CLOSE_BRACE_TOKEN", diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_13.json b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_13.json index 839b8791b6a7..14ef0a235343 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_13.json +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_13.json @@ -1,5 +1,6 @@ { "kind": "FUNCTION_DEFINITION", + "hasDiagnostics": true, "children": [ { "kind": "LIST", @@ -55,6 +56,7 @@ }, { "kind": "FUNCTION_BODY_BLOCK", + "hasDiagnostics": true, "children": [ { "kind": "OPEN_BRACE_TOKEN", @@ -67,9 +69,11 @@ }, { "kind": "LIST", + "hasDiagnostics": true, "children": [ { "kind": "RETRY_STATEMENT", + "hasDiagnostics": true, "children": [ { "kind": "RETRY_KEYWORD", @@ -125,6 +129,7 @@ }, { "kind": "ON_FAIL_CLAUSE", + "hasDiagnostics": true, "children": [ { "kind": "ON_KEYWORD", @@ -146,6 +151,7 @@ }, { "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, "children": [ { "kind": "VAR_TYPE_DESC", @@ -163,6 +169,7 @@ }, { "kind": "ERROR_BINDING_PATTERN", + "hasDiagnostics": true, "children": [ { "kind": "ERROR_KEYWORD" @@ -174,35 +181,17 @@ "kind": "LIST", "children": [ { - "kind": "NAMED_ARG_BINDING_PATTERN", + "kind": "CAPTURE_BINDING_PATTERN", "children": [ { "kind": "IDENTIFIER_TOKEN", - "value": "message", + "value": "m", "trailingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", "value": " " } ] - }, - { - "kind": "EQUAL_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "m" - } - ] } ] } @@ -210,11 +199,10 @@ }, { "kind": "CLOSE_PAREN_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_CLOSE_PAREN_TOKEN" ] } ] diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_14.json b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_14.json index ab732d14a47a..711814eadb27 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_14.json +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_14.json @@ -162,15 +162,41 @@ ] }, { - "kind": "CAPTURE_BINDING_PATTERN", + "kind": "ERROR_BINDING_PATTERN", "hasDiagnostics": true, "children": [ { - "kind": "IDENTIFIER_TOKEN", + "kind": "ERROR_KEYWORD", "isMissing": true, "hasDiagnostics": true, "diagnostics": [ - "ERROR_MISSING_IDENTIFIER" + "ERROR_MISSING_ERROR_KEYWORD" + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } ] } ] @@ -179,170 +205,71 @@ }, { "kind": "BLOCK_STATEMENT", - "hasDiagnostics": true, "children": [ { "kind": "OPEN_BRACE_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_OPEN_BRACE_TOKEN" + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } ] }, { "kind": "LIST", - "hasDiagnostics": true, "children": [ { - "kind": "LOCAL_VAR_DECL", - "hasDiagnostics": true, + "kind": "CALL_STATEMENT", "children": [ { - "kind": "LIST", - "children": [] - }, - { - "kind": "TYPED_BINDING_PATTERN", - "hasDiagnostics": true, + "kind": "FUNCTION_CALL", "children": [ { - "kind": "PARENTHESISED_TYPE_DESC", + "kind": "QUALIFIED_NAME_REFERENCE", "children": [ { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ { - "kind": "IDENTIFIER_TOKEN", - "value": "m" + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] }, { - "kind": "CLOSE_PAREN_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" } ] }, { - "kind": "MAPPING_BINDING_PATTERN", - "hasDiagnostics": true, + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", "children": [ { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "hasDiagnostics": true, + "kind": "POSITIONAL_ARG", "children": [ { - "kind": "FIELD_BINDING_PATTERN", - "hasDiagnostics": true, + "kind": "SIMPLE_NAME_REFERENCE", "children": [ { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "ERROR_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "ERROR_KEYWORD", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_ERROR_KEYWORD" - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "m" - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] + "kind": "IDENTIFIER_TOKEN", + "value": "m" } ] } ] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_CLOSE_BRACE_TOKEN" - ] } ] - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_VARIABLE_DECL_HAVING_BP_MUST_BE_INITIALIZED" - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ + }, { - "kind": "IDENTIFIER_TOKEN", - "isMissing": true + "kind": "CLOSE_PAREN_TOKEN" } ] }, diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_15.json b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_15.json index 28300f5b59af..d07169f276d4 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_15.json +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_15.json @@ -168,15 +168,41 @@ ] }, { - "kind": "CAPTURE_BINDING_PATTERN", + "kind": "ERROR_BINDING_PATTERN", "hasDiagnostics": true, "children": [ { - "kind": "IDENTIFIER_TOKEN", + "kind": "ERROR_KEYWORD", "isMissing": true, "hasDiagnostics": true, "diagnostics": [ - "ERROR_MISSING_IDENTIFIER" + "ERROR_MISSING_ERROR_KEYWORD" + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } ] } ] @@ -185,170 +211,71 @@ }, { "kind": "BLOCK_STATEMENT", - "hasDiagnostics": true, "children": [ { "kind": "OPEN_BRACE_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_OPEN_BRACE_TOKEN" + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } ] }, { "kind": "LIST", - "hasDiagnostics": true, "children": [ { - "kind": "LOCAL_VAR_DECL", - "hasDiagnostics": true, + "kind": "CALL_STATEMENT", "children": [ { - "kind": "LIST", - "children": [] - }, - { - "kind": "TYPED_BINDING_PATTERN", - "hasDiagnostics": true, + "kind": "FUNCTION_CALL", "children": [ { - "kind": "PARENTHESISED_TYPE_DESC", + "kind": "QUALIFIED_NAME_REFERENCE", "children": [ { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ { - "kind": "IDENTIFIER_TOKEN", - "value": "m" + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] }, { - "kind": "CLOSE_PAREN_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" } ] }, { - "kind": "MAPPING_BINDING_PATTERN", - "hasDiagnostics": true, + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", "children": [ { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "hasDiagnostics": true, + "kind": "POSITIONAL_ARG", "children": [ { - "kind": "FIELD_BINDING_PATTERN", - "hasDiagnostics": true, + "kind": "SIMPLE_NAME_REFERENCE", "children": [ { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "ERROR_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "ERROR_KEYWORD", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_ERROR_KEYWORD" - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "m" - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] + "kind": "IDENTIFIER_TOKEN", + "value": "m" } ] } ] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_CLOSE_BRACE_TOKEN" - ] } ] - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_VARIABLE_DECL_HAVING_BP_MUST_BE_INITIALIZED" - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ + }, { - "kind": "IDENTIFIER_TOKEN", - "isMissing": true + "kind": "CLOSE_PAREN_TOKEN" } ] }, diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_12.bal b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_12.bal index 6776d372bb64..bf54fb15d440 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_12.bal +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_12.bal @@ -1,7 +1,7 @@ public function test() { retry { - } on fail error [err] { + } on fail error error err { io:println(err); } } diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_13.bal b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_13.bal index 76cf2062480c..8dec1c25f2a6 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_13.bal +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_13.bal @@ -1,7 +1,7 @@ public function test() { retry { - } on fail var error(message = m) { + } on fail var error(m { io:println(m); } } diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_03.json b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_03.json index 82bba96a4358..6110b5be8583 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_03.json +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_03.json @@ -131,26 +131,36 @@ ] }, { - "kind": "ERROR_TYPE_DESC", + "kind": "TYPED_BINDING_PATTERN", "children": [ { - "kind": "ERROR_KEYWORD", - "trailingMinutiae": [ + "kind": "ERROR_TYPE_DESC", + "children": [ { - "kind": "WHITESPACE_MINUTIAE", - "value": " " + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] } ] - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "e", - "trailingMinutiae": [ + }, { - "kind": "WHITESPACE_MINUTIAE", - "value": " " + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "e", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] } ] }, @@ -412,26 +422,36 @@ ] }, { - "kind": "ERROR_TYPE_DESC", + "kind": "TYPED_BINDING_PATTERN", "children": [ { - "kind": "ERROR_KEYWORD", - "trailingMinutiae": [ + "kind": "ERROR_TYPE_DESC", + "children": [ { - "kind": "WHITESPACE_MINUTIAE", - "value": " " + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] } ] - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "e", - "trailingMinutiae": [ + }, { - "kind": "WHITESPACE_MINUTIAE", - "value": " " + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "e", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] } ] }, @@ -777,26 +797,36 @@ ] }, { - "kind": "ERROR_TYPE_DESC", + "kind": "TYPED_BINDING_PATTERN", "children": [ { - "kind": "ERROR_KEYWORD", - "trailingMinutiae": [ + "kind": "ERROR_TYPE_DESC", + "children": [ { - "kind": "WHITESPACE_MINUTIAE", - "value": " " + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] } ] - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "e", - "trailingMinutiae": [ + }, { - "kind": "WHITESPACE_MINUTIAE", - "value": " " + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "e", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] } ] }, @@ -1100,26 +1130,36 @@ ] }, { - "kind": "ERROR_TYPE_DESC", + "kind": "TYPED_BINDING_PATTERN", "children": [ { - "kind": "ERROR_KEYWORD", - "trailingMinutiae": [ + "kind": "ERROR_TYPE_DESC", + "children": [ { - "kind": "WHITESPACE_MINUTIAE", - "value": " " + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] } ] - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "e", - "trailingMinutiae": [ + }, { - "kind": "WHITESPACE_MINUTIAE", - "value": " " + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "e", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] } ] }, @@ -1289,26 +1329,36 @@ ] }, { - "kind": "ERROR_TYPE_DESC", + "kind": "TYPED_BINDING_PATTERN", "children": [ { - "kind": "ERROR_KEYWORD", - "trailingMinutiae": [ + "kind": "ERROR_TYPE_DESC", + "children": [ { - "kind": "WHITESPACE_MINUTIAE", - "value": " " + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] } ] - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "e", - "trailingMinutiae": [ + }, { - "kind": "WHITESPACE_MINUTIAE", - "value": " " + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "e", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] } ] }, diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_04.json b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_04.json index d62a35af42c5..b710521c1ebf 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_04.json +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_04.json @@ -156,50 +156,62 @@ ] }, { - "kind": "SIMPLE_NAME_REFERENCE", + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, "children": [ { - "kind": "IDENTIFIER_TOKEN", - "value": "extra", - "trailingMinutiae": [ + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ { - "kind": "WHITESPACE_MINUTIAE", - "value": " " + "kind": "IDENTIFIER_TOKEN", + "value": "extra", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] } ] - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "hasDiagnostics": true, - "value": "e", - "leadingMinutiae": [ - { - "kind": "INVALID_NODE_MINUTIAE", - "invalidNode": { - "kind": "INVALID_TOKEN_MINUTIAE_NODE", - "hasDiagnostics": true, - "children": [ - { - "kind": "TYPEDESC_KEYWORD", - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_INVALID_TOKEN" - ] - } - ] - } }, { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " + "kind": "CAPTURE_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "hasDiagnostics": true, + "value": "e", + "leadingMinutiae": [ + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "hasDiagnostics": true, + "children": [ + { + "kind": "TYPEDESC_KEYWORD", + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_INVALID_TOKEN" + ] + } + ] + } + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] } ] }, @@ -483,50 +495,62 @@ ] }, { - "kind": "SIMPLE_NAME_REFERENCE", + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, "children": [ { - "kind": "IDENTIFIER_TOKEN", - "value": "extra", - "trailingMinutiae": [ + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ { - "kind": "WHITESPACE_MINUTIAE", - "value": " " + "kind": "IDENTIFIER_TOKEN", + "value": "extra", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] } ] - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "hasDiagnostics": true, - "value": "e", - "leadingMinutiae": [ - { - "kind": "INVALID_NODE_MINUTIAE", - "invalidNode": { - "kind": "INVALID_TOKEN_MINUTIAE_NODE", - "hasDiagnostics": true, - "children": [ - { - "kind": "TYPEDESC_KEYWORD", - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_INVALID_TOKEN" - ] - } - ] - } }, { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " + "kind": "CAPTURE_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "hasDiagnostics": true, + "value": "e", + "leadingMinutiae": [ + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "hasDiagnostics": true, + "children": [ + { + "kind": "TYPEDESC_KEYWORD", + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_INVALID_TOKEN" + ] + } + ] + } + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] } ] }, @@ -883,50 +907,62 @@ ] }, { - "kind": "SIMPLE_NAME_REFERENCE", + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, "children": [ { - "kind": "IDENTIFIER_TOKEN", - "value": "extra", - "trailingMinutiae": [ + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ { - "kind": "WHITESPACE_MINUTIAE", - "value": " " + "kind": "IDENTIFIER_TOKEN", + "value": "extra", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] } ] - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "hasDiagnostics": true, - "value": "e", - "leadingMinutiae": [ - { - "kind": "INVALID_NODE_MINUTIAE", - "invalidNode": { - "kind": "INVALID_TOKEN_MINUTIAE_NODE", - "hasDiagnostics": true, - "children": [ - { - "kind": "TYPEDESC_KEYWORD", - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_INVALID_TOKEN" - ] - } - ] - } }, { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " + "kind": "CAPTURE_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "hasDiagnostics": true, + "value": "e", + "leadingMinutiae": [ + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "hasDiagnostics": true, + "children": [ + { + "kind": "TYPEDESC_KEYWORD", + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_INVALID_TOKEN" + ] + } + ] + } + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] } ] }, @@ -1258,50 +1294,62 @@ ] }, { - "kind": "SIMPLE_NAME_REFERENCE", + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, "children": [ { - "kind": "IDENTIFIER_TOKEN", - "value": "extra", - "trailingMinutiae": [ + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ { - "kind": "WHITESPACE_MINUTIAE", - "value": " " + "kind": "IDENTIFIER_TOKEN", + "value": "extra", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] } ] - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "hasDiagnostics": true, - "value": "e", - "leadingMinutiae": [ - { - "kind": "INVALID_NODE_MINUTIAE", - "invalidNode": { - "kind": "INVALID_TOKEN_MINUTIAE_NODE", - "hasDiagnostics": true, - "children": [ - { - "kind": "TYPEDESC_KEYWORD", - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_INVALID_TOKEN" - ] - } - ] - } }, { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " + "kind": "CAPTURE_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "hasDiagnostics": true, + "value": "e", + "leadingMinutiae": [ + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "hasDiagnostics": true, + "children": [ + { + "kind": "TYPEDESC_KEYWORD", + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_INVALID_TOKEN" + ] + } + ] + } + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] } ] }, @@ -1478,50 +1526,62 @@ ] }, { - "kind": "SIMPLE_NAME_REFERENCE", + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, "children": [ { - "kind": "IDENTIFIER_TOKEN", - "value": "extra", - "trailingMinutiae": [ + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ { - "kind": "WHITESPACE_MINUTIAE", - "value": " " + "kind": "IDENTIFIER_TOKEN", + "value": "extra", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] } ] - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "hasDiagnostics": true, - "value": "e", - "leadingMinutiae": [ - { - "kind": "INVALID_NODE_MINUTIAE", - "invalidNode": { - "kind": "INVALID_TOKEN_MINUTIAE_NODE", - "hasDiagnostics": true, - "children": [ - { - "kind": "TYPEDESC_KEYWORD", - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_INVALID_TOKEN" - ] - } - ] - } }, { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " + "kind": "CAPTURE_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "hasDiagnostics": true, + "value": "e", + "leadingMinutiae": [ + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "hasDiagnostics": true, + "children": [ + { + "kind": "TYPEDESC_KEYWORD", + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_INVALID_TOKEN" + ] + } + ] + } + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] } ] }, diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_09.json b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_09.json index 8c70f0e203d8..54b5fb2c10c0 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_09.json +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_09.json @@ -154,15 +154,185 @@ ] }, { - "kind": "CAPTURE_BINDING_PATTERN", + "kind": "ERROR_BINDING_PATTERN", "hasDiagnostics": true, "children": [ { - "kind": "IDENTIFIER_TOKEN", + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_OPEN_PAREN_TOKEN" + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", "isMissing": true, "hasDiagnostics": true, "diagnostics": [ - "ERROR_MISSING_IDENTIFIER" + "ERROR_MISSING_CLOSE_PAREN_TOKEN" + ], + "leadingMinutiae": [ + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_BINDING_PATTERN_NOT_ALLOWED" + ] + } + ] + } + }, + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io" + } + ] + } + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "COLON_TOKEN" + } + ] + } + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + } + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + } + ] + } + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "hasDiagnostics": true, + "children": [ + { + "kind": "SEMICOLON_TOKEN", + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_INVALID_TOKEN" + ] + } + ] + } + }, + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "CLOSE_BRACE_TOKEN" + } + ] + } + }, + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } ] } ] @@ -185,240 +355,6 @@ "kind": "LIST", "hasDiagnostics": true, "children": [ - { - "kind": "LOCAL_VAR_DECL", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "TYPED_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "TUPLE_TYPE_DESC", - "children": [ - { - "kind": "OPEN_BRACKET_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "MEMBER_TYPE_DESC", - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "err" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_BRACKET_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "MAPPING_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "hasDiagnostics": true, - "children": [ - { - "kind": "FIELD_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "ERROR_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "ERROR_KEYWORD", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_ERROR_KEYWORD" - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "err" - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - } - ] - }, - { - "kind": "COMMA_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_COMMA_TOKEN" - ] - }, - { - "kind": "FIELD_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "hasDiagnostics": true, - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_IDENTIFIER" - ], - "leadingMinutiae": [ - { - "kind": "INVALID_NODE_MINUTIAE", - "invalidNode": { - "kind": "INVALID_TOKEN_MINUTIAE_NODE", - "hasDiagnostics": true, - "children": [ - { - "kind": "SEMICOLON_TOKEN", - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_INVALID_TOKEN" - ] - } - ] - } - }, - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_VARIABLE_DECL_HAVING_BP_MUST_BE_INITIALIZED" - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "isMissing": true - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_SEMICOLON_TOKEN" - ] - } - ] - }, { "kind": "TRANSACTION_STATEMENT", "hasDiagnostics": true, @@ -593,271 +529,207 @@ ] }, { - "kind": "CAPTURE_BINDING_PATTERN", + "kind": "ERROR_BINDING_PATTERN", "hasDiagnostics": true, "children": [ { - "kind": "IDENTIFIER_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_IDENTIFIER" + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } ] - } - ] - } - ] - }, - { - "kind": "BLOCK_STATEMENT", - "hasDiagnostics": true, - "children": [ - { - "kind": "OPEN_BRACE_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_OPEN_BRACE_TOKEN" - ] - }, - { - "kind": "LIST", - "hasDiagnostics": true, - "children": [ + }, { - "kind": "LOCAL_VAR_DECL", - "hasDiagnostics": true, + "kind": "SIMPLE_NAME_REFERENCE", "children": [ { - "kind": "LIST", - "children": [] - }, - { - "kind": "TYPED_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ + "kind": "IDENTIFIER_TOKEN", + "value": "err", + "trailingMinutiae": [ { - "kind": "TUPLE_TYPE_DESC", - "children": [ - { - "kind": "OPEN_BRACKET_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "MEMBER_TYPE_DESC", - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "err" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_BRACKET_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "MAPPING_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "hasDiagnostics": true, - "children": [ - { - "kind": "FIELD_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "ERROR_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "ERROR_KEYWORD", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_ERROR_KEYWORD" - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "err" - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - } - ] - }, - { - "kind": "COMMA_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_COMMA_TOKEN" - ] - }, - { - "kind": "FIELD_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "hasDiagnostics": true, - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_IDENTIFIER" - ], - "leadingMinutiae": [ - { - "kind": "INVALID_NODE_MINUTIAE", - "invalidNode": { - "kind": "INVALID_TOKEN_MINUTIAE_NODE", - "hasDiagnostics": true, - "children": [ - { - "kind": "SEMICOLON_TOKEN", - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_INVALID_TOKEN" - ] - } - ] - } - }, - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_OPEN_PAREN_TOKEN" + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_CLOSE_PAREN_TOKEN" + ], + "leadingMinutiae": [ + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_BINDING_PATTERN_NOT_ALLOWED" + ] + } + ] + } }, { - "kind": "EQUAL_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_VARIABLE_DECL_HAVING_BP_MUST_BE_INITIALIZED" - ] + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" }, { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "isMissing": true - } - ] + "kind": "WHITESPACE_MINUTIAE", + "value": " " }, { - "kind": "SEMICOLON_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_SEMICOLON_TOKEN" - ] + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io" + } + ] + } + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "COLON_TOKEN" + } + ] + } + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + } + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + } + ] + } + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "hasDiagnostics": true, + "children": [ + { + "kind": "SEMICOLON_TOKEN", + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_INVALID_TOKEN" + ] + } + ] + } + }, + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "CLOSE_BRACE_TOKEN" + } + ] + } + }, + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" } ] - }, + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_OPEN_BRACE_TOKEN" + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ { "kind": "TRANSACTION_STATEMENT", "hasDiagnostics": true, @@ -1116,271 +988,207 @@ ] }, { - "kind": "CAPTURE_BINDING_PATTERN", + "kind": "ERROR_BINDING_PATTERN", "hasDiagnostics": true, "children": [ { - "kind": "IDENTIFIER_TOKEN", + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN", "isMissing": true, "hasDiagnostics": true, "diagnostics": [ - "ERROR_MISSING_IDENTIFIER" + "ERROR_MISSING_OPEN_PAREN_TOKEN" ] - } - ] - } - ] - }, - { - "kind": "BLOCK_STATEMENT", - "hasDiagnostics": true, - "children": [ - { - "kind": "OPEN_BRACE_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_OPEN_BRACE_TOKEN" - ] - }, - { - "kind": "LIST", - "hasDiagnostics": true, - "children": [ + }, + { + "kind": "LIST", + "children": [] + }, { - "kind": "LOCAL_VAR_DECL", + "kind": "CLOSE_PAREN_TOKEN", + "isMissing": true, "hasDiagnostics": true, - "children": [ + "diagnostics": [ + "ERROR_MISSING_CLOSE_PAREN_TOKEN" + ], + "leadingMinutiae": [ { - "kind": "LIST", - "children": [] + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_BINDING_PATTERN_NOT_ALLOWED" + ] + } + ] + } }, { - "kind": "TYPED_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "TUPLE_TYPE_DESC", - "children": [ - { - "kind": "OPEN_BRACKET_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "MEMBER_TYPE_DESC", - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "err" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_BRACKET_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "MAPPING_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "hasDiagnostics": true, - "children": [ - { - "kind": "FIELD_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "ERROR_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "ERROR_KEYWORD", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_ERROR_KEYWORD" - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "err" - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - } - ] - }, - { - "kind": "COMMA_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_COMMA_TOKEN" - ] - }, - { - "kind": "FIELD_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "hasDiagnostics": true, - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_IDENTIFIER" - ], - "leadingMinutiae": [ - { - "kind": "INVALID_NODE_MINUTIAE", - "invalidNode": { - "kind": "INVALID_TOKEN_MINUTIAE_NODE", - "hasDiagnostics": true, - "children": [ - { - "kind": "SEMICOLON_TOKEN", - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_INVALID_TOKEN" - ] - } - ] - } - }, - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" }, { - "kind": "EQUAL_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_VARIABLE_DECL_HAVING_BP_MUST_BE_INITIALIZED" - ] + "kind": "WHITESPACE_MINUTIAE", + "value": " " }, { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "isMissing": true - } - ] + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io" + } + ] + } }, { - "kind": "SEMICOLON_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_SEMICOLON_TOKEN" - ] + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "COLON_TOKEN" + } + ] + } + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + } + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + } + ] + } + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "hasDiagnostics": true, + "children": [ + { + "kind": "SEMICOLON_TOKEN", + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_INVALID_TOKEN" + ] + } + ] + } + }, + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "CLOSE_BRACE_TOKEN" + } + ] + } + }, + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" } ] - }, + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_OPEN_BRACE_TOKEN" + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ { "kind": "TRANSACTION_STATEMENT", "hasDiagnostics": true, @@ -1603,15 +1411,185 @@ ] }, { - "kind": "CAPTURE_BINDING_PATTERN", + "kind": "ERROR_BINDING_PATTERN", "hasDiagnostics": true, "children": [ { - "kind": "IDENTIFIER_TOKEN", + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN", "isMissing": true, "hasDiagnostics": true, "diagnostics": [ - "ERROR_MISSING_IDENTIFIER" + "ERROR_MISSING_OPEN_PAREN_TOKEN" + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_CLOSE_PAREN_TOKEN" + ], + "leadingMinutiae": [ + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_BINDING_PATTERN_NOT_ALLOWED" + ] + } + ] + } + }, + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io" + } + ] + } + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "COLON_TOKEN" + } + ] + } + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + } + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + } + ] + } + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "hasDiagnostics": true, + "children": [ + { + "kind": "SEMICOLON_TOKEN", + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_INVALID_TOKEN" + ] + } + ] + } + }, + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "CLOSE_BRACE_TOKEN" + } + ] + } + }, + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } ] } ] @@ -1632,243 +1610,7 @@ }, { "kind": "LIST", - "hasDiagnostics": true, - "children": [ - { - "kind": "LOCAL_VAR_DECL", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "TYPED_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "TUPLE_TYPE_DESC", - "children": [ - { - "kind": "OPEN_BRACKET_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "MEMBER_TYPE_DESC", - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "err" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_BRACKET_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "MAPPING_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "hasDiagnostics": true, - "children": [ - { - "kind": "FIELD_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "ERROR_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "ERROR_KEYWORD", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_ERROR_KEYWORD" - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "err" - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - } - ] - }, - { - "kind": "COMMA_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_COMMA_TOKEN" - ] - }, - { - "kind": "FIELD_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "hasDiagnostics": true, - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_IDENTIFIER" - ], - "leadingMinutiae": [ - { - "kind": "INVALID_NODE_MINUTIAE", - "invalidNode": { - "kind": "INVALID_TOKEN_MINUTIAE_NODE", - "hasDiagnostics": true, - "children": [ - { - "kind": "SEMICOLON_TOKEN", - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_INVALID_TOKEN" - ] - } - ] - } - }, - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_VARIABLE_DECL_HAVING_BP_MUST_BE_INITIALIZED" - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "isMissing": true - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_SEMICOLON_TOKEN" - ] - } - ] - } - ] + "children": [] }, { "kind": "CLOSE_BRACE_TOKEN", @@ -1951,15 +1693,185 @@ ] }, { - "kind": "CAPTURE_BINDING_PATTERN", + "kind": "ERROR_BINDING_PATTERN", "hasDiagnostics": true, "children": [ { - "kind": "IDENTIFIER_TOKEN", + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN", "isMissing": true, "hasDiagnostics": true, "diagnostics": [ - "ERROR_MISSING_IDENTIFIER" + "ERROR_MISSING_OPEN_PAREN_TOKEN" + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_CLOSE_PAREN_TOKEN" + ], + "leadingMinutiae": [ + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_BINDING_PATTERN_NOT_ALLOWED" + ] + } + ] + } + }, + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io" + } + ] + } + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "COLON_TOKEN" + } + ] + } + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + } + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + } + ] + } + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "hasDiagnostics": true, + "children": [ + { + "kind": "SEMICOLON_TOKEN", + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_INVALID_TOKEN" + ] + } + ] + } + }, + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "CLOSE_BRACE_TOKEN" + } + ] + } + }, + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } ] } ] @@ -1980,243 +1892,7 @@ }, { "kind": "LIST", - "hasDiagnostics": true, - "children": [ - { - "kind": "LOCAL_VAR_DECL", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "TYPED_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "TUPLE_TYPE_DESC", - "children": [ - { - "kind": "OPEN_BRACKET_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "MEMBER_TYPE_DESC", - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "err" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_BRACKET_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "MAPPING_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "hasDiagnostics": true, - "children": [ - { - "kind": "FIELD_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "ERROR_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "ERROR_KEYWORD", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_ERROR_KEYWORD" - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "err" - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - } - ] - }, - { - "kind": "COMMA_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_COMMA_TOKEN" - ] - }, - { - "kind": "FIELD_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "hasDiagnostics": true, - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_IDENTIFIER" - ], - "leadingMinutiae": [ - { - "kind": "INVALID_NODE_MINUTIAE", - "invalidNode": { - "kind": "INVALID_TOKEN_MINUTIAE_NODE", - "hasDiagnostics": true, - "children": [ - { - "kind": "SEMICOLON_TOKEN", - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_INVALID_TOKEN" - ] - } - ] - } - }, - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_VARIABLE_DECL_HAVING_BP_MUST_BE_INITIALIZED" - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "isMissing": true - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_SEMICOLON_TOKEN" - ] - } - ] - } - ] + "children": [] }, { "kind": "CLOSE_BRACE_TOKEN", diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_10.json b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_10.json index 27bf8f0441bb..cdd5d322b1fc 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_10.json +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_10.json @@ -1,5 +1,6 @@ { "kind": "FUNCTION_DEFINITION", + "hasDiagnostics": true, "children": [ { "kind": "LIST", @@ -45,6 +46,7 @@ }, { "kind": "FUNCTION_BODY_BLOCK", + "hasDiagnostics": true, "children": [ { "kind": "OPEN_BRACE_TOKEN", @@ -57,9 +59,11 @@ }, { "kind": "LIST", + "hasDiagnostics": true, "children": [ { "kind": "TRANSACTION_STATEMENT", + "hasDiagnostics": true, "children": [ { "kind": "TRANSACTION_KEYWORD", @@ -111,6 +115,7 @@ }, { "kind": "ON_FAIL_CLAUSE", + "hasDiagnostics": true, "children": [ { "kind": "ON_KEYWORD", @@ -132,6 +137,7 @@ }, { "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, "children": [ { "kind": "VAR_TYPE_DESC", @@ -149,6 +155,7 @@ }, { "kind": "ERROR_BINDING_PATTERN", + "hasDiagnostics": true, "children": [ { "kind": "ERROR_KEYWORD" @@ -160,35 +167,17 @@ "kind": "LIST", "children": [ { - "kind": "NAMED_ARG_BINDING_PATTERN", + "kind": "CAPTURE_BINDING_PATTERN", "children": [ { "kind": "IDENTIFIER_TOKEN", - "value": "message", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "EQUAL_TOKEN", + "value": "m", "trailingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", "value": " " } ] - }, - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "m" - } - ] } ] } @@ -196,11 +185,10 @@ }, { "kind": "CLOSE_PAREN_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_CLOSE_PAREN_TOKEN" ] } ] @@ -313,6 +301,7 @@ }, { "kind": "TRANSACTION_STATEMENT", + "hasDiagnostics": true, "children": [ { "kind": "TRANSACTION_KEYWORD", @@ -445,6 +434,7 @@ }, { "kind": "ON_FAIL_CLAUSE", + "hasDiagnostics": true, "children": [ { "kind": "ON_KEYWORD", @@ -466,6 +456,7 @@ }, { "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, "children": [ { "kind": "VAR_TYPE_DESC", @@ -483,6 +474,7 @@ }, { "kind": "ERROR_BINDING_PATTERN", + "hasDiagnostics": true, "children": [ { "kind": "ERROR_KEYWORD" @@ -494,35 +486,17 @@ "kind": "LIST", "children": [ { - "kind": "NAMED_ARG_BINDING_PATTERN", + "kind": "CAPTURE_BINDING_PATTERN", "children": [ { "kind": "IDENTIFIER_TOKEN", - "value": "message", + "value": "m", "trailingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", "value": " " } ] - }, - { - "kind": "EQUAL_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "m" - } - ] } ] } @@ -530,11 +504,10 @@ }, { "kind": "CLOSE_PAREN_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_CLOSE_PAREN_TOKEN" ] } ] @@ -647,6 +620,7 @@ }, { "kind": "TRANSACTION_STATEMENT", + "hasDiagnostics": true, "children": [ { "kind": "TRANSACTION_KEYWORD", @@ -863,6 +837,7 @@ }, { "kind": "ON_FAIL_CLAUSE", + "hasDiagnostics": true, "children": [ { "kind": "ON_KEYWORD", @@ -884,6 +859,7 @@ }, { "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, "children": [ { "kind": "VAR_TYPE_DESC", @@ -901,6 +877,7 @@ }, { "kind": "ERROR_BINDING_PATTERN", + "hasDiagnostics": true, "children": [ { "kind": "ERROR_KEYWORD" @@ -912,35 +889,17 @@ "kind": "LIST", "children": [ { - "kind": "NAMED_ARG_BINDING_PATTERN", + "kind": "CAPTURE_BINDING_PATTERN", "children": [ { "kind": "IDENTIFIER_TOKEN", - "value": "message", + "value": "m", "trailingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", "value": " " } ] - }, - { - "kind": "EQUAL_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "m" - } - ] } ] } @@ -948,11 +907,10 @@ }, { "kind": "CLOSE_PAREN_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_CLOSE_PAREN_TOKEN" ] } ] @@ -1065,6 +1023,7 @@ }, { "kind": "TRANSACTION_STATEMENT", + "hasDiagnostics": true, "children": [ { "kind": "TRANSACTION_KEYWORD", @@ -1087,6 +1046,7 @@ }, { "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, "children": [ { "kind": "OPEN_BRACE_TOKEN", @@ -1099,9 +1059,11 @@ }, { "kind": "LIST", + "hasDiagnostics": true, "children": [ { "kind": "TRANSACTION_STATEMENT", + "hasDiagnostics": true, "children": [ { "kind": "TRANSACTION_KEYWORD", @@ -1120,6 +1082,7 @@ }, { "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, "children": [ { "kind": "OPEN_BRACE_TOKEN", @@ -1132,9 +1095,11 @@ }, { "kind": "LIST", + "hasDiagnostics": true, "children": [ { "kind": "TRANSACTION_STATEMENT", + "hasDiagnostics": true, "children": [ { "kind": "TRANSACTION_KEYWORD", @@ -1239,6 +1204,7 @@ }, { "kind": "ON_FAIL_CLAUSE", + "hasDiagnostics": true, "children": [ { "kind": "ON_KEYWORD", @@ -1260,6 +1226,7 @@ }, { "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, "children": [ { "kind": "VAR_TYPE_DESC", @@ -1277,6 +1244,7 @@ }, { "kind": "ERROR_BINDING_PATTERN", + "hasDiagnostics": true, "children": [ { "kind": "ERROR_KEYWORD" @@ -1288,35 +1256,17 @@ "kind": "LIST", "children": [ { - "kind": "NAMED_ARG_BINDING_PATTERN", + "kind": "CAPTURE_BINDING_PATTERN", "children": [ { "kind": "IDENTIFIER_TOKEN", - "value": "message", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "EQUAL_TOKEN", + "value": "m", "trailingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", "value": " " } ] - }, - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "m" - } - ] } ] } @@ -1324,11 +1274,10 @@ }, { "kind": "CLOSE_PAREN_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_CLOSE_PAREN_TOKEN" ] } ] @@ -1481,6 +1430,7 @@ }, { "kind": "ON_FAIL_CLAUSE", + "hasDiagnostics": true, "children": [ { "kind": "ON_KEYWORD", @@ -1502,6 +1452,7 @@ }, { "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, "children": [ { "kind": "VAR_TYPE_DESC", @@ -1519,6 +1470,7 @@ }, { "kind": "ERROR_BINDING_PATTERN", + "hasDiagnostics": true, "children": [ { "kind": "ERROR_KEYWORD" @@ -1530,35 +1482,17 @@ "kind": "LIST", "children": [ { - "kind": "NAMED_ARG_BINDING_PATTERN", + "kind": "CAPTURE_BINDING_PATTERN", "children": [ { "kind": "IDENTIFIER_TOKEN", - "value": "message", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "EQUAL_TOKEN", + "value": "m", "trailingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", "value": " " } ] - }, - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "m" - } - ] } ] } @@ -1566,11 +1500,10 @@ }, { "kind": "CLOSE_PAREN_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_CLOSE_PAREN_TOKEN" ] } ] diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_11.json b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_11.json index d41c2b9bffec..e4bf323b969e 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_11.json +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_11.json @@ -148,15 +148,41 @@ ] }, { - "kind": "CAPTURE_BINDING_PATTERN", + "kind": "ERROR_BINDING_PATTERN", "hasDiagnostics": true, "children": [ { - "kind": "IDENTIFIER_TOKEN", + "kind": "ERROR_KEYWORD", "isMissing": true, "hasDiagnostics": true, "diagnostics": [ - "ERROR_MISSING_IDENTIFIER" + "ERROR_MISSING_ERROR_KEYWORD" + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } ] } ] @@ -165,170 +191,71 @@ }, { "kind": "BLOCK_STATEMENT", - "hasDiagnostics": true, "children": [ { "kind": "OPEN_BRACE_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_OPEN_BRACE_TOKEN" + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } ] }, { "kind": "LIST", - "hasDiagnostics": true, "children": [ { - "kind": "LOCAL_VAR_DECL", - "hasDiagnostics": true, + "kind": "CALL_STATEMENT", "children": [ { - "kind": "LIST", - "children": [] - }, - { - "kind": "TYPED_BINDING_PATTERN", - "hasDiagnostics": true, + "kind": "FUNCTION_CALL", "children": [ { - "kind": "PARENTHESISED_TYPE_DESC", + "kind": "QUALIFIED_NAME_REFERENCE", "children": [ { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ { - "kind": "IDENTIFIER_TOKEN", - "value": "m" + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] }, { - "kind": "CLOSE_PAREN_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" } ] }, { - "kind": "MAPPING_BINDING_PATTERN", - "hasDiagnostics": true, + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", "children": [ { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "hasDiagnostics": true, + "kind": "POSITIONAL_ARG", "children": [ { - "kind": "FIELD_BINDING_PATTERN", - "hasDiagnostics": true, + "kind": "SIMPLE_NAME_REFERENCE", "children": [ { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "ERROR_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "ERROR_KEYWORD", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_ERROR_KEYWORD" - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "m" - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] + "kind": "IDENTIFIER_TOKEN", + "value": "m" } ] } ] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_CLOSE_BRACE_TOKEN" - ] } ] - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_VARIABLE_DECL_HAVING_BP_MUST_BE_INITIALIZED" - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ + }, { - "kind": "IDENTIFIER_TOKEN", - "isMissing": true + "kind": "CLOSE_PAREN_TOKEN" } ] }, @@ -534,15 +461,41 @@ ] }, { - "kind": "CAPTURE_BINDING_PATTERN", + "kind": "ERROR_BINDING_PATTERN", "hasDiagnostics": true, "children": [ { - "kind": "IDENTIFIER_TOKEN", + "kind": "ERROR_KEYWORD", "isMissing": true, "hasDiagnostics": true, "diagnostics": [ - "ERROR_MISSING_IDENTIFIER" + "ERROR_MISSING_ERROR_KEYWORD" + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } ] } ] @@ -551,170 +504,71 @@ }, { "kind": "BLOCK_STATEMENT", - "hasDiagnostics": true, "children": [ { "kind": "OPEN_BRACE_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_OPEN_BRACE_TOKEN" + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } ] }, { "kind": "LIST", - "hasDiagnostics": true, "children": [ { - "kind": "LOCAL_VAR_DECL", - "hasDiagnostics": true, + "kind": "CALL_STATEMENT", "children": [ { - "kind": "LIST", - "children": [] - }, - { - "kind": "TYPED_BINDING_PATTERN", - "hasDiagnostics": true, + "kind": "FUNCTION_CALL", "children": [ { - "kind": "PARENTHESISED_TYPE_DESC", + "kind": "QUALIFIED_NAME_REFERENCE", "children": [ { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ { - "kind": "IDENTIFIER_TOKEN", - "value": "m" + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] }, { - "kind": "CLOSE_PAREN_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" } ] }, { - "kind": "MAPPING_BINDING_PATTERN", - "hasDiagnostics": true, + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", "children": [ { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "hasDiagnostics": true, + "kind": "POSITIONAL_ARG", "children": [ { - "kind": "FIELD_BINDING_PATTERN", - "hasDiagnostics": true, + "kind": "SIMPLE_NAME_REFERENCE", "children": [ { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "ERROR_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "ERROR_KEYWORD", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_ERROR_KEYWORD" - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "m" - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] + "kind": "IDENTIFIER_TOKEN", + "value": "m" } ] } ] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_CLOSE_BRACE_TOKEN" - ] } ] - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_VARIABLE_DECL_HAVING_BP_MUST_BE_INITIALIZED" - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ + }, { - "kind": "IDENTIFIER_TOKEN", - "isMissing": true + "kind": "CLOSE_PAREN_TOKEN" } ] }, @@ -1004,187 +858,114 @@ ] }, { - "kind": "CAPTURE_BINDING_PATTERN", + "kind": "ERROR_BINDING_PATTERN", "hasDiagnostics": true, "children": [ { - "kind": "IDENTIFIER_TOKEN", + "kind": "ERROR_KEYWORD", "isMissing": true, "hasDiagnostics": true, "diagnostics": [ - "ERROR_MISSING_IDENTIFIER" + "ERROR_MISSING_ERROR_KEYWORD" ] - } - ] - } - ] - }, - { - "kind": "BLOCK_STATEMENT", - "hasDiagnostics": true, + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", "children": [ { "kind": "OPEN_BRACE_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_OPEN_BRACE_TOKEN" + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } ] }, { "kind": "LIST", - "hasDiagnostics": true, "children": [ { - "kind": "LOCAL_VAR_DECL", - "hasDiagnostics": true, + "kind": "CALL_STATEMENT", "children": [ { - "kind": "LIST", - "children": [] - }, - { - "kind": "TYPED_BINDING_PATTERN", - "hasDiagnostics": true, + "kind": "FUNCTION_CALL", "children": [ { - "kind": "PARENTHESISED_TYPE_DESC", + "kind": "QUALIFIED_NAME_REFERENCE", "children": [ { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ { - "kind": "IDENTIFIER_TOKEN", - "value": "m" + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] }, { - "kind": "CLOSE_PAREN_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" } ] }, { - "kind": "MAPPING_BINDING_PATTERN", - "hasDiagnostics": true, + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", "children": [ { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "hasDiagnostics": true, + "kind": "POSITIONAL_ARG", "children": [ { - "kind": "FIELD_BINDING_PATTERN", - "hasDiagnostics": true, + "kind": "SIMPLE_NAME_REFERENCE", "children": [ { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "ERROR_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "ERROR_KEYWORD", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_ERROR_KEYWORD" - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "m" - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] + "kind": "IDENTIFIER_TOKEN", + "value": "m" } ] } ] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_CLOSE_BRACE_TOKEN" - ] } ] - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_VARIABLE_DECL_HAVING_BP_MUST_BE_INITIALIZED" - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ + }, { - "kind": "IDENTIFIER_TOKEN", - "isMissing": true + "kind": "CLOSE_PAREN_TOKEN" } ] }, @@ -1438,15 +1219,41 @@ ] }, { - "kind": "CAPTURE_BINDING_PATTERN", + "kind": "ERROR_BINDING_PATTERN", "hasDiagnostics": true, "children": [ { - "kind": "IDENTIFIER_TOKEN", + "kind": "ERROR_KEYWORD", "isMissing": true, "hasDiagnostics": true, "diagnostics": [ - "ERROR_MISSING_IDENTIFIER" + "ERROR_MISSING_ERROR_KEYWORD" + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } ] } ] @@ -1455,170 +1262,71 @@ }, { "kind": "BLOCK_STATEMENT", - "hasDiagnostics": true, "children": [ { "kind": "OPEN_BRACE_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_OPEN_BRACE_TOKEN" + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } ] }, { "kind": "LIST", - "hasDiagnostics": true, "children": [ { - "kind": "LOCAL_VAR_DECL", - "hasDiagnostics": true, + "kind": "CALL_STATEMENT", "children": [ { - "kind": "LIST", - "children": [] - }, - { - "kind": "TYPED_BINDING_PATTERN", - "hasDiagnostics": true, + "kind": "FUNCTION_CALL", "children": [ { - "kind": "PARENTHESISED_TYPE_DESC", + "kind": "QUALIFIED_NAME_REFERENCE", "children": [ { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ { - "kind": "IDENTIFIER_TOKEN", - "value": "m" + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] }, { - "kind": "CLOSE_PAREN_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" } ] }, { - "kind": "MAPPING_BINDING_PATTERN", - "hasDiagnostics": true, + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", "children": [ { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "hasDiagnostics": true, + "kind": "POSITIONAL_ARG", "children": [ { - "kind": "FIELD_BINDING_PATTERN", - "hasDiagnostics": true, + "kind": "SIMPLE_NAME_REFERENCE", "children": [ { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "ERROR_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "ERROR_KEYWORD", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_ERROR_KEYWORD" - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "m" - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] + "kind": "IDENTIFIER_TOKEN", + "value": "m" } ] } ] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_CLOSE_BRACE_TOKEN" - ] } ] - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_VARIABLE_DECL_HAVING_BP_MUST_BE_INITIALIZED" - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ + }, { - "kind": "IDENTIFIER_TOKEN", - "isMissing": true + "kind": "CLOSE_PAREN_TOKEN" } ] }, @@ -1731,15 +1439,41 @@ ] }, { - "kind": "CAPTURE_BINDING_PATTERN", + "kind": "ERROR_BINDING_PATTERN", "hasDiagnostics": true, "children": [ { - "kind": "IDENTIFIER_TOKEN", + "kind": "ERROR_KEYWORD", "isMissing": true, "hasDiagnostics": true, "diagnostics": [ - "ERROR_MISSING_IDENTIFIER" + "ERROR_MISSING_ERROR_KEYWORD" + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } ] } ] @@ -1748,170 +1482,71 @@ }, { "kind": "BLOCK_STATEMENT", - "hasDiagnostics": true, "children": [ { "kind": "OPEN_BRACE_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_OPEN_BRACE_TOKEN" + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } ] }, { "kind": "LIST", - "hasDiagnostics": true, "children": [ { - "kind": "LOCAL_VAR_DECL", - "hasDiagnostics": true, + "kind": "CALL_STATEMENT", "children": [ { - "kind": "LIST", - "children": [] - }, - { - "kind": "TYPED_BINDING_PATTERN", - "hasDiagnostics": true, + "kind": "FUNCTION_CALL", "children": [ { - "kind": "PARENTHESISED_TYPE_DESC", + "kind": "QUALIFIED_NAME_REFERENCE", "children": [ { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ { - "kind": "IDENTIFIER_TOKEN", - "value": "m" + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] }, { - "kind": "CLOSE_PAREN_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" } ] }, { - "kind": "MAPPING_BINDING_PATTERN", - "hasDiagnostics": true, + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", "children": [ { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "hasDiagnostics": true, + "kind": "POSITIONAL_ARG", "children": [ { - "kind": "FIELD_BINDING_PATTERN", - "hasDiagnostics": true, + "kind": "SIMPLE_NAME_REFERENCE", "children": [ { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "ERROR_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "ERROR_KEYWORD", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_ERROR_KEYWORD" - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "m" - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] + "kind": "IDENTIFIER_TOKEN", + "value": "m" } ] } ] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_CLOSE_BRACE_TOKEN" - ] } ] - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_VARIABLE_DECL_HAVING_BP_MUST_BE_INITIALIZED" - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ + }, { - "kind": "IDENTIFIER_TOKEN", - "isMissing": true + "kind": "CLOSE_PAREN_TOKEN" } ] }, diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_12.json b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_12.json index 7bd24a397b07..2d03ee99cbf7 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_12.json +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_12.json @@ -154,15 +154,41 @@ ] }, { - "kind": "CAPTURE_BINDING_PATTERN", + "kind": "ERROR_BINDING_PATTERN", "hasDiagnostics": true, "children": [ { - "kind": "IDENTIFIER_TOKEN", + "kind": "ERROR_KEYWORD", "isMissing": true, "hasDiagnostics": true, "diagnostics": [ - "ERROR_MISSING_IDENTIFIER" + "ERROR_MISSING_ERROR_KEYWORD" + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } ] } ] @@ -171,170 +197,71 @@ }, { "kind": "BLOCK_STATEMENT", - "hasDiagnostics": true, "children": [ { "kind": "OPEN_BRACE_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_OPEN_BRACE_TOKEN" + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } ] }, { "kind": "LIST", - "hasDiagnostics": true, "children": [ { - "kind": "LOCAL_VAR_DECL", - "hasDiagnostics": true, + "kind": "CALL_STATEMENT", "children": [ { - "kind": "LIST", - "children": [] - }, - { - "kind": "TYPED_BINDING_PATTERN", - "hasDiagnostics": true, + "kind": "FUNCTION_CALL", "children": [ { - "kind": "PARENTHESISED_TYPE_DESC", + "kind": "QUALIFIED_NAME_REFERENCE", "children": [ { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ { - "kind": "IDENTIFIER_TOKEN", - "value": "m" + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] }, { - "kind": "CLOSE_PAREN_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" } ] }, { - "kind": "MAPPING_BINDING_PATTERN", - "hasDiagnostics": true, + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", "children": [ { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "hasDiagnostics": true, + "kind": "POSITIONAL_ARG", "children": [ { - "kind": "FIELD_BINDING_PATTERN", - "hasDiagnostics": true, + "kind": "SIMPLE_NAME_REFERENCE", "children": [ { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "ERROR_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "ERROR_KEYWORD", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_ERROR_KEYWORD" - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "m" - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] + "kind": "IDENTIFIER_TOKEN", + "value": "m" } ] } ] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_CLOSE_BRACE_TOKEN" - ] } ] - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_VARIABLE_DECL_HAVING_BP_MUST_BE_INITIALIZED" - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ + }, { - "kind": "IDENTIFIER_TOKEN", - "isMissing": true + "kind": "CLOSE_PAREN_TOKEN" } ] }, @@ -546,15 +473,41 @@ ] }, { - "kind": "CAPTURE_BINDING_PATTERN", + "kind": "ERROR_BINDING_PATTERN", "hasDiagnostics": true, "children": [ { - "kind": "IDENTIFIER_TOKEN", + "kind": "ERROR_KEYWORD", "isMissing": true, "hasDiagnostics": true, "diagnostics": [ - "ERROR_MISSING_IDENTIFIER" + "ERROR_MISSING_ERROR_KEYWORD" + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } ] } ] @@ -563,170 +516,71 @@ }, { "kind": "BLOCK_STATEMENT", - "hasDiagnostics": true, "children": [ { "kind": "OPEN_BRACE_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_OPEN_BRACE_TOKEN" + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } ] }, { "kind": "LIST", - "hasDiagnostics": true, "children": [ { - "kind": "LOCAL_VAR_DECL", - "hasDiagnostics": true, + "kind": "CALL_STATEMENT", "children": [ { - "kind": "LIST", - "children": [] - }, - { - "kind": "TYPED_BINDING_PATTERN", - "hasDiagnostics": true, + "kind": "FUNCTION_CALL", "children": [ { - "kind": "PARENTHESISED_TYPE_DESC", + "kind": "QUALIFIED_NAME_REFERENCE", "children": [ { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ { - "kind": "IDENTIFIER_TOKEN", - "value": "m" + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] }, { - "kind": "CLOSE_PAREN_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" } ] }, { - "kind": "MAPPING_BINDING_PATTERN", - "hasDiagnostics": true, + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", "children": [ { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "hasDiagnostics": true, + "kind": "POSITIONAL_ARG", "children": [ { - "kind": "FIELD_BINDING_PATTERN", - "hasDiagnostics": true, + "kind": "SIMPLE_NAME_REFERENCE", "children": [ { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "ERROR_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "ERROR_KEYWORD", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_ERROR_KEYWORD" - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "m" - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] + "kind": "IDENTIFIER_TOKEN", + "value": "m" } ] } ] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_CLOSE_BRACE_TOKEN" - ] } ] - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_VARIABLE_DECL_HAVING_BP_MUST_BE_INITIALIZED" - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ + }, { - "kind": "IDENTIFIER_TOKEN", - "isMissing": true + "kind": "CLOSE_PAREN_TOKEN" } ] }, @@ -1022,187 +876,114 @@ ] }, { - "kind": "CAPTURE_BINDING_PATTERN", + "kind": "ERROR_BINDING_PATTERN", "hasDiagnostics": true, "children": [ { - "kind": "IDENTIFIER_TOKEN", + "kind": "ERROR_KEYWORD", "isMissing": true, "hasDiagnostics": true, "diagnostics": [ - "ERROR_MISSING_IDENTIFIER" + "ERROR_MISSING_ERROR_KEYWORD" ] - } - ] - } - ] - }, - { - "kind": "BLOCK_STATEMENT", - "hasDiagnostics": true, + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", "children": [ { "kind": "OPEN_BRACE_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_OPEN_BRACE_TOKEN" + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } ] }, { "kind": "LIST", - "hasDiagnostics": true, "children": [ { - "kind": "LOCAL_VAR_DECL", - "hasDiagnostics": true, + "kind": "CALL_STATEMENT", "children": [ { - "kind": "LIST", - "children": [] - }, - { - "kind": "TYPED_BINDING_PATTERN", - "hasDiagnostics": true, + "kind": "FUNCTION_CALL", "children": [ { - "kind": "PARENTHESISED_TYPE_DESC", + "kind": "QUALIFIED_NAME_REFERENCE", "children": [ { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ { - "kind": "IDENTIFIER_TOKEN", - "value": "m" + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] }, { - "kind": "CLOSE_PAREN_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" } ] }, { - "kind": "MAPPING_BINDING_PATTERN", - "hasDiagnostics": true, + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", "children": [ { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "hasDiagnostics": true, + "kind": "POSITIONAL_ARG", "children": [ { - "kind": "FIELD_BINDING_PATTERN", - "hasDiagnostics": true, + "kind": "SIMPLE_NAME_REFERENCE", "children": [ { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "ERROR_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "ERROR_KEYWORD", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_ERROR_KEYWORD" - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "m" - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] + "kind": "IDENTIFIER_TOKEN", + "value": "m" } ] } ] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_CLOSE_BRACE_TOKEN" - ] } ] - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_VARIABLE_DECL_HAVING_BP_MUST_BE_INITIALIZED" - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ + }, { - "kind": "IDENTIFIER_TOKEN", - "isMissing": true + "kind": "CLOSE_PAREN_TOKEN" } ] }, @@ -1462,15 +1243,41 @@ ] }, { - "kind": "CAPTURE_BINDING_PATTERN", + "kind": "ERROR_BINDING_PATTERN", "hasDiagnostics": true, "children": [ { - "kind": "IDENTIFIER_TOKEN", + "kind": "ERROR_KEYWORD", "isMissing": true, "hasDiagnostics": true, "diagnostics": [ - "ERROR_MISSING_IDENTIFIER" + "ERROR_MISSING_ERROR_KEYWORD" + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } ] } ] @@ -1479,170 +1286,71 @@ }, { "kind": "BLOCK_STATEMENT", - "hasDiagnostics": true, "children": [ { "kind": "OPEN_BRACE_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_OPEN_BRACE_TOKEN" + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } ] }, { "kind": "LIST", - "hasDiagnostics": true, "children": [ { - "kind": "LOCAL_VAR_DECL", - "hasDiagnostics": true, + "kind": "CALL_STATEMENT", "children": [ { - "kind": "LIST", - "children": [] - }, - { - "kind": "TYPED_BINDING_PATTERN", - "hasDiagnostics": true, + "kind": "FUNCTION_CALL", "children": [ { - "kind": "PARENTHESISED_TYPE_DESC", + "kind": "QUALIFIED_NAME_REFERENCE", "children": [ { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ { - "kind": "IDENTIFIER_TOKEN", - "value": "m" + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] }, { - "kind": "CLOSE_PAREN_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" } ] }, { - "kind": "MAPPING_BINDING_PATTERN", - "hasDiagnostics": true, + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", "children": [ { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "hasDiagnostics": true, + "kind": "POSITIONAL_ARG", "children": [ { - "kind": "FIELD_BINDING_PATTERN", - "hasDiagnostics": true, + "kind": "SIMPLE_NAME_REFERENCE", "children": [ { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "ERROR_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "ERROR_KEYWORD", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_ERROR_KEYWORD" - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "m" - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] + "kind": "IDENTIFIER_TOKEN", + "value": "m" } ] } ] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_CLOSE_BRACE_TOKEN" - ] } ] - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_VARIABLE_DECL_HAVING_BP_MUST_BE_INITIALIZED" - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ + }, { - "kind": "IDENTIFIER_TOKEN", - "isMissing": true + "kind": "CLOSE_PAREN_TOKEN" } ] }, @@ -1761,15 +1469,41 @@ ] }, { - "kind": "CAPTURE_BINDING_PATTERN", + "kind": "ERROR_BINDING_PATTERN", "hasDiagnostics": true, "children": [ { - "kind": "IDENTIFIER_TOKEN", + "kind": "ERROR_KEYWORD", "isMissing": true, "hasDiagnostics": true, "diagnostics": [ - "ERROR_MISSING_IDENTIFIER" + "ERROR_MISSING_ERROR_KEYWORD" + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } ] } ] @@ -1778,170 +1512,71 @@ }, { "kind": "BLOCK_STATEMENT", - "hasDiagnostics": true, "children": [ { "kind": "OPEN_BRACE_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_OPEN_BRACE_TOKEN" + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } ] }, { "kind": "LIST", - "hasDiagnostics": true, "children": [ { - "kind": "LOCAL_VAR_DECL", - "hasDiagnostics": true, + "kind": "CALL_STATEMENT", "children": [ { - "kind": "LIST", - "children": [] - }, - { - "kind": "TYPED_BINDING_PATTERN", - "hasDiagnostics": true, + "kind": "FUNCTION_CALL", "children": [ { - "kind": "PARENTHESISED_TYPE_DESC", + "kind": "QUALIFIED_NAME_REFERENCE", "children": [ { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ { - "kind": "IDENTIFIER_TOKEN", - "value": "m" + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] }, { - "kind": "CLOSE_PAREN_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" } ] }, { - "kind": "MAPPING_BINDING_PATTERN", - "hasDiagnostics": true, + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", "children": [ { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "hasDiagnostics": true, + "kind": "POSITIONAL_ARG", "children": [ { - "kind": "FIELD_BINDING_PATTERN", - "hasDiagnostics": true, + "kind": "SIMPLE_NAME_REFERENCE", "children": [ { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "ERROR_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "ERROR_KEYWORD", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_ERROR_KEYWORD" - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "m" - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] + "kind": "IDENTIFIER_TOKEN", + "value": "m" } ] } ] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_CLOSE_BRACE_TOKEN" - ] } ] - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_VARIABLE_DECL_HAVING_BP_MUST_BE_INITIALIZED" - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ + }, { - "kind": "IDENTIFIER_TOKEN", - "isMissing": true + "kind": "CLOSE_PAREN_TOKEN" } ] }, diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_09.bal b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_09.bal index edc275af9635..78e41d69de03 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_09.bal +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_09.bal @@ -1,12 +1,12 @@ function foo() { transaction { - } on fail error [err] { + } on fail error error err { io:println(err); } transaction { int a = 5; - } on fail error [err] { + } on fail error error err { io:println(err); } @@ -16,7 +16,7 @@ function foo() { string b; } } - } on fail error [err] { + } on fail error error err { io:println(err); } @@ -24,11 +24,11 @@ function foo() { transaction { transaction { string b; - } on fail error [err] { + } on fail error error err { io:println(err); } } - } on fail error [err] { + } on fail error error err { io:println(err); } } diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_10.bal b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_10.bal index 46739327f745..024867e1c555 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_10.bal +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_10.bal @@ -1,12 +1,12 @@ function foo() { transaction { - } on fail var error(message = m) { + } on fail var error(m { io:println(m); } transaction { int a = 5; - } on fail var error(message = m) { + } on fail var error(m { io:println(m); } @@ -16,7 +16,7 @@ function foo() { string b; } } - } on fail var error(message = m) { + } on fail var error(m { io:println(m); } @@ -24,11 +24,11 @@ function foo() { transaction { transaction { string b; - } on fail var error(message = m) { + } on fail var error(m { io:println(m); } } - } on fail var error(message = m) { + } on fail var error(m { io:println(m); } } diff --git a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_04.json b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_04.json index cadec5ea7953..8332a9bbb25f 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_04.json +++ b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_04.json @@ -493,26 +493,36 @@ ] }, { - "kind": "ERROR_TYPE_DESC", + "kind": "TYPED_BINDING_PATTERN", "children": [ { - "kind": "ERROR_KEYWORD", - "trailingMinutiae": [ + "kind": "ERROR_TYPE_DESC", + "children": [ { - "kind": "WHITESPACE_MINUTIAE", - "value": " " + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] } ] - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "e", - "trailingMinutiae": [ + }, { - "kind": "WHITESPACE_MINUTIAE", - "value": " " + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "e", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] } ] }, diff --git a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_05.json b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_05.json index 9e70bd1d668a..6fb0804b3e52 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_05.json +++ b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_05.json @@ -514,50 +514,62 @@ ] }, { - "kind": "SIMPLE_NAME_REFERENCE", + "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, "children": [ { - "kind": "IDENTIFIER_TOKEN", - "value": "extra", - "trailingMinutiae": [ + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ { - "kind": "WHITESPACE_MINUTIAE", - "value": " " + "kind": "IDENTIFIER_TOKEN", + "value": "extra", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] } ] - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "hasDiagnostics": true, - "value": "e", - "leadingMinutiae": [ - { - "kind": "INVALID_NODE_MINUTIAE", - "invalidNode": { - "kind": "INVALID_TOKEN_MINUTIAE_NODE", - "hasDiagnostics": true, - "children": [ - { - "kind": "TYPEDESC_KEYWORD", - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_INVALID_TOKEN" - ] - } - ] - } }, { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " + "kind": "CAPTURE_BINDING_PATTERN", + "hasDiagnostics": true, + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "hasDiagnostics": true, + "value": "e", + "leadingMinutiae": [ + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "hasDiagnostics": true, + "children": [ + { + "kind": "TYPEDESC_KEYWORD", + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_INVALID_TOKEN" + ] + } + ] + } + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] } ] }, diff --git a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_09.json b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_09.json index 0f17859fc822..1a8e198af7b4 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_09.json +++ b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_09.json @@ -1,1319 +1,116 @@ { - "kind": "MODULE_PART", + "kind": "TYPE_DEFINITION", "children": [ { - "kind": "LIST", - "children": [] + "kind": "TYPE_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] }, { - "kind": "LIST", + "kind": "IDENTIFIER_TOKEN", + "value": "SampleErrorData", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "RECORD_TYPE_DESC", "children": [ { - "kind": "TYPE_DEFINITION", - "children": [ - { - "kind": "TYPE_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "SampleErrorData", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "RECORD_TYPE_DESC", - "children": [ - { - "kind": "RECORD_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "OPEN_BRACE_PIPE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "children": [ - { - "kind": "RECORD_FIELD", - "children": [ - { - "kind": "INT_TYPE_DESC", - "children": [ - { - "kind": "INT_KEYWORD", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "userCode" - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "RECORD_FIELD", - "children": [ - { - "kind": "STRING_TYPE_DESC", - "children": [ - { - "kind": "STRING_KEYWORD", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "userReason" - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_BRACE_PIPE_TOKEN" - } - ] - }, + "kind": "RECORD_KEYWORD", + "trailingMinutiae": [ { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] }, { - "kind": "TYPE_DEFINITION", - "children": [ - { - "kind": "TYPE_KEYWORD", - "leadingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "SampleError", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, + "kind": "OPEN_BRACE_PIPE_TOKEN", + "trailingMinutiae": [ { - "kind": "ERROR_TYPE_DESC", - "children": [ - { - "kind": "ERROR_KEYWORD" - }, - { - "kind": "TYPE_PARAMETER", - "children": [ - { - "kind": "LT_TOKEN" - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "SampleErrorData" - } - ] - }, - { - "kind": "GT_TOKEN" - } - ] - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" } ] }, { - "kind": "FUNCTION_DEFINITION", + "kind": "LIST", "children": [ { - "kind": "LIST", + "kind": "RECORD_FIELD", "children": [ { - "kind": "PUBLIC_KEYWORD", - "leadingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ], - "trailingMinutiae": [ + "kind": "INT_TYPE_DESC", + "children": [ { - "kind": "WHITESPACE_MINUTIAE", - "value": " " + "kind": "INT_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] } ] - } - ] - }, - { - "kind": "FUNCTION_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "test" - }, - { - "kind": "LIST", - "children": [] - }, - { - "kind": "FUNCTION_SIGNATURE", - "children": [ - { - "kind": "OPEN_PAREN_TOKEN" }, { - "kind": "LIST", - "children": [] + "kind": "IDENTIFIER_TOKEN", + "value": "userCode" }, { - "kind": "CLOSE_PAREN_TOKEN", + "kind": "SEMICOLON_TOKEN", "trailingMinutiae": [ { - "kind": "WHITESPACE_MINUTIAE", - "value": " " + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" } ] } ] }, { - "kind": "FUNCTION_BODY_BLOCK", + "kind": "RECORD_FIELD", "children": [ { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", + "kind": "STRING_TYPE_DESC", "children": [ { - "kind": "LOCAL_VAR_DECL", - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "TYPED_BINDING_PATTERN", - "children": [ - { - "kind": "INT_TYPE_DESC", - "children": [ - { - "kind": "INT_KEYWORD", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "i", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, + "kind": "STRING_KEYWORD", + "leadingMinutiae": [ { - "kind": "NUMERIC_LITERAL", - "children": [ - { - "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", - "value": "0" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] + "kind": "WHITESPACE_MINUTIAE", + "value": " " } - ] - }, - { - "kind": "WHILE_STATEMENT", - "children": [ - { - "kind": "WHILE_KEYWORD", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, + ], + "trailingMinutiae": [ { - "kind": "BINARY_EXPRESSION", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "i", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "LT_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "NUMERIC_LITERAL", - "children": [ - { - "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", - "value": "3", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - } - ] - }, - { - "kind": "BLOCK_STATEMENT", - "children": [ - { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "children": [ - { - "kind": "ASSIGNMENT_STATEMENT", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "i", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "BINARY_EXPRESSION", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "i", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "PLUS_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "NUMERIC_LITERAL", - "children": [ - { - "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", - "value": "1" - } - ] - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "LOCAL_VAR_DECL", - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "TYPED_BINDING_PATTERN", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "SampleError", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "err", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "ERROR_CONSTRUCTOR", - "children": [ - { - "kind": "ERROR_KEYWORD" - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "STRING_LITERAL", - "children": [ - { - "kind": "STRING_LITERAL_TOKEN", - "value": "Transaction Failure" - } - ] - } - ] - }, - { - "kind": "COMMA_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "ERROR_CONSTRUCTOR", - "children": [ - { - "kind": "ERROR_KEYWORD" - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "STRING_LITERAL", - "children": [ - { - "kind": "STRING_LITERAL_TOKEN", - "value": "Database Error" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - } - ] - }, - { - "kind": "COMMA_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "NAMED_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "userCode", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "NUMERIC_LITERAL", - "children": [ - { - "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", - "value": "20" - } - ] - } - ] - }, - { - "kind": "COMMA_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "NAMED_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "userReason", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "STRING_LITERAL", - "children": [ - { - "kind": "STRING_LITERAL_TOKEN", - "value": "deadlock condition" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "FAIL_STATEMENT", - "children": [ - { - "kind": "FAIL_KEYWORD", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "err" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "ON_FAIL_CLAUSE", - "children": [ - { - "kind": "ON_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "FAIL_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "TYPED_BINDING_PATTERN", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "SampleError", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "ERROR_BINDING_PATTERN", - "children": [ - { - "kind": "ERROR_KEYWORD" - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "message" - } - ] - }, - { - "kind": "COMMA_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "cause" - } - ] - }, - { - "kind": "COMMA_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "NAMED_ARG_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "userCode", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "code" - } - ] - } - ] - }, - { - "kind": "COMMA_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "NAMED_ARG_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "userReason", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "reason" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - } - ] - }, - { - "kind": "BLOCK_STATEMENT", - "children": [ - { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "children": [ - { - "kind": "CALL_STATEMENT", - "children": [ - { - "kind": "FUNCTION_CALL", - "children": [ - { - "kind": "QUALIFIED_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "message" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "CALL_STATEMENT", - "children": [ - { - "kind": "FUNCTION_CALL", - "children": [ - { - "kind": "QUALIFIED_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "cause" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "CALL_STATEMENT", - "children": [ - { - "kind": "FUNCTION_CALL", - "children": [ - { - "kind": "QUALIFIED_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "code" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "CALL_STATEMENT", - "children": [ - { - "kind": "FUNCTION_CALL", - "children": [ - { - "kind": "QUALIFIED_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "reason" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] } ] }, { - "kind": "CLOSE_BRACE_TOKEN", + "kind": "IDENTIFIER_TOKEN", + "value": "userReason" + }, + { + "kind": "SEMICOLON_TOKEN", "trailingMinutiae": [ { "kind": "END_OF_LINE_MINUTIAE", @@ -1324,11 +121,20 @@ ] } ] + }, + { + "kind": "CLOSE_BRACE_PIPE_TOKEN" } ] }, { - "kind": "EOF_TOKEN" + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] } ] } diff --git a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_10.json b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_10.json index 402bb8dfd873..1a8e198af7b4 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_10.json +++ b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_10.json @@ -1,1318 +1,116 @@ { - "kind": "MODULE_PART", + "kind": "TYPE_DEFINITION", "children": [ { - "kind": "LIST", - "children": [] + "kind": "TYPE_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] }, { - "kind": "LIST", + "kind": "IDENTIFIER_TOKEN", + "value": "SampleErrorData", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "RECORD_TYPE_DESC", "children": [ { - "kind": "TYPE_DEFINITION", - "children": [ - { - "kind": "TYPE_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "SampleErrorData", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "RECORD_TYPE_DESC", - "children": [ - { - "kind": "RECORD_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "OPEN_BRACE_PIPE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "children": [ - { - "kind": "RECORD_FIELD", - "children": [ - { - "kind": "INT_TYPE_DESC", - "children": [ - { - "kind": "INT_KEYWORD", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "userCode" - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "RECORD_FIELD", - "children": [ - { - "kind": "STRING_TYPE_DESC", - "children": [ - { - "kind": "STRING_KEYWORD", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "userReason" - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_BRACE_PIPE_TOKEN" - } - ] - }, + "kind": "RECORD_KEYWORD", + "trailingMinutiae": [ { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] }, { - "kind": "TYPE_DEFINITION", - "children": [ - { - "kind": "TYPE_KEYWORD", - "leadingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "SampleError", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, + "kind": "OPEN_BRACE_PIPE_TOKEN", + "trailingMinutiae": [ { - "kind": "ERROR_TYPE_DESC", - "children": [ - { - "kind": "ERROR_KEYWORD" - }, - { - "kind": "TYPE_PARAMETER", - "children": [ - { - "kind": "LT_TOKEN" - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "SampleErrorData" - } - ] - }, - { - "kind": "GT_TOKEN" - } - ] - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" } ] }, { - "kind": "FUNCTION_DEFINITION", + "kind": "LIST", "children": [ { - "kind": "LIST", + "kind": "RECORD_FIELD", "children": [ { - "kind": "PUBLIC_KEYWORD", - "leadingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ], - "trailingMinutiae": [ + "kind": "INT_TYPE_DESC", + "children": [ { - "kind": "WHITESPACE_MINUTIAE", - "value": " " + "kind": "INT_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] } ] - } - ] - }, - { - "kind": "FUNCTION_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "test" - }, - { - "kind": "LIST", - "children": [] - }, - { - "kind": "FUNCTION_SIGNATURE", - "children": [ - { - "kind": "OPEN_PAREN_TOKEN" }, { - "kind": "LIST", - "children": [] + "kind": "IDENTIFIER_TOKEN", + "value": "userCode" }, { - "kind": "CLOSE_PAREN_TOKEN", + "kind": "SEMICOLON_TOKEN", "trailingMinutiae": [ { - "kind": "WHITESPACE_MINUTIAE", - "value": " " + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" } ] } ] }, { - "kind": "FUNCTION_BODY_BLOCK", + "kind": "RECORD_FIELD", "children": [ { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", + "kind": "STRING_TYPE_DESC", "children": [ { - "kind": "LOCAL_VAR_DECL", - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "TYPED_BINDING_PATTERN", - "children": [ - { - "kind": "INT_TYPE_DESC", - "children": [ - { - "kind": "INT_KEYWORD", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "i", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, + "kind": "STRING_KEYWORD", + "leadingMinutiae": [ { - "kind": "NUMERIC_LITERAL", - "children": [ - { - "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", - "value": "0" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] + "kind": "WHITESPACE_MINUTIAE", + "value": " " } - ] - }, - { - "kind": "WHILE_STATEMENT", - "children": [ - { - "kind": "WHILE_KEYWORD", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, + ], + "trailingMinutiae": [ { - "kind": "BINARY_EXPRESSION", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "i", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "LT_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "NUMERIC_LITERAL", - "children": [ - { - "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", - "value": "3", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - } - ] - }, - { - "kind": "BLOCK_STATEMENT", - "children": [ - { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "children": [ - { - "kind": "ASSIGNMENT_STATEMENT", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "i", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "BINARY_EXPRESSION", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "i", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "PLUS_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "NUMERIC_LITERAL", - "children": [ - { - "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", - "value": "1" - } - ] - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "LOCAL_VAR_DECL", - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "TYPED_BINDING_PATTERN", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "SampleError", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "err", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "ERROR_CONSTRUCTOR", - "children": [ - { - "kind": "ERROR_KEYWORD" - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "STRING_LITERAL", - "children": [ - { - "kind": "STRING_LITERAL_TOKEN", - "value": "Transaction Failure" - } - ] - } - ] - }, - { - "kind": "COMMA_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "ERROR_CONSTRUCTOR", - "children": [ - { - "kind": "ERROR_KEYWORD" - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "STRING_LITERAL", - "children": [ - { - "kind": "STRING_LITERAL_TOKEN", - "value": "Database Error" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - } - ] - }, - { - "kind": "COMMA_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "NAMED_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "userCode", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "NUMERIC_LITERAL", - "children": [ - { - "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", - "value": "20" - } - ] - } - ] - }, - { - "kind": "COMMA_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "NAMED_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "userReason", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "STRING_LITERAL", - "children": [ - { - "kind": "STRING_LITERAL_TOKEN", - "value": "deadlock condition" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "FAIL_STATEMENT", - "children": [ - { - "kind": "FAIL_KEYWORD", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "err" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "ON_FAIL_CLAUSE", - "children": [ - { - "kind": "ON_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "FAIL_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "TYPED_BINDING_PATTERN", - "children": [ - { - "kind": "VAR_TYPE_DESC", - "children": [ - { - "kind": "VAR_KEYWORD", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "ERROR_BINDING_PATTERN", - "children": [ - { - "kind": "ERROR_KEYWORD" - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "message" - } - ] - }, - { - "kind": "COMMA_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "cause" - } - ] - }, - { - "kind": "COMMA_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "NAMED_ARG_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "userCode", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "code" - } - ] - } - ] - }, - { - "kind": "COMMA_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "NAMED_ARG_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "userReason", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "reason" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - } - ] - }, - { - "kind": "BLOCK_STATEMENT", - "children": [ - { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "children": [ - { - "kind": "CALL_STATEMENT", - "children": [ - { - "kind": "FUNCTION_CALL", - "children": [ - { - "kind": "QUALIFIED_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "message" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "CALL_STATEMENT", - "children": [ - { - "kind": "FUNCTION_CALL", - "children": [ - { - "kind": "QUALIFIED_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "cause" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "CALL_STATEMENT", - "children": [ - { - "kind": "FUNCTION_CALL", - "children": [ - { - "kind": "QUALIFIED_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "code" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "CALL_STATEMENT", - "children": [ - { - "kind": "FUNCTION_CALL", - "children": [ - { - "kind": "QUALIFIED_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "reason" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] } ] }, { - "kind": "CLOSE_BRACE_TOKEN", + "kind": "IDENTIFIER_TOKEN", + "value": "userReason" + }, + { + "kind": "SEMICOLON_TOKEN", "trailingMinutiae": [ { "kind": "END_OF_LINE_MINUTIAE", @@ -1323,11 +121,20 @@ ] } ] + }, + { + "kind": "CLOSE_BRACE_PIPE_TOKEN" } ] }, { - "kind": "EOF_TOKEN" + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] } ] } diff --git a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_11.json b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_11.json index fb1d1e7d8505..b28e29bfac2f 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_11.json +++ b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_11.json @@ -429,15 +429,185 @@ ] }, { - "kind": "CAPTURE_BINDING_PATTERN", + "kind": "ERROR_BINDING_PATTERN", "hasDiagnostics": true, "children": [ { - "kind": "IDENTIFIER_TOKEN", + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN", "isMissing": true, "hasDiagnostics": true, "diagnostics": [ - "ERROR_MISSING_IDENTIFIER" + "ERROR_MISSING_OPEN_PAREN_TOKEN" + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_CLOSE_PAREN_TOKEN" + ], + "leadingMinutiae": [ + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_BINDING_PATTERN_NOT_ALLOWED" + ] + } + ] + } + }, + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io" + } + ] + } + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "COLON_TOKEN" + } + ] + } + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + } + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + } + ] + } + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "hasDiagnostics": true, + "children": [ + { + "kind": "SEMICOLON_TOKEN", + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_INVALID_TOKEN" + ] + } + ] + } + }, + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + }, + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "children": [ + { + "kind": "CLOSE_BRACE_TOKEN" + } + ] + } + }, + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } ] } ] @@ -458,243 +628,7 @@ }, { "kind": "LIST", - "hasDiagnostics": true, - "children": [ - { - "kind": "LOCAL_VAR_DECL", - "hasDiagnostics": true, - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "TYPED_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "TUPLE_TYPE_DESC", - "children": [ - { - "kind": "OPEN_BRACKET_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "MEMBER_TYPE_DESC", - "children": [ - { - "kind": "LIST", - "children": [] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "err" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_BRACKET_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "MAPPING_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "hasDiagnostics": true, - "children": [ - { - "kind": "FIELD_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "ERROR_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "ERROR_KEYWORD", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_ERROR_KEYWORD" - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "err" - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - } - ] - }, - { - "kind": "COMMA_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_COMMA_TOKEN" - ] - }, - { - "kind": "FIELD_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "hasDiagnostics": true, - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_IDENTIFIER" - ], - "leadingMinutiae": [ - { - "kind": "INVALID_NODE_MINUTIAE", - "invalidNode": { - "kind": "INVALID_TOKEN_MINUTIAE_NODE", - "hasDiagnostics": true, - "children": [ - { - "kind": "SEMICOLON_TOKEN", - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_INVALID_TOKEN" - ] - } - ] - } - }, - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_VARIABLE_DECL_HAVING_BP_MUST_BE_INITIALIZED" - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "isMissing": true - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_SEMICOLON_TOKEN" - ] - } - ] - } - ] + "children": [] }, { "kind": "CLOSE_BRACE_TOKEN", diff --git a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_12.json b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_12.json index df8ccfcb2916..be49b02a88cd 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_12.json +++ b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_12.json @@ -1,5 +1,6 @@ { "kind": "FUNCTION_DEFINITION", + "hasDiagnostics": true, "children": [ { "kind": "LIST", @@ -55,6 +56,7 @@ }, { "kind": "FUNCTION_BODY_BLOCK", + "hasDiagnostics": true, "children": [ { "kind": "OPEN_BRACE_TOKEN", @@ -67,6 +69,7 @@ }, { "kind": "LIST", + "hasDiagnostics": true, "children": [ { "kind": "LOCAL_VAR_DECL", @@ -146,6 +149,7 @@ }, { "kind": "WHILE_STATEMENT", + "hasDiagnostics": true, "children": [ { "kind": "WHILE_KEYWORD", @@ -386,6 +390,7 @@ }, { "kind": "ON_FAIL_CLAUSE", + "hasDiagnostics": true, "children": [ { "kind": "ON_KEYWORD", @@ -407,6 +412,7 @@ }, { "kind": "TYPED_BINDING_PATTERN", + "hasDiagnostics": true, "children": [ { "kind": "VAR_TYPE_DESC", @@ -424,6 +430,7 @@ }, { "kind": "ERROR_BINDING_PATTERN", + "hasDiagnostics": true, "children": [ { "kind": "ERROR_KEYWORD" @@ -435,35 +442,17 @@ "kind": "LIST", "children": [ { - "kind": "NAMED_ARG_BINDING_PATTERN", + "kind": "CAPTURE_BINDING_PATTERN", "children": [ { "kind": "IDENTIFIER_TOKEN", - "value": "message", + "value": "m", "trailingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", "value": " " } ] - }, - { - "kind": "EQUAL_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "m" - } - ] } ] } @@ -471,11 +460,10 @@ }, { "kind": "CLOSE_PAREN_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_CLOSE_PAREN_TOKEN" ] } ] diff --git a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_13.json b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_13.json index 031d9fe1b0ff..79af61ad7d5e 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_13.json +++ b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_13.json @@ -423,15 +423,41 @@ ] }, { - "kind": "CAPTURE_BINDING_PATTERN", + "kind": "ERROR_BINDING_PATTERN", "hasDiagnostics": true, "children": [ { - "kind": "IDENTIFIER_TOKEN", + "kind": "ERROR_KEYWORD", "isMissing": true, "hasDiagnostics": true, "diagnostics": [ - "ERROR_MISSING_IDENTIFIER" + "ERROR_MISSING_ERROR_KEYWORD" + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } ] } ] @@ -440,170 +466,71 @@ }, { "kind": "BLOCK_STATEMENT", - "hasDiagnostics": true, "children": [ { "kind": "OPEN_BRACE_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_OPEN_BRACE_TOKEN" + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } ] }, { "kind": "LIST", - "hasDiagnostics": true, "children": [ { - "kind": "LOCAL_VAR_DECL", - "hasDiagnostics": true, + "kind": "CALL_STATEMENT", "children": [ { - "kind": "LIST", - "children": [] - }, - { - "kind": "TYPED_BINDING_PATTERN", - "hasDiagnostics": true, + "kind": "FUNCTION_CALL", "children": [ { - "kind": "PARENTHESISED_TYPE_DESC", + "kind": "QUALIFIED_NAME_REFERENCE", "children": [ { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ { - "kind": "IDENTIFIER_TOKEN", - "value": "m" + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] }, { - "kind": "CLOSE_PAREN_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" } ] }, { - "kind": "MAPPING_BINDING_PATTERN", - "hasDiagnostics": true, + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", "children": [ { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "hasDiagnostics": true, + "kind": "POSITIONAL_ARG", "children": [ { - "kind": "FIELD_BINDING_PATTERN", - "hasDiagnostics": true, + "kind": "SIMPLE_NAME_REFERENCE", "children": [ { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "ERROR_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "ERROR_KEYWORD", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_ERROR_KEYWORD" - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "m" - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] + "kind": "IDENTIFIER_TOKEN", + "value": "m" } ] } ] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_CLOSE_BRACE_TOKEN" - ] } ] - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_VARIABLE_DECL_HAVING_BP_MUST_BE_INITIALIZED" - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ + }, { - "kind": "IDENTIFIER_TOKEN", - "isMissing": true + "kind": "CLOSE_PAREN_TOKEN" } ] }, diff --git a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_14.json b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_14.json index b13d37599bbd..042772e4b9c6 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_14.json +++ b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_14.json @@ -429,15 +429,41 @@ ] }, { - "kind": "CAPTURE_BINDING_PATTERN", + "kind": "ERROR_BINDING_PATTERN", "hasDiagnostics": true, "children": [ { - "kind": "IDENTIFIER_TOKEN", + "kind": "ERROR_KEYWORD", "isMissing": true, "hasDiagnostics": true, "diagnostics": [ - "ERROR_MISSING_IDENTIFIER" + "ERROR_MISSING_ERROR_KEYWORD" + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "m" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } ] } ] @@ -446,170 +472,71 @@ }, { "kind": "BLOCK_STATEMENT", - "hasDiagnostics": true, "children": [ { "kind": "OPEN_BRACE_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_OPEN_BRACE_TOKEN" + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } ] }, { "kind": "LIST", - "hasDiagnostics": true, "children": [ { - "kind": "LOCAL_VAR_DECL", - "hasDiagnostics": true, + "kind": "CALL_STATEMENT", "children": [ { - "kind": "LIST", - "children": [] - }, - { - "kind": "TYPED_BINDING_PATTERN", - "hasDiagnostics": true, + "kind": "FUNCTION_CALL", "children": [ { - "kind": "PARENTHESISED_TYPE_DESC", + "kind": "QUALIFIED_NAME_REFERENCE", "children": [ { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ { - "kind": "IDENTIFIER_TOKEN", - "value": "m" + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] }, { - "kind": "CLOSE_PAREN_TOKEN", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" } ] }, { - "kind": "MAPPING_BINDING_PATTERN", - "hasDiagnostics": true, + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", "children": [ { - "kind": "OPEN_BRACE_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - }, - { - "kind": "LIST", - "hasDiagnostics": true, + "kind": "POSITIONAL_ARG", "children": [ { - "kind": "FIELD_BINDING_PATTERN", - "hasDiagnostics": true, + "kind": "SIMPLE_NAME_REFERENCE", "children": [ { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "ERROR_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "ERROR_KEYWORD", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_ERROR_KEYWORD" - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "CAPTURE_BINDING_PATTERN", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "m" - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] + "kind": "IDENTIFIER_TOKEN", + "value": "m" } ] } ] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_CLOSE_BRACE_TOKEN" - ] } ] - } - ] - }, - { - "kind": "EQUAL_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_VARIABLE_DECL_HAVING_BP_MUST_BE_INITIALIZED" - ] - }, - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ + }, { - "kind": "IDENTIFIER_TOKEN", - "isMissing": true + "kind": "CLOSE_PAREN_TOKEN" } ] }, diff --git a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_11.bal b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_11.bal index f9b99010a816..874f0d648c3f 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_11.bal +++ b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_11.bal @@ -3,7 +3,7 @@ public function test() { while i < 3 { i = i + 1; fail error("error!"); - } on fail error [err] { + } on fail error error err { io:println(err); } } diff --git a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_12.bal b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_12.bal index 2431f4c32aa9..4214db7cde74 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_12.bal +++ b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_12.bal @@ -3,7 +3,7 @@ public function test() { while i < 3 { i = i + 1; fail error("error!"); - } on fail var error(message = m) { + } on fail var error(m { io:println(m); } } From c43bb84d5a6e653e4eac66a99334b375a9fd1465 Mon Sep 17 00:00:00 2001 From: suleka96 Date: Tue, 18 Apr 2023 17:24:43 +0530 Subject: [PATCH 05/33] Update for each test --- .../parser/test/syntax/statements/ForEachStatementTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/ForEachStatementTest.java b/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/ForEachStatementTest.java index 5c58fbfbd621..7fc906c6f0d3 100644 --- a/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/ForEachStatementTest.java +++ b/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/ForEachStatementTest.java @@ -117,7 +117,7 @@ public void testForEachWithOnFailClauseHavingErrorBPWithUserDefinedErrorWithVar( @Test public void testForEachStmtWithMissingClosingBraces() { testFile("forEach-stmt/forEach_stmt_source_04.bal", - "forEach-stmt/forEach_stmt_source_04.json"); + "forEach-stmt/forEach_stmt_assert_04.json"); } @Test From bd2cf0413d0c73bc338e4fb6a2fde0219ee3bc80 Mon Sep 17 00:00:00 2001 From: suleka96 Date: Tue, 18 Apr 2023 18:18:04 +0530 Subject: [PATCH 06/33] Update tree modifier --- .../ballerinalang/formatter/core/FormattingTreeModifier.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/misc/formatter/modules/formatter-core/src/main/java/org/ballerinalang/formatter/core/FormattingTreeModifier.java b/misc/formatter/modules/formatter-core/src/main/java/org/ballerinalang/formatter/core/FormattingTreeModifier.java index ced690e44001..e1b34566e81a 100644 --- a/misc/formatter/modules/formatter-core/src/main/java/org/ballerinalang/formatter/core/FormattingTreeModifier.java +++ b/misc/formatter/modules/formatter-core/src/main/java/org/ballerinalang/formatter/core/FormattingTreeModifier.java @@ -1021,7 +1021,8 @@ public BinaryExpressionNode transform(BinaryExpressionNode binaryExpressionNode) public OnFailClauseNode transform(OnFailClauseNode onFailClauseNode) { Token onKeyword = formatToken(onFailClauseNode.onKeyword(), 1, 0); Token failKeyword = formatToken(onFailClauseNode.failKeyword(), 1, 0); - TypedBindingPatternNode typeBindingPattern = formatNode(onFailClauseNode.typedBindingPattern().orElse(null), 1, 0); + TypedBindingPatternNode typeBindingPattern = + formatNode(onFailClauseNode.typedBindingPattern().orElse(null), 1, 0); BlockStatementNode blockStatement = formatNode(onFailClauseNode.blockStatement(), env.trailingWS, env.trailingNL); From c3c12aff2219468ec8e6de7758f46e9b303cf40f Mon Sep 17 00:00:00 2001 From: suleka96 Date: Wed, 19 Apr 2023 14:18:53 +0530 Subject: [PATCH 07/33] Skip recovery formatter tests --- .../formatter/core/ParserTestFormatter.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/misc/formatter/modules/formatter-core/src/test/java/org/ballerinalang/formatter/core/ParserTestFormatter.java b/misc/formatter/modules/formatter-core/src/test/java/org/ballerinalang/formatter/core/ParserTestFormatter.java index ac5889f39d75..dc21b39097c8 100644 --- a/misc/formatter/modules/formatter-core/src/test/java/org/ballerinalang/formatter/core/ParserTestFormatter.java +++ b/misc/formatter/modules/formatter-core/src/test/java/org/ballerinalang/formatter/core/ParserTestFormatter.java @@ -182,7 +182,16 @@ public List skipList() { "client_resource_access_action_source_05.bal", "client_resource_access_action_source_06.bal", "resiliency_source_05.bal", "regexp_constructor_source_26.bal", "regexp_constructor_source_28.bal", "regexp_constructor_source_44.bal", "regexp_constructor_source_47.bal", - "regexp_constructor_source_52.bal", "regexp_constructor_source_53.bal", "completion_source_07.bal"); + "regexp_constructor_source_52.bal", "regexp_constructor_source_53.bal", "completion_source_07.bal", + "do_stmt_source_14.bal", "do_stmt_source_15.bal", "do_stmt_source_16.bal", "do_stmt_source_17.bal", + "forEach_stmt_source_31.bal", "foreach_stmt_source_32.bal", "forEach_stmt_source_33.bal", + "foreach_stmt_source_34.bal", "lock_stmt_source_15.bal", "lock_stmt_source_16.bal", "lock_stmt_source_17.bal", + "lock_stmt_source_18.bal", "match_stmt_source_28.bal", "match_stmt_source_29.bal", + "match_stmt_source_30.bal", "match_stmt_source_31.bal", "retry_stmt_source_12.bal", + "retry_stmt_source_13.bal", "retry_stmt_source_14.bal", "retry_stmt_source_15.bal", + "transaction_stmt_source_09.bal", "transaction_stmt_source_10.bal", "transaction_stmt_source_11.bal", + "transaction_stmt_source_12.bal", "while_stmt_source_11.bal", "while_stmt_source_12.bal", + "while_stmt_source_13.bal", "while_stmt_source_14.bal"); } @DataProvider(name = "test-file-provider") From 983e08b7b7ec7d7d5507e133c7a595a76e0a0631 Mon Sep 17 00:00:00 2001 From: suleka96 Date: Wed, 19 Apr 2023 17:05:09 +0530 Subject: [PATCH 08/33] Add nodeBuilder change --- .../compiler/parser/BLangNodeBuilder.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/parser/BLangNodeBuilder.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/parser/BLangNodeBuilder.java index 5574415a2e00..a5fbfb23ba0c 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/parser/BLangNodeBuilder.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/parser/BLangNodeBuilder.java @@ -3921,15 +3921,13 @@ public BLangNode transform(OnFailClauseNode onFailClauseNode) { BLangOnFailClause onFailClause = (BLangOnFailClause) TreeBuilder.createOnFailClauseNode(); onFailClause.pos = pos; onFailClauseNode.typedBindingPattern().ifPresent(typedBindingPatternNode -> { - if (typedBindingPatternNode.bindingPattern().kind() == SyntaxKind.CAPTURE_BINDING_PATTERN) { - VariableDefinitionNode variableDefinitionNode = - createBLangVarDef(getPosition(typedBindingPatternNode), typedBindingPatternNode, - Optional.empty(), Optional.empty()); - onFailClause.isDeclaredWithVar = - typedBindingPatternNode.typeDescriptor().kind() == SyntaxKind.VAR_TYPE_DESC; + VariableDefinitionNode variableDefinitionNode = + createBLangVarDef(getPosition(typedBindingPatternNode), typedBindingPatternNode, + Optional.empty(), Optional.empty()); + onFailClause.isDeclaredWithVar = + typedBindingPatternNode.typeDescriptor().kind() == SyntaxKind.VAR_TYPE_DESC; markVariableWithFlag((BLangVariable) variableDefinitionNode.getVariable(), Flag.FINAL); - onFailClause.variableDefinitionNode = variableDefinitionNode; - } + onFailClause.variableDefinitionNode = variableDefinitionNode; }); BLangBlockStmt blockNode = (BLangBlockStmt) transform(onFailClauseNode.blockStatement()); blockNode.pos = pos; From 8d57c80f19502abf80fe68c31f20925a96be8895 Mon Sep 17 00:00:00 2001 From: suleka96 Date: Wed, 19 Apr 2023 14:55:24 +0530 Subject: [PATCH 09/33] Update column pos for tests --- .../formatter/core/ParserTestFormatter.java | 14 +++++++------- .../test/dataflow/analysis/UnusedVariableTest.java | 2 +- .../test/isolation/IsolatedVariableTest.java | 8 ++++---- .../test/statements/dostatement/DoStmtsTest.java | 12 ++++++------ .../matchstmt/MatchStatementOnFailTest.java | 14 +++++++------- .../retrystmt/RetryStmtWithOnFailTest.java | 14 +++++++------- .../statements/whilestatement/WhileStmtTest.java | 12 ++++++------ ...iableDeclaredWithWithVarIncludingErrorTest.java | 2 +- 8 files changed, 39 insertions(+), 39 deletions(-) diff --git a/misc/formatter/modules/formatter-core/src/test/java/org/ballerinalang/formatter/core/ParserTestFormatter.java b/misc/formatter/modules/formatter-core/src/test/java/org/ballerinalang/formatter/core/ParserTestFormatter.java index dc21b39097c8..523a509bed6c 100644 --- a/misc/formatter/modules/formatter-core/src/test/java/org/ballerinalang/formatter/core/ParserTestFormatter.java +++ b/misc/formatter/modules/formatter-core/src/test/java/org/ballerinalang/formatter/core/ParserTestFormatter.java @@ -185,13 +185,13 @@ public List skipList() { "regexp_constructor_source_52.bal", "regexp_constructor_source_53.bal", "completion_source_07.bal", "do_stmt_source_14.bal", "do_stmt_source_15.bal", "do_stmt_source_16.bal", "do_stmt_source_17.bal", "forEach_stmt_source_31.bal", "foreach_stmt_source_32.bal", "forEach_stmt_source_33.bal", - "foreach_stmt_source_34.bal", "lock_stmt_source_15.bal", "lock_stmt_source_16.bal", "lock_stmt_source_17.bal", - "lock_stmt_source_18.bal", "match_stmt_source_28.bal", "match_stmt_source_29.bal", - "match_stmt_source_30.bal", "match_stmt_source_31.bal", "retry_stmt_source_12.bal", - "retry_stmt_source_13.bal", "retry_stmt_source_14.bal", "retry_stmt_source_15.bal", - "transaction_stmt_source_09.bal", "transaction_stmt_source_10.bal", "transaction_stmt_source_11.bal", - "transaction_stmt_source_12.bal", "while_stmt_source_11.bal", "while_stmt_source_12.bal", - "while_stmt_source_13.bal", "while_stmt_source_14.bal"); + "foreach_stmt_source_34.bal", "lock_stmt_source_15.bal", "lock_stmt_source_16.bal", + "lock_stmt_source_17.bal", "lock_stmt_source_18.bal", "match_stmt_source_28.bal", + "match_stmt_source_29.bal", "match_stmt_source_30.bal", "match_stmt_source_31.bal", + "retry_stmt_source_12.bal", "retry_stmt_source_13.bal", "retry_stmt_source_14.bal", + "retry_stmt_source_15.bal", "transaction_stmt_source_09.bal", "transaction_stmt_source_10.bal", + "transaction_stmt_source_11.bal", "transaction_stmt_source_12.bal", "while_stmt_source_11.bal", + "while_stmt_source_12.bal", "while_stmt_source_13.bal", "while_stmt_source_14.bal"); } @DataProvider(name = "test-file-provider") diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/dataflow/analysis/UnusedVariableTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/dataflow/analysis/UnusedVariableTest.java index 266af25788f0..6ef128910ed3 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/dataflow/analysis/UnusedVariableTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/dataflow/analysis/UnusedVariableTest.java @@ -63,7 +63,7 @@ public void testUnusedVariableAnalysis() { validateWarning(result, i++, getUnusedVariableWarning("m"), 90, 9); validateWarning(result, i++, getUnusedVariableWarning("p"), 96, 9); validateWarning(result, i++, getUnusedVariableWarning("a"), 112, 5); - validateWarning(result, i++, getUnusedVariableWarning("e"), 122, 7); + validateWarning(result, i++, getUnusedVariableWarning("e"), 122, 15); validateWarning(result, i++, getUnusedVariableWarning("i"), 163, 5); validateWarning(result, i++, getUnusedVariableWarning("a"), 171, 5); validateWarning(result, i++, getUnusedVariableWarning("i"), 183, 13); diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/isolation/IsolatedVariableTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/isolation/IsolatedVariableTest.java index 48d442aa1b9d..e1aa40d5c645 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/isolation/IsolatedVariableTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/isolation/IsolatedVariableTest.java @@ -138,16 +138,16 @@ public void testIsolatedVariablesIsolationNegative() { validateError(result, i++, ERROR_INVALID_TRANSFER_OUT_IN_LOCK_WITH_RESTRICTED_VAR_USAGE, 324, 13); validateError(result, i++, ERROR_INVALID_TRANSFER_OUT_IN_LOCK_WITH_RESTRICTED_VAR_USAGE, 325, 16); validateError(result, i++, ERROR_INVALID_TRANSFER_OUT_IN_LOCK_WITH_RESTRICTED_VAR_USAGE, 333, 16); - validateWarning(result, i++, "unused variable 'e'", 342, 7); + validateWarning(result, i++, "unused variable 'e'", 342, 15); validateWarning(result, i++, "unused variable 'k'", 343, 9); validateError(result, i++, ERROR_INVALID_ISOLATED_VAR_ACCESS_OUTSIDE_LOCK, 343, 17); validateWarning(result, i++, "unused variable 'k'", 350, 17); validateError(result, i++, ERROR_INVALID_ISOLATED_VAR_ACCESS_OUTSIDE_LOCK, 354, 9); - validateWarning(result, i++, "unused variable 'e'", 359, 7); + validateWarning(result, i++, "unused variable 'e'", 359, 15); validateError(result, i++, ERROR_INVALID_ISOLATED_VAR_ACCESS_OUTSIDE_LOCK, 360, 9); - validateWarning(result, i++, "unused variable 'e'", 367, 7); + validateWarning(result, i++, "unused variable 'e'", 367, 15); validateError(result, i++, ERROR_INVALID_ISOLATED_VAR_ACCESS_OUTSIDE_LOCK, 368, 9); - validateWarning(result, i++, "unused variable 'e'", 373, 7); + validateWarning(result, i++, "unused variable 'e'", 373, 15); validateError(result, i++, ERROR_INVALID_ISOLATED_VAR_ACCESS_OUTSIDE_LOCK, 374, 9); validateError(result, i++, ERROR_INVALID_ISOLATED_VAR_ACCESS_OUTSIDE_LOCK, 374, 11); Assert.assertEquals(result.getErrorCount(), i - 13); diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/dostatement/DoStmtsTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/dostatement/DoStmtsTest.java index e595fd67054b..f2fc388ff8ef 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/dostatement/DoStmtsTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/dostatement/DoStmtsTest.java @@ -49,17 +49,17 @@ public void testOnFailStatement() { public void testNegative1() { int index = 0; BAssertUtil.validateError(negativeFile1, index++, "unreachable code", 15, 6); - BAssertUtil.validateWarning(negativeFile1, index++, "unused variable 'e'", 17, 4); + BAssertUtil.validateWarning(negativeFile1, index++, "unused variable 'e'", 17, 12); BAssertUtil.validateError(negativeFile1, index++, "incompatible error definition type: " + - "'ErrorTypeA' will not be matched to 'ErrorTypeB'", 30, 4); - BAssertUtil.validateWarning(negativeFile1, index++, "unused variable 'e'", 30, 4); - BAssertUtil.validateWarning(negativeFile1, index++, "unused variable 'e'", 43, 4); - BAssertUtil.validateWarning(negativeFile1, index++, "unused variable 'e'", 57, 4); + "'ErrorTypeA' will not be matched to 'ErrorTypeB'", 30, 12); + BAssertUtil.validateWarning(negativeFile1, index++, "unused variable 'e'", 30, 12); + BAssertUtil.validateWarning(negativeFile1, index++, "unused variable 'e'", 43, 12); + BAssertUtil.validateWarning(negativeFile1, index++, "unused variable 'e'", 57, 12); BAssertUtil.validateError(negativeFile1, index++, "unreachable code", 60, 7); BAssertUtil.validateError(negativeFile1, index++, "unreachable code", 72, 3); BAssertUtil.validateError(negativeFile1, index++, "this function must return a result", 73, 1); BAssertUtil.validateError(negativeFile1, index++, "incompatible error definition type: " + - "'ErrorTypeB' will not be matched to 'ErrorTypeA'", 90, 4); + "'ErrorTypeB' will not be matched to 'ErrorTypeA'", 90, 12); Assert.assertEquals(negativeFile1.getDiagnostics().length, index); } diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/matchstmt/MatchStatementOnFailTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/matchstmt/MatchStatementOnFailTest.java index f3784d96f568..6d7d8717e1bd 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/matchstmt/MatchStatementOnFailTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/matchstmt/MatchStatementOnFailTest.java @@ -75,19 +75,19 @@ public void testVarInMatchPatternWithinOnfail() { public void testNegative1() { int i = -1; BAssertUtil.validateError(resultNegative, ++i, "unreachable code", 29, 14); - BAssertUtil.validateWarning(resultNegative, ++i, "unused variable 'e'", 31, 7); + BAssertUtil.validateWarning(resultNegative, ++i, "unused variable 'e'", 31, 15); BAssertUtil.validateWarning(resultNegative, ++i, "unused variable 'err'", 56, 14); BAssertUtil.validateError(resultNegative, ++i, "incompatible error definition type: " + - "'ErrorTypeA' will not be matched to 'ErrorTypeB'", 59, 7); - BAssertUtil.validateWarning(resultNegative, ++i, "unused variable 'e'", 59, 7); + "'ErrorTypeA' will not be matched to 'ErrorTypeB'", 59, 15); + BAssertUtil.validateWarning(resultNegative, ++i, "unused variable 'e'", 59, 15); BAssertUtil.validateWarning(resultNegative, ++i, "unused variable 'err'", 85, 14); BAssertUtil.validateError(resultNegative, ++i, "incompatible error definition type: " + - "'ErrorTypeA' will not be matched to 'ErrorTypeB'", 88, 7); - BAssertUtil.validateWarning(resultNegative, ++i, "unused variable 'e'", 88, 7); + "'ErrorTypeA' will not be matched to 'ErrorTypeB'", 88, 15); + BAssertUtil.validateWarning(resultNegative, ++i, "unused variable 'e'", 88, 15); BAssertUtil.validateError(resultNegative, ++i, "unreachable code", 90, 9); BAssertUtil.validateError(resultNegative, ++i, "incompatible error definition type: " + - "'ErrorTypeA' will not be matched to 'ErrorTypeB'", 124, 7); - BAssertUtil.validateWarning(resultNegative, ++i, "unused variable 'e'", 124, 7); + "'ErrorTypeA' will not be matched to 'ErrorTypeB'", 124, 15); + BAssertUtil.validateWarning(resultNegative, ++i, "unused variable 'e'", 124, 15); Assert.assertEquals(resultNegative.getDiagnostics().length, i + 1); } diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/retrystmt/RetryStmtWithOnFailTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/retrystmt/RetryStmtWithOnFailTest.java index 7c59ea877800..a48f0b796c95 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/retrystmt/RetryStmtWithOnFailTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/retrystmt/RetryStmtWithOnFailTest.java @@ -49,18 +49,18 @@ public void testRetryStatement() { public void testNegative1() { int index = 0; BAssertUtil.validateError(negativeFile, index++, "unreachable code", 20, 12); - BAssertUtil.validateWarning(negativeFile, index++, "unused variable 'e'", 21, 8); + BAssertUtil.validateWarning(negativeFile, index++, "unused variable 'e'", 21, 16); BAssertUtil.validateError(negativeFile, index++, "incompatible error definition type: " + - "'ErrorTypeA' will not be matched to 'ErrorTypeB'", 32, 6); - BAssertUtil.validateWarning(negativeFile, index++, "unused variable 'e'", 32, 6); - BAssertUtil.validateWarning(negativeFile, index++, "unused variable 'e'", 45, 4); - BAssertUtil.validateWarning(negativeFile, index++, "unused variable 'e'", 59, 4); + "'ErrorTypeA' will not be matched to 'ErrorTypeB'", 32, 14); + BAssertUtil.validateWarning(negativeFile, index++, "unused variable 'e'", 32, 14); + BAssertUtil.validateWarning(negativeFile, index++, "unused variable 'e'", 45, 12); + BAssertUtil.validateWarning(negativeFile, index++, "unused variable 'e'", 59, 12); BAssertUtil.validateError(negativeFile, index++, "unreachable code", 62, 7); - BAssertUtil.validateWarning(negativeFile, index++, "unused variable 'e1'", 78, 4); + BAssertUtil.validateWarning(negativeFile, index++, "unused variable 'e1'", 78, 12); BAssertUtil.validateWarning(negativeFile, index++, "unused variable 'resA'", 97, 6); BAssertUtil.validateWarning(negativeFile, index++, "unused variable 'resB'", 98, 6); BAssertUtil.validateError(negativeFile, index++, "incompatible error definition type: " + - "'ErrorTypeB' will not be matched to 'ErrorTypeA'", 100, 4); + "'ErrorTypeB' will not be matched to 'ErrorTypeA'", 100, 12); Assert.assertEquals(negativeFile.getDiagnostics().length, index); } diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/whilestatement/WhileStmtTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/whilestatement/WhileStmtTest.java index 29af7acdf2b2..85482694d268 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/whilestatement/WhileStmtTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/whilestatement/WhileStmtTest.java @@ -246,16 +246,16 @@ public void testNestedWhileStmtLoopTerminationWithFail() { public void testNegative1() { int index = 0; BAssertUtil.validateError(onfailNegativeCompileResult, index++, "unreachable code", 17, 6); - BAssertUtil.validateWarning(onfailNegativeCompileResult, index++, "unused variable 'e'", 19, 4); + BAssertUtil.validateWarning(onfailNegativeCompileResult, index++, "unused variable 'e'", 19, 12); BAssertUtil.validateError(onfailNegativeCompileResult, index++, "incompatible error definition type: " + - "'ErrorTypeA' will not be matched to 'ErrorTypeB'", 34, 4); - BAssertUtil.validateWarning(onfailNegativeCompileResult, index++, "unused variable 'e'", 34, 4); - BAssertUtil.validateWarning(onfailNegativeCompileResult, index++, "unused variable 'e'", 49, 4); - BAssertUtil.validateWarning(onfailNegativeCompileResult, index++, "unused variable 'e'", 65, 4); + "'ErrorTypeA' will not be matched to 'ErrorTypeB'", 34, 12); + BAssertUtil.validateWarning(onfailNegativeCompileResult, index++, "unused variable 'e'", 34, 12); + BAssertUtil.validateWarning(onfailNegativeCompileResult, index++, "unused variable 'e'", 49, 12); + BAssertUtil.validateWarning(onfailNegativeCompileResult, index++, "unused variable 'e'", 65, 12); BAssertUtil.validateError(onfailNegativeCompileResult, index++, "unreachable code", 68, 7); BAssertUtil.validateError(onfailNegativeCompileResult, index++, "this function must return a result", 83, 1); BAssertUtil.validateError(onfailNegativeCompileResult, index++, "incompatible error definition type: " + - "'ErrorTypeB' will not be matched to 'ErrorTypeA'", 102, 4); + "'ErrorTypeB' will not be matched to 'ErrorTypeA'", 102, 12); BAssertUtil.validateError(onfailNegativeCompileResult, index++, "unreachable code", 116, 9); BAssertUtil.validateError(onfailNegativeCompileResult, index++, "unreachable code", 118, 5); Assert.assertEquals(onfailNegativeCompileResult.getDiagnostics().length, index); diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/types/var/VariableDeclaredWithWithVarIncludingErrorTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/types/var/VariableDeclaredWithWithVarIncludingErrorTest.java index 80ff44f7fc09..f65911a09892 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/types/var/VariableDeclaredWithWithVarIncludingErrorTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/types/var/VariableDeclaredWithWithVarIncludingErrorTest.java @@ -62,7 +62,7 @@ public void testVarWithInferredTypeIncludingErrorNegative() { validateError(negativeResult, index++, getInvalidUnusedVarErrorMessage("e1"), 33, 25); validateWarning(negativeResult, index++, "unused variable 'e2'", 33, 48); validateError(negativeResult, index++, getInvalidUnusedVarErrorMessage("e3"), 33, 76); - validateError(negativeResult, index++, getInvalidUnusedVarErrorMessage("x"), 44, 7); + validateError(negativeResult, index++, getInvalidUnusedVarErrorMessage("x"), 44, 15); assertEquals(index, negativeResult.getDiagnostics().length); } From 0a735b17cc93e5c90f1400c10c0b1bdda86f4aef Mon Sep 17 00:00:00 2001 From: suleka96 Date: Fri, 21 Apr 2023 10:02:25 +0530 Subject: [PATCH 10/33] Add semantic analyzer changes --- .../ballerinalang/util/diagnostic/DiagnosticErrorCode.java | 4 +++- .../compiler/semantics/analyzer/SemanticAnalyzer.java | 5 +++++ .../ballerina-lang/src/main/resources/compiler.properties | 3 +++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/compiler/ballerina-lang/src/main/java/org/ballerinalang/util/diagnostic/DiagnosticErrorCode.java b/compiler/ballerina-lang/src/main/java/org/ballerinalang/util/diagnostic/DiagnosticErrorCode.java index cf1446ee155e..90f1e605e6b5 100644 --- a/compiler/ballerina-lang/src/main/java/org/ballerinalang/util/diagnostic/DiagnosticErrorCode.java +++ b/compiler/ballerina-lang/src/main/java/org/ballerinalang/util/diagnostic/DiagnosticErrorCode.java @@ -799,7 +799,9 @@ public enum DiagnosticErrorCode implements DiagnosticCode { EMPTY_REGEXP_STRING_DISALLOWED( "BCS4044", "empty.regexp.string.disallowed"), UNSUPPORTED_EMPTY_CHARACTER_CLASS( - "BCS4045", "unsupported.empty.character.class") + "BCS4045", "unsupported.empty.character.class"), + + INVALID_BINDING_PATTERN_IN_ON_FAIL("BCS4046", "invalid.binding.pattern.in.on.fail") ; private String diagnosticId; diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SemanticAnalyzer.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SemanticAnalyzer.java index 51c60c80e963..b1403056120a 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SemanticAnalyzer.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SemanticAnalyzer.java @@ -3870,6 +3870,11 @@ public void visit(BLangOnFailClause onFailClause, AnalyzerData data) { SymbolEnv onFailEnv = SymbolEnv.createBlockEnv(onFailClause.body, data.env); VariableDefinitionNode onFailVarDefNode = onFailClause.variableDefinitionNode; if (onFailVarDefNode != null) { + BLangVariable variableNode = (BLangVariable) onFailVarDefNode.getVariable(); + if (variableNode.getKind() != NodeKind.VARIABLE && variableNode.getKind() != NodeKind.ERROR_VARIABLE) { + dlog.error(variableNode.pos, DiagnosticErrorCode.INVALID_BINDING_PATTERN_IN_ON_FAIL); + return; + } // Check on-fail node's variables and set types. handleForeachDefinitionVariables(onFailVarDefNode, symTable.errorType, onFailClause.isDeclaredWithVar, true, onFailEnv); diff --git a/compiler/ballerina-lang/src/main/resources/compiler.properties b/compiler/ballerina-lang/src/main/resources/compiler.properties index aff8578d678e..6dd00b8f0427 100644 --- a/compiler/ballerina-lang/src/main/resources/compiler.properties +++ b/compiler/ballerina-lang/src/main/resources/compiler.properties @@ -1967,3 +1967,6 @@ error.empty.regexp.string.disallowed=\ error.unsupported.empty.character.class=\ empty character class disallowed + +error.invalid.binding.pattern.in.on.fail=\ + invalid binding pattern in ''on fail'' clause: only a capture binding pattern or an error binding pattern is allowed From 18d8ca791b027a43a7c7ead00f71516330fd8a4f Mon Sep 17 00:00:00 2001 From: suleka96 Date: Mon, 24 Apr 2023 05:06:12 +0530 Subject: [PATCH 11/33] Add new bp tests --- .../compiler/parser/BLangNodeBuilder.java | 2 +- .../internal/parser/BallerinaParser.java | 11 + .../syntax/statements/DoStatementTest.java | 65 +- .../statements/ForEachStatementTest.java | 65 +- .../syntax/statements/LockStatementTest.java | 65 +- .../syntax/statements/MatchStatementTest.java | 65 +- .../statements/TransactionStatementTest.java | 149 +- .../syntax/statements/WhileStatementTest.java | 65 +- .../statements/do-stmt/do_stmt_assert_12.json | 247 +- .../statements/do-stmt/do_stmt_assert_13.json | 230 +- .../statements/do-stmt/do_stmt_assert_18.json | 374 +++ .../statements/do-stmt/do_stmt_assert_19.json | 397 +++ .../statements/do-stmt/do_stmt_assert_20.json | 290 ++ .../statements/do-stmt/do_stmt_assert_21.json | 399 +++ .../statements/do-stmt/do_stmt_assert_22.json | 661 ++++ .../statements/do-stmt/do_stmt_assert_23.json | 729 +++++ .../statements/do-stmt/do_stmt_assert_24.json | 891 ++++++ .../statements/do-stmt/do_stmt_assert_25.json | 572 ++++ .../statements/do-stmt/do_stmt_assert_26.json | 377 +++ .../statements/do-stmt/do_stmt_assert_27.json | 377 +++ .../statements/do-stmt/do_stmt_source_12.bal | 5 +- .../statements/do-stmt/do_stmt_source_13.bal | 5 +- .../statements/do-stmt/do_stmt_source_18.bal | 7 + .../statements/do-stmt/do_stmt_source_19.bal | 7 + .../statements/do-stmt/do_stmt_source_20.bal | 6 + .../statements/do-stmt/do_stmt_source_21.bal | 7 + .../statements/do-stmt/do_stmt_source_22.bal | 8 + .../statements/do-stmt/do_stmt_source_23.bal | 8 + .../statements/do-stmt/do_stmt_source_24.bal | 8 + .../statements/do-stmt/do_stmt_source_25.bal | 7 + .../statements/do-stmt/do_stmt_source_26.bal | 7 + .../statements/do-stmt/do_stmt_source_27.bal | 7 + .../forEach-stmt/forEach_stmt_assert_35.json | 432 +++ .../forEach-stmt/forEach_stmt_assert_36.json | 455 +++ .../forEach-stmt/forEach_stmt_assert_37.json | 348 +++ .../forEach-stmt/forEach_stmt_assert_38.json | 457 +++ .../forEach-stmt/forEach_stmt_assert_39.json | 719 +++++ .../forEach-stmt/forEach_stmt_assert_40.json | 787 +++++ .../forEach-stmt/forEach_stmt_assert_41.json | 949 ++++++ .../forEach-stmt/forEach_stmt_assert_42.json | 630 ++++ .../forEach-stmt/forEach_stmt_assert_43.json | 435 +++ .../forEach-stmt/forEach_stmt_assert_44.json | 435 +++ .../forEach-stmt/forEach_stmt_source_29.bal | 5 +- .../forEach-stmt/forEach_stmt_source_30.bal | 5 +- .../forEach-stmt/forEach_stmt_source_35.bal | 7 + .../forEach-stmt/forEach_stmt_source_36.bal | 7 + .../forEach-stmt/forEach_stmt_source_37.bal | 6 + .../forEach-stmt/forEach_stmt_source_38.bal | 7 + .../forEach-stmt/forEach_stmt_source_39.bal | 8 + .../forEach-stmt/forEach_stmt_source_40.bal | 8 + .../forEach-stmt/forEach_stmt_source_41.bal | 8 + .../forEach-stmt/forEach_stmt_source_42.bal | 7 + .../forEach-stmt/forEach_stmt_source_43.bal | 7 + .../forEach-stmt/forEach_stmt_source_44.bal | 7 + .../lock-stmt/lock_stmt_assert_19.json | 374 +++ .../lock-stmt/lock_stmt_assert_20.json | 397 +++ .../lock-stmt/lock_stmt_assert_21.json | 290 ++ .../lock-stmt/lock_stmt_assert_22.json | 399 +++ .../lock-stmt/lock_stmt_assert_23.json | 661 ++++ .../lock-stmt/lock_stmt_assert_24.json | 729 +++++ .../lock-stmt/lock_stmt_assert_25.json | 891 ++++++ .../lock-stmt/lock_stmt_assert_26.json | 572 ++++ .../lock-stmt/lock_stmt_assert_27.json | 377 +++ .../lock-stmt/lock_stmt_assert_38.json | 377 +++ .../lock-stmt/lock_stmt_source_13.bal | 5 +- .../lock-stmt/lock_stmt_source_14.bal | 5 +- .../lock-stmt/lock_stmt_source_19.bal | 7 + .../lock-stmt/lock_stmt_source_20.bal | 7 + .../lock-stmt/lock_stmt_source_21.bal | 6 + .../lock-stmt/lock_stmt_source_22.bal | 7 + .../lock-stmt/lock_stmt_source_23.bal | 8 + .../lock-stmt/lock_stmt_source_24.bal | 8 + .../lock-stmt/lock_stmt_source_25.bal | 8 + .../lock-stmt/lock_stmt_source_26.bal | 7 + .../lock-stmt/lock_stmt_source_27.bal | 7 + .../lock-stmt/lock_stmt_source_28.bal | 7 + .../match-stmt/match_stmt_assert_32.json | 533 ++++ .../match-stmt/match_stmt_assert_33.json | 556 ++++ .../match-stmt/match_stmt_assert_34.json | 449 +++ .../match-stmt/match_stmt_assert_35.json | 558 ++++ .../match-stmt/match_stmt_assert_36.json | 820 +++++ .../match-stmt/match_stmt_assert_37.json | 888 ++++++ .../match-stmt/match_stmt_assert_38.json | 1050 +++++++ .../match-stmt/match_stmt_assert_39.json | 731 +++++ .../match-stmt/match_stmt_assert_40.json | 536 ++++ .../match-stmt/match_stmt_assert_41.json | 536 ++++ .../match-stmt/match_stmt_source_26.bal | 5 +- .../match-stmt/match_stmt_source_27.bal | 5 +- .../match-stmt/match_stmt_source_32.bal | 11 + .../match-stmt/match_stmt_source_33.bal | 11 + .../match-stmt/match_stmt_source_34.bal | 10 + .../match-stmt/match_stmt_source_35.bal | 11 + .../match-stmt/match_stmt_source_36.bal | 12 + .../match-stmt/match_stmt_source_37.bal | 12 + .../match-stmt/match_stmt_source_38.bal | 12 + .../match-stmt/match_stmt_source_39.bal | 11 + .../match-stmt/match_stmt_source_40.bal | 11 + .../match-stmt/match_stmt_source_41.bal | 11 + .../retry_stmt_assert_10.json | 247 +- .../retry_stmt_assert_11.json | 247 +- .../retry_stmt_assert_16.json | 374 +++ .../retry_stmt_assert_17.json | 397 +++ .../retry_stmt_assert_18.json | 290 ++ .../retry_stmt_assert_19.json | 399 +++ .../retry_stmt_assert_20.json | 661 ++++ .../transaction-stmt/retry_stmt_assert_21json | 729 +++++ .../retry_stmt_assert_22.json | 891 ++++++ .../retry_stmt_assert_23.json | 572 ++++ .../retry_stmt_assert_24.json | 377 +++ .../retry_stmt_assert_25.json | 377 +++ .../transaction-stmt/retry_stmt_source_10.bal | 5 +- .../transaction-stmt/retry_stmt_source_11.bal | 5 +- .../transaction-stmt/retry_stmt_source_16.bal | 7 + .../transaction-stmt/retry_stmt_source_17.bal | 7 + .../transaction-stmt/retry_stmt_source_18.bal | 6 + .../transaction-stmt/retry_stmt_source_19.bal | 7 + .../transaction-stmt/retry_stmt_source_20.bal | 8 + .../transaction-stmt/retry_stmt_source_21.bal | 8 + .../transaction-stmt/retry_stmt_source_22.bal | 8 + .../transaction-stmt/retry_stmt_source_23.bal | 7 + .../transaction-stmt/retry_stmt_source_24.bal | 7 + .../transaction-stmt/retry_stmt_source_25.bal | 7 + .../transaction_stmt_assert_07.json | 1256 ++------ .../transaction_stmt_assert_08.json | 1256 ++------ .../transaction_stmt_assert_13.json | 1563 ++++++++++ .../transaction_stmt_assert_14.json | 1678 ++++++++++ .../transaction_stmt_assert_15.json | 1143 +++++++ .../transaction_stmt_assert_16.json | 1688 ++++++++++ .../transaction_stmt_assert_17.json | 2188 +++++++++++++ .../transaction_stmt_assert_18.json | 2358 ++++++++++++++ .../transaction_stmt_assert_19.json | 2763 +++++++++++++++++ .../transaction_stmt_assert_20.json | 2008 ++++++++++++ .../transaction_stmt_assert_21.json | 1578 ++++++++++ .../transaction_stmt_assert_22.json | 1578 ++++++++++ .../transaction_stmt_source_07.bal | 25 +- .../transaction_stmt_source_08.bal | 25 +- .../transaction_stmt_source_13.bal | 34 + .../transaction_stmt_source_14.bal | 34 + .../transaction_stmt_source_15.bal | 29 + .../transaction_stmt_source_16.bal | 34 + .../transaction_stmt_source_17.bal | 34 + .../transaction_stmt_source_18.bal | 34 + .../transaction_stmt_source_19.bal | 34 + .../transaction_stmt_source_20.bal | 34 + .../transaction_stmt_source_21.bal | 34 + .../transaction_stmt_source_22.bal | 34 + .../while-stmt/while_stmt_assert_15.json | 576 ++++ .../while-stmt/while_stmt_assert_16.json | 599 ++++ .../while-stmt/while_stmt_assert_17.json | 492 +++ .../while-stmt/while_stmt_assert_18.json | 601 ++++ .../while-stmt/while_stmt_assert_19.json | 863 +++++ .../while-stmt/while_stmt_assert_20.json | 931 ++++++ .../while-stmt/while_stmt_assert_21.json | 1093 +++++++ .../while-stmt/while_stmt_assert_22.json | 774 +++++ .../while-stmt/while_stmt_assert_23.json | 579 ++++ .../while-stmt/while_stmt_assert_24.json | 579 ++++ .../while-stmt/while_stmt_source_09.bal | 5 +- .../while-stmt/while_stmt_source_10.bal | 5 +- .../while-stmt/while_stmt_source_15.bal | 9 + .../while-stmt/while_stmt_source_16.bal | 9 + .../while-stmt/while_stmt_source_17.bal | 8 + .../while-stmt/while_stmt_source_18.bal | 9 + .../while-stmt/while_stmt_source_19.bal | 10 + .../while-stmt/while_stmt_source_20.bal | 10 + .../while-stmt/while_stmt_source_21.bal | 10 + .../while-stmt/while_stmt_source_22.bal | 9 + .../while-stmt/while_stmt_source_23.bal | 9 + .../while-stmt/while_stmt_source_24.bal | 9 + 168 files changed, 54926 insertions(+), 3118 deletions(-) create mode 100644 compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_18.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_19.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_20.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_21.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_22.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_23.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_24.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_25.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_26.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_27.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_18.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_19.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_20.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_21.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_22.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_23.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_24.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_25.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_26.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_27.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_35.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_36.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_37.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_38.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_39.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_40.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_41.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_42.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_43.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_44.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_35.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_36.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_37.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_38.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_39.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_40.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_41.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_42.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_43.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_44.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_19.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_20.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_21.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_22.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_23.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_24.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_25.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_26.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_27.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_38.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_19.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_20.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_21.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_22.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_23.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_24.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_25.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_26.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_27.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_28.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_32.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_33.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_34.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_35.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_36.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_37.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_38.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_39.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_40.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_41.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_32.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_33.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_34.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_35.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_36.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_37.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_38.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_39.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_40.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_41.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_16.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_17.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_18.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_19.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_20.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_21json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_22.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_23.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_24.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_25.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_16.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_17.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_18.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_19.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_20.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_21.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_22.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_23.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_24.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_25.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_13.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_14.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_15.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_16.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_17.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_18.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_19.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_20.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_21.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_22.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_13.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_14.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_15.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_16.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_17.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_18.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_19.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_20.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_21.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_22.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_15.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_16.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_17.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_18.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_19.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_20.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_21.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_22.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_23.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_24.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_15.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_16.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_17.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_18.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_19.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_20.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_21.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_22.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_23.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_24.bal diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/parser/BLangNodeBuilder.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/parser/BLangNodeBuilder.java index 0768132de9a3..0ae450b4ad5e 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/parser/BLangNodeBuilder.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/parser/BLangNodeBuilder.java @@ -3921,7 +3921,7 @@ public BLangNode transform(OnFailClauseNode onFailClauseNode) { Optional.empty(), Optional.empty()); onFailClause.isDeclaredWithVar = typedBindingPatternNode.typeDescriptor().kind() == SyntaxKind.VAR_TYPE_DESC; - markVariableWithFlag((BLangVariable) variableDefinitionNode.getVariable(), Flag.FINAL); + markVariableWithFlag((BLangVariable) variableDefinitionNode.getVariable(), Flag.FINAL); onFailClause.variableDefinitionNode = variableDefinitionNode; } }); diff --git a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/BallerinaParser.java b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/BallerinaParser.java index 4681e60cd126..fc252f4368ca 100644 --- a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/BallerinaParser.java +++ b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/BallerinaParser.java @@ -13853,6 +13853,17 @@ private STNode parseOnFailClause() { blockStatement); } + /** + * Parse typed binding pattern. + *

+ * + * typed-binding-pattern := inferable-type-descriptor binding-pattern + *
+ * inferable-type-descriptor := type-descriptor | var + *
+ * + * @return Typed binding pattern node + */ private STNode parseTypedBindingPattern() { STNode typeDescriptor = parseTypeDescriptor(ParserRuleContext.TYPE_DESC_IN_TYPE_BINDING_PATTERN, true, false, TypePrecedence.DEFAULT); diff --git a/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/DoStatementTest.java b/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/DoStatementTest.java index fe43c959581e..10d9ad6d567e 100644 --- a/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/DoStatementTest.java +++ b/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/DoStatementTest.java @@ -17,6 +17,7 @@ */ package io.ballerinalang.compiler.parser.test.syntax.statements; +import org.testng.annotations.DataProvider; import org.testng.annotations.Test; /** @@ -67,6 +68,49 @@ public void testDoWithOnFailClauseHavingErrorBPWithUserDefinedErrorWithVar() { testFile("do-stmt/do_stmt_source_13.bal", "do-stmt/do_stmt_assert_13.json"); } + @DataProvider(name = "onFailClauseOtherBPTestDataProvider") + public Object[][] onFailClauseOtherBPTestDataProvider() { + return new Object[][]{ + {"do-stmt/do_stmt_source_18.bal", "do-stmt/do_stmt_assert_18.json"}, + {"do-stmt/do_stmt_source_19.bal", "do-stmt/do_stmt_assert_19.json"}, + {"do-stmt/do_stmt_source_20.bal", "do-stmt/do_stmt_assert_20.json"}, + {"do-stmt/do_stmt_source_21.bal", "do-stmt/do_stmt_assert_21.json"} + }; + } + + @Test(dataProvider = "onFailClauseOtherBPTestDataProvider") + public void testDoOnFailClauseWithOtherBP(String sourceFile, String assertFile) { + testFile(sourceFile, assertFile); + } + + @DataProvider(name = "onFailClauseErrorBPWithFieldBPTestDataProvider") + public Object[][] onFailClauseErrorBPWithFieldBPTestDataProvider() { + return new Object[][]{ + {"do-stmt/do_stmt_source_22.bal", "do-stmt/do_stmt_assert_22.json"}, + {"do-stmt/do_stmt_source_23.bal", "do-stmt/do_stmt_assert_23.json"}, + {"do-stmt/do_stmt_source_24.bal", "do-stmt/do_stmt_assert_24.json"} + }; + } + + @Test(dataProvider = "onFailClauseErrorBPWithFieldBPTestDataProvider") + public void testDoOnFailClausHavingErrorBPWithFieldBP(String sourceFile, String assertFile) { + testFile(sourceFile, assertFile); + } + + @DataProvider(name = "onFailClauseErrorBPWithOtherTypeDescTestDataProvider") + public Object[][] onFailClauseErrorBPWithOtherTypeDescTestDataProvider() { + return new Object[][]{ + {"do-stmt/do_stmt_source_25.bal", "do-stmt/do_stmt_assert_25.json"}, + {"do-stmt/do_stmt_source_26.bal", "do-stmt/do_stmt_assert_26.json"}, + {"do-stmt/do_stmt_source_27.bal", "do-stmt/do_stmt_assert_27.json"} + }; + } + + @Test(dataProvider = "onFailClauseErrorBPWithOtherTypeDescTestDataProvider") + public void testDoOnFailClausHavingErrorBPWithOtherTypeDesc(String sourceFile, String assertFile) { + testFile(sourceFile, assertFile); + } + // Recovery test @Test @@ -75,13 +119,20 @@ public void testDoWithMissingOpenCloseBraces() { testFile("do-stmt/do_stmt_source_05.bal", "do-stmt/do_stmt_assert_05.json"); } - @Test - public void testDoOnFailClauseRecovery() { - testFile("do-stmt/do_stmt_source_06.bal", "do-stmt/do_stmt_assert_06.json"); - testFile("do-stmt/do_stmt_source_14.bal", "do-stmt/do_stmt_assert_14.json"); - testFile("do-stmt/do_stmt_source_15.bal", "do-stmt/do_stmt_assert_15.json"); - testFile("do-stmt/do_stmt_source_16.bal", "do-stmt/do_stmt_assert_16.json"); - testFile("do-stmt/do_stmt_source_17.bal", "do-stmt/do_stmt_assert_17.json"); + @DataProvider(name = "onFailClauseRecoveryTestDataProvider") + public Object[][] onFailClauseRecoveryTestDataProvider() { + return new Object[][]{ + {"do-stmt/do_stmt_source_06.bal", "do-stmt/do_stmt_assert_06.json"}, + {"do-stmt/do_stmt_source_14.bal", "do-stmt/do_stmt_assert_14.json"}, + {"do-stmt/do_stmt_source_15.bal", "do-stmt/do_stmt_assert_15.json"}, + {"do-stmt/do_stmt_source_16.bal", "do-stmt/do_stmt_assert_16.json"}, + {"do-stmt/do_stmt_source_17.bal", "do-stmt/do_stmt_assert_17.json"} + }; + } + + @Test(dataProvider = "onFailClauseRecoveryTestDataProvider") + public void testDoOnFailClauseRecovery(String sourceFile, String assertFile) { + testFile(sourceFile, assertFile); } @Test diff --git a/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/ForEachStatementTest.java b/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/ForEachStatementTest.java index 7fc906c6f0d3..8084bc710ad5 100644 --- a/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/ForEachStatementTest.java +++ b/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/ForEachStatementTest.java @@ -17,6 +17,7 @@ */ package io.ballerinalang.compiler.parser.test.syntax.statements; +import org.testng.annotations.DataProvider; import org.testng.annotations.Test; /** @@ -112,6 +113,49 @@ public void testForEachWithOnFailClauseHavingErrorBPWithUserDefinedErrorWithVar( testFile("forEach-stmt/forEach_stmt_source_30.bal", "forEach-stmt/forEach_stmt_assert_30.json"); } + @DataProvider(name = "onFailClauseOtherBPTestDataProvider") + public Object[][] onFailClauseOtherBPTestDataProvider() { + return new Object[][]{ + {"forEach-stmt/forEach_stmt_source_35.bal", "forEach-stmt/forEach_stmt_assert_35.json"}, + {"forEach-stmt/forEach_stmt_source_36.bal", "forEach-stmt/forEach_stmt_assert_36.json"}, + {"forEach-stmt/forEach_stmt_source_37.bal", "forEach-stmt/forEach_stmt_assert_37.json"}, + {"forEach-stmt/forEach_stmt_source_38.bal", "forEach-stmt/forEach_stmt_assert_38.json"} + }; + } + + @Test(dataProvider = "onFailClauseOtherBPTestDataProvider") + public void testForEachOnFailClauseWithOtherBP(String sourceFile, String assertFile) { + testFile(sourceFile, assertFile); + } + + @DataProvider(name = "onFailClauseErrorBPWithFieldBPTestDataProvider") + public Object[][] onFailClauseErrorBPWithFieldBPTestDataProvider() { + return new Object[][]{ + {"forEach-stmt/forEach_stmt_source_39.bal", "forEach-stmt/forEach_stmt_assert_39.json"}, + {"forEach-stmt/forEach_stmt_source_40.bal", "forEach-stmt/forEach_stmt_assert_40.json"}, + {"forEach-stmt/forEach_stmt_source_41.bal", "forEach-stmt/forEach_stmt_assert_41.json"} + }; + } + + @Test(dataProvider = "onFailClauseErrorBPWithFieldBPTestDataProvider") + public void testForEachOnFailClausHavingErrorBPWithFieldBP(String sourceFile, String assertFile) { + testFile(sourceFile, assertFile); + } + + @DataProvider(name = "onFailClauseErrorBPWithOtherTypeDescTestDataProvider") + public Object[][] onFailClauseErrorBPWithOtherTypeDescTestDataProvider() { + return new Object[][]{ + {"forEach-stmt/forEach_stmt_source_42.bal", "forEach-stmt/forEach_stmt_assert_42.json"}, + {"forEach-stmt/forEach_stmt_source_43.bal", "forEach-stmt/forEach_stmt_assert_43.json"}, + {"forEach-stmt/forEach_stmt_source_44.bal", "forEach-stmt/forEach_stmt_assert_44.json"} + }; + } + + @Test(dataProvider = "onFailClauseErrorBPWithOtherTypeDescTestDataProvider") + public void testForEachOnFailClausHavingErrorBPWithOtherTypeDesc(String sourceFile, String assertFile) { + testFile(sourceFile, assertFile); + } + // Recovery tests @Test @@ -198,12 +242,19 @@ public void testMappingBindingPatternMissingCloseBraceForEachStmt() { "forEach-stmt/forEach_stmt_assert_23.json"); } - @Test - public void testForEachOnFailClauseRecovery() { - testFile("forEach-stmt/forEach_stmt_source_25.bal", "forEach-stmt/forEach_stmt_assert_25.json"); - testFile("forEach-stmt/forEach_stmt_source_31.bal", "forEach-stmt/forEach_stmt_assert_31.json"); - testFile("forEach-stmt/forEach_stmt_source_32.bal", "forEach-stmt/forEach_stmt_assert_32.json"); - testFile("forEach-stmt/forEach_stmt_source_33.bal", "forEach-stmt/forEach_stmt_assert_33.json"); - testFile("forEach-stmt/forEach_stmt_source_34.bal", "forEach-stmt/forEach_stmt_assert_34.json"); + @DataProvider(name = "onFailClauseRecoveryTestDataProvider") + public Object[][] onFailClauseRecoveryTestDataProvider() { + return new Object[][]{ + {"forEach-stmt/forEach_stmt_source_25.bal", "forEach-stmt/forEach_stmt_assert_25.json"}, + {"forEach-stmt/forEach_stmt_source_31.bal", "forEach-stmt/forEach_stmt_assert_31.json"}, + {"forEach-stmt/forEach_stmt_source_32.bal", "forEach-stmt/forEach_stmt_assert_32.json"}, + {"forEach-stmt/forEach_stmt_source_33.bal", "forEach-stmt/forEach_stmt_assert_33.json"}, + {"forEach-stmt/forEach_stmt_source_34.bal", "forEach-stmt/forEach_stmt_assert_34.json"} + }; + } + + @Test(dataProvider = "onFailClauseRecoveryTestDataProvider") + public void testForEachOnFailClauseRecovery(String sourceFile, String assertFile) { + testFile(sourceFile, assertFile); } } diff --git a/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/LockStatementTest.java b/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/LockStatementTest.java index a51a478d2fc5..ddda9c0b0ef6 100644 --- a/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/LockStatementTest.java +++ b/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/LockStatementTest.java @@ -17,6 +17,7 @@ */ package io.ballerinalang.compiler.parser.test.syntax.statements; +import org.testng.annotations.DataProvider; import org.testng.annotations.Test; /** @@ -76,6 +77,49 @@ public void testLockWithOnFailClauseHavingErrorBPWithUserDefinedErrorWithVar() { "lock-stmt/lock_stmt_assert_14.json"); } + @DataProvider(name = "onFailClauseOtherBPTestDataProvider") + public Object[][] onFailClauseOtherBPTestDataProvider() { + return new Object[][]{ + {"lock-stmt/lock_stmt_source_19.bal", "lock-stmt/lock_stmt_assert_19.json"}, + {"lock-stmt/lock_stmt_source_20.bal", "lock-stmt/lock_stmt_assert_20.json"}, + {"lock-stmt/lock_stmt_source_21.bal", "lock-stmt/lock_stmt_assert_21.json"}, + {"lock-stmt/lock_stmt_source_22.bal", "lock-stmt/lock_stmt_assert_22.json"} + }; + } + + @Test(dataProvider = "onFailClauseOtherBPTestDataProvider") + public void testLockOnFailClauseWithOtherBP(String sourceFile, String assertFile) { + testFile(sourceFile, assertFile); + } + + @DataProvider(name = "onFailClauseErrorBPWithFieldBPTestDataProvider") + public Object[][] onFailClauseErrorBPWithFieldBPTestDataProvider() { + return new Object[][]{ + {"lock-stmt/lock_stmt_source_23.bal", "lock-stmt/lock_stmt_assert_23.json"}, + {"lock-stmt/lock_stmt_source_24.bal", "lock-stmt/lock_stmt_assert_24.json"}, + {"lock-stmt/lock_stmt_source_25.bal", "lock-stmt/lock_stmt_assert_25.json"} + }; + } + + @Test(dataProvider = "onFailClauseErrorBPWithFieldBPTestDataProvider") + public void testLockOnFailClausHavingErrorBPWithFieldBP(String sourceFile, String assertFile) { + testFile(sourceFile, assertFile); + } + + @DataProvider(name = "onFailClauseErrorBPWithOtherTypeDescTestDataProvider") + public Object[][] onFailClauseErrorBPWithOtherTypeDescTestDataProvider() { + return new Object[][]{ + {"lock-stmt/lock_stmt_source_26.bal", "lock-stmt/lock_stmt_assert_26.json"}, + {"lock-stmt/lock_stmt_source_27.bal", "lock-stmt/lock_stmt_assert_27.json"}, + {"lock-stmt/lock_stmt_source_28.bal", "lock-stmt/lock_stmt_assert_38.json"} + }; + } + + @Test(dataProvider = "onFailClauseErrorBPWithOtherTypeDescTestDataProvider") + public void testLockOnFailClausHavingErrorBPWithOtherTypeDesc(String sourceFile, String assertFile) { + testFile(sourceFile, assertFile); + } + // Recovery tests @Test @@ -102,12 +146,19 @@ public void testMissingCloseBrace() { "lock-stmt/lock_stmt_assert_07.json"); } - @Test - public void testLockOnFailClauseRecovery() { - testFile("lock-stmt/lock_stmt_source_09.bal", "lock-stmt/lock_stmt_assert_09.json"); - testFile("lock-stmt/lock_stmt_source_15.bal", "lock-stmt/lock_stmt_assert_15.json"); - testFile("lock-stmt/lock_stmt_source_16.bal", "lock-stmt/lock_stmt_assert_16.json"); - testFile("lock-stmt/lock_stmt_source_17.bal", "lock-stmt/lock_stmt_assert_17.json"); - testFile("lock-stmt/lock_stmt_source_18.bal", "lock-stmt/lock_stmt_assert_18.json"); + @DataProvider(name = "onFailClauseRecoveryTestDataProvider") + public Object[][] onFailClauseRecoveryTestDataProvider() { + return new Object[][]{ + {"lock-stmt/lock_stmt_source_09.bal", "lock-stmt/lock_stmt_assert_09.json"}, + {"lock-stmt/lock_stmt_source_15.bal", "lock-stmt/lock_stmt_assert_15.json"}, + {"lock-stmt/lock_stmt_source_16.bal", "lock-stmt/lock_stmt_assert_16.json"}, + {"lock-stmt/lock_stmt_source_17.bal", "lock-stmt/lock_stmt_assert_17.json"}, + {"lock-stmt/lock_stmt_source_18.bal", "lock-stmt/lock_stmt_assert_18.json"} + }; + } + + @Test(dataProvider = "onFailClauseRecoveryTestDataProvider") + public void testLockOnFailClauseRecovery(String sourceFile, String assertFile) { + testFile(sourceFile, assertFile); } } diff --git a/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/MatchStatementTest.java b/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/MatchStatementTest.java index 5e509859fe54..65cab54693ba 100644 --- a/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/MatchStatementTest.java +++ b/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/MatchStatementTest.java @@ -17,6 +17,7 @@ */ package io.ballerinalang.compiler.parser.test.syntax.statements; +import org.testng.annotations.DataProvider; import org.testng.annotations.Test; /** @@ -93,6 +94,49 @@ public void testSimpleMatchStatementWithOnFailClauseHavingErrorBPWithUserDefined testFile("match-stmt/match_stmt_source_27.bal", "match-stmt/match_stmt_assert_27.json"); } + @DataProvider(name = "onFailClauseOtherBPTestDataProvider") + public Object[][] onFailClauseOtherBPTestDataProvider() { + return new Object[][]{ + {"match-stmt/match_stmt_source_32.bal", "match-stmt/match_stmt_assert_32.json"}, + {"match-stmt/match_stmt_source_33.bal", "match-stmt/match_stmt_assert_33.json"}, + {"match-stmt/match_stmt_source_34.bal", "match-stmt/match_stmt_assert_34.json"}, + {"match-stmt/match_stmt_source_35.bal", "match-stmt/match_stmt_assert_35.json"} + }; + } + + @Test(dataProvider = "onFailClauseOtherBPTestDataProvider") + public void testMatchStmtOnFailClauseWithOtherBP(String sourceFile, String assertFile) { + testFile(sourceFile, assertFile); + } + + @DataProvider(name = "onFailClauseErrorBPWithFieldBPTestDataProvider") + public Object[][] onFailClauseErrorBPWithFieldBPTestDataProvider() { + return new Object[][]{ + {"match-stmt/match_stmt_source_36.bal", "match-stmt/match_stmt_assert_36.json"}, + {"match-stmt/match_stmt_source_37.bal", "match-stmt/match_stmt_assert_37.json"}, + {"match-stmt/match_stmt_source_38.bal", "match-stmt/match_stmt_assert_38.json"} + }; + } + + @Test(dataProvider = "onFailClauseErrorBPWithFieldBPTestDataProvider") + public void testMatchStmtOnFailClausHavingErrorBPWithFieldBP(String sourceFile, String assertFile) { + testFile(sourceFile, assertFile); + } + + @DataProvider(name = "onFailClauseErrorBPWithOtherTypeDescTestDataProvider") + public Object[][] onFailClauseErrorBPWithOtherTypeDescTestDataProvider() { + return new Object[][]{ + {"match-stmt/match_stmt_source_39.bal", "match-stmt/match_stmt_assert_39.json"}, + {"match-stmt/match_stmt_source_40.bal", "match-stmt/match_stmt_assert_40.json"}, + {"match-stmt/match_stmt_source_41.bal", "match-stmt/match_stmt_assert_41.json"} + }; + } + + @Test(dataProvider = "onFailClauseErrorBPWithOtherTypeDescTestDataProvider") + public void testMatchStmtOnFailClausHavingErrorBPWithOtherTypeDesc(String sourceFile, String assertFile) { + testFile(sourceFile, assertFile); + } + // Recovery tests @Test @@ -132,13 +176,20 @@ public void testMatchStmtRecoveryInvalidErrorMatchPatterns() { testFile("match-stmt/match_stmt_source_13.bal", "match-stmt/match_stmt_assert_13.json"); } - @Test - public void testMatchStatementOnFailClauseRecovery() { - testFile("match-stmt/match_stmt_source_15.bal", "match-stmt/match_stmt_assert_15.json"); - testFile("match-stmt/match_stmt_source_28.bal", "match-stmt/match_stmt_assert_28.json"); - testFile("match-stmt/match_stmt_source_29.bal", "match-stmt/match_stmt_assert_29.json"); - testFile("match-stmt/match_stmt_source_30.bal", "match-stmt/match_stmt_assert_30.json"); - testFile("match-stmt/match_stmt_source_31.bal", "match-stmt/match_stmt_assert_31.json"); + @DataProvider(name = "onFailClauseRecoveryTestDataProvider") + public Object[][] onFailClauseRecoveryTestDataProvider() { + return new Object[][]{ + {"match-stmt/match_stmt_source_15.bal", "match-stmt/match_stmt_assert_15.json"}, + {"match-stmt/match_stmt_source_28.bal", "match-stmt/match_stmt_assert_28.json"}, + {"match-stmt/match_stmt_source_29.bal", "match-stmt/match_stmt_assert_29.json"}, + {"match-stmt/match_stmt_source_30.bal", "match-stmt/match_stmt_assert_30.json"}, + {"match-stmt/match_stmt_source_31.bal", "match-stmt/match_stmt_assert_31.json"} + }; + } + + @Test(dataProvider = "onFailClauseRecoveryTestDataProvider") + public void testMatchStatementOnFailClauseRecovery(String sourceFile, String assertFile) { + testFile(sourceFile, assertFile); } @Test diff --git a/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/TransactionStatementTest.java b/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/TransactionStatementTest.java index 7ab7f3267683..ceb223849ea2 100644 --- a/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/TransactionStatementTest.java +++ b/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/TransactionStatementTest.java @@ -17,6 +17,7 @@ */ package io.ballerinalang.compiler.parser.test.syntax.statements; +import org.testng.annotations.DataProvider; import org.testng.annotations.Test; /** @@ -117,6 +118,112 @@ public void testTransactionalWorker() { "transaction-stmt/transactional_worker_assert_01.json"); } + @DataProvider(name = "retryOnFailClauseOtherBPTestDataProvider") + public Object[][] retryOnFailClauseOtherBPTestDataProvider() { + return new Object[][]{ + {"transaction-stmt/retry_stmt_source_16.bal", + "transaction-stmt/retry_stmt_assert_16.json"}, + {"transaction-stmt/retry_stmt_source_17.bal", + "transaction-stmt/retry_stmt_assert_17.json"}, + {"transaction-stmt/retry_stmt_source_18.bal", + "transaction-stmt/retry_stmt_assert_18.json"}, + {"transaction-stmt/retry_stmt_source_19.bal", + "transaction-stmt/retry_stmt_assert_19.json"} + }; + } + + @Test(dataProvider = "retryOnFailClauseOtherBPTestDataProvider") + public void testRetryOnFailClauseWithOtherBP(String sourceFile, String assertFile) { + testFile(sourceFile, assertFile); + } + + @DataProvider(name = "retryOnFailClauseErrorBPWithFieldBPTestDataProvider") + public Object[][] retryOnFailClauseErrorBPWithFieldBPTestDataProvider() { + return new Object[][]{ + {"transaction-stmt/retry_stmt_source_20.bal", + "transaction-stmt/retry_stmt_assert_20.json"}, + {"transaction-stmt/retry_stmt_source_21.bal", + "transaction-stmt/retry_stmt_assert_21json"}, + {"transaction-stmt/retry_stmt_source_22.bal", + "transaction-stmt/retry_stmt_assert_22.json"} + }; + } + + @Test(dataProvider = "retryOnFailClauseErrorBPWithFieldBPTestDataProvider") + public void testRetryOnFailClausHavingErrorBPWithFieldBP(String sourceFile, String assertFile) { + testFile(sourceFile, assertFile); + } + + @DataProvider(name = "retryOnFailClauseErrorBPWithOtherTypeDescTestDataProvider") + public Object[][] retryOnFailClauseErrorBPWithOtherTypeDescTestDataProvider() { + return new Object[][]{ + {"transaction-stmt/retry_stmt_source_23.bal", + "transaction-stmt/retry_stmt_assert_23.json"}, + {"transaction-stmt/retry_stmt_source_24.bal", + "transaction-stmt/retry_stmt_assert_24.json"}, + {"transaction-stmt/retry_stmt_source_25.bal", + "transaction-stmt/retry_stmt_assert_25.json"} + }; + } + + @Test(dataProvider = "retryOnFailClauseErrorBPWithOtherTypeDescTestDataProvider") + public void testRetryOnFailClausHavingErrorBPWithOtherTypeDesc(String sourceFile, String assertFile) { + testFile(sourceFile, assertFile); + } + + @DataProvider(name = "transactionOnFailClauseOtherBPTestDataProvider") + public Object[][] transactionOnFailClauseOtherBPTestDataProvider() { + return new Object[][]{ + {"transaction-stmt/transaction_stmt_source_13.bal", + "transaction-stmt/transaction_stmt_assert_13.json"}, + {"transaction-stmt/transaction_stmt_source_14.bal", + "transaction-stmt/transaction_stmt_assert_14.json"}, + {"transaction-stmt/transaction_stmt_source_15.bal", + "transaction-stmt/transaction_stmt_assert_15.json"}, + {"transaction-stmt/transaction_stmt_source_16.bal", + "transaction-stmt/transaction_stmt_assert_16.json"} + }; + } + + @Test(dataProvider = "transactionOnFailClauseOtherBPTestDataProvider") + public void testTransactionOnFailClauseWithOtherBP(String sourceFile, String assertFile) { + testFile(sourceFile, assertFile); + } + + @DataProvider(name = "transactionOnFailClauseErrorBPWithFieldBPTestDataProvider") + public Object[][] transactionOnFailClauseErrorBPWithFieldBPTestDataProvider() { + return new Object[][]{ + {"transaction-stmt/transaction_stmt_source_17.bal", + "transaction-stmt/transaction_stmt_assert_17.json"}, + {"transaction-stmt/transaction_stmt_source_18.bal", + "transaction-stmt/transaction_stmt_assert_18.json"}, + {"transaction-stmt/transaction_stmt_source_19.bal", + "transaction-stmt/transaction_stmt_assert_19.json"} + }; + } + + @Test(dataProvider = "transactionOnFailClauseErrorBPWithFieldBPTestDataProvider") + public void testTransactionOnFailClausHavingErrorBPWithFieldBP(String sourceFile, String assertFile) { + testFile(sourceFile, assertFile); + } + + @DataProvider(name = "transactionOnFailClauseErrorBPWithOtherTypeDescTestDataProvider") + public Object[][] transactionOnFailClauseErrorBPWithOtherTypeDescTestDataProvider() { + return new Object[][]{ + {"transaction-stmt/transaction_stmt_source_20.bal", + "transaction-stmt/transaction_stmt_assert_20.json"}, + {"transaction-stmt/transaction_stmt_source_21.bal", + "transaction-stmt/transaction_stmt_assert_21.json"}, + {"transaction-stmt/transaction_stmt_source_22.bal", + "transaction-stmt/transaction_stmt_assert_22.json"} + }; + } + + @Test(dataProvider = "transactionOnFailClauseErrorBPWithOtherTypeDescTestDataProvider") + public void testTransactionOnFailClausHavingErrorBPWithOtherTypeDesc(String sourceFile, String assertFile) { + testFile(sourceFile, assertFile); + } + // Recovery tests @Test @@ -139,21 +246,35 @@ public void testRetryTransactionStatementRecovery() { testFile("transaction-stmt/retry_stmt_source_04.bal", "transaction-stmt/retry_stmt_assert_04.json"); } - @Test - public void testTransactionOnFailClauseRecovery() { - testFile("transaction-stmt/transaction_stmt_source_04.bal", "transaction-stmt/transaction_stmt_assert_04.json"); - testFile("transaction-stmt/transaction_stmt_source_09.bal", "transaction-stmt/transaction_stmt_assert_09.json"); - testFile("transaction-stmt/transaction_stmt_source_10.bal", "transaction-stmt/transaction_stmt_assert_10.json"); - testFile("transaction-stmt/transaction_stmt_source_11.bal", "transaction-stmt/transaction_stmt_assert_11.json"); - testFile("transaction-stmt/transaction_stmt_source_12.bal", "transaction-stmt/transaction_stmt_assert_12.json"); + @DataProvider(name = "transactionOnFailClauseRecoveryTestDataProvider") + public Object[][] transactionOnFailClauseRecoveryTestDataProvider() { + return new Object[][]{ + {"transaction-stmt/transaction_stmt_source_04.bal", "transaction-stmt/transaction_stmt_assert_04.json"}, + {"transaction-stmt/transaction_stmt_source_09.bal", "transaction-stmt/transaction_stmt_assert_09.json"}, + {"transaction-stmt/transaction_stmt_source_10.bal", "transaction-stmt/transaction_stmt_assert_10.json"}, + {"transaction-stmt/transaction_stmt_source_11.bal", "transaction-stmt/transaction_stmt_assert_11.json"}, + {"transaction-stmt/transaction_stmt_source_12.bal", "transaction-stmt/transaction_stmt_assert_12.json"} + }; } - @Test - public void testRetryOnFailClauseRecovery() { - testFile("transaction-stmt/retry_stmt_source_06.bal", "transaction-stmt/retry_stmt_assert_06.json"); - testFile("transaction-stmt/retry_stmt_source_12.bal", "transaction-stmt/retry_stmt_assert_12.json"); - testFile("transaction-stmt/retry_stmt_source_13.bal", "transaction-stmt/retry_stmt_assert_13.json"); - testFile("transaction-stmt/retry_stmt_source_14.bal", "transaction-stmt/retry_stmt_assert_14.json"); - testFile("transaction-stmt/retry_stmt_source_15.bal", "transaction-stmt/retry_stmt_assert_15.json"); + @Test(dataProvider = "transactionOnFailClauseRecoveryTestDataProvider") + public void testTransactionOnFailClauseRecovery(String sourceFile, String assertFile) { + testFile(sourceFile, assertFile); + } + + @DataProvider(name = "retryOnFailClauseRecoveryTestDataProvider") + public Object[][] retryOnFailClauseRecoveryTestDataProvider() { + return new Object[][]{ + {"transaction-stmt/retry_stmt_source_06.bal", "transaction-stmt/retry_stmt_assert_06.json"}, + {"transaction-stmt/retry_stmt_source_12.bal", "transaction-stmt/retry_stmt_assert_12.json"}, + {"transaction-stmt/retry_stmt_source_13.bal", "transaction-stmt/retry_stmt_assert_13.json"}, + {"transaction-stmt/retry_stmt_source_14.bal", "transaction-stmt/retry_stmt_assert_14.json"}, + {"transaction-stmt/retry_stmt_source_15.bal", "transaction-stmt/retry_stmt_assert_15.json"} + }; + } + + @Test(dataProvider = "retryOnFailClauseRecoveryTestDataProvider") + public void testRetryOnFailClauseRecovery(String sourceFile, String assertFile) { + testFile(sourceFile, assertFile); } } diff --git a/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/WhileStatementTest.java b/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/WhileStatementTest.java index 0337e951f1c8..a444496ed8af 100644 --- a/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/WhileStatementTest.java +++ b/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/WhileStatementTest.java @@ -17,6 +17,7 @@ */ package io.ballerinalang.compiler.parser.test.syntax.statements; +import org.testng.annotations.DataProvider; import org.testng.annotations.Test; /** @@ -66,6 +67,49 @@ public void testWhileWithOnFailClauseHavingErrorBPWithUserDefinedErrorWithVar() testFile("while-stmt/while_stmt_source_10.bal", "while-stmt/while_stmt_assert_10.json"); } + @DataProvider(name = "onFailClauseOtherBPTestDataProvider") + public Object[][] onFailClauseOtherBPTestDataProvider() { + return new Object[][]{ + {"while-stmt/while_stmt_source_15.bal", "while-stmt/while_stmt_assert_15.json"}, + {"while-stmt/while_stmt_source_16.bal", "while-stmt/while_stmt_assert_16.json"}, + {"while-stmt/while_stmt_source_17.bal", "while-stmt/while_stmt_assert_17.json"}, + {"while-stmt/while_stmt_source_18.bal", "while-stmt/while_stmt_assert_18.json"} + }; + } + + @Test(dataProvider = "onFailClauseOtherBPTestDataProvider") + public void testWhileOnFailClauseWithOtherBP(String sourceFile, String assertFile) { + testFile(sourceFile, assertFile); + } + + @DataProvider(name = "onFailClauseErrorBPWithFieldBPTestDataProvider") + public Object[][] onFailClauseErrorBPWithFieldBPTestDataProvider() { + return new Object[][]{ + {"while-stmt/while_stmt_source_19.bal", "while-stmt/while_stmt_assert_19.json"}, + {"while-stmt/while_stmt_source_20.bal", "while-stmt/while_stmt_assert_20.json"}, + {"while-stmt/while_stmt_source_21.bal", "while-stmt/while_stmt_assert_21.json"} + }; + } + + @Test(dataProvider = "onFailClauseErrorBPWithFieldBPTestDataProvider") + public void testWhileOnFailClausHavingErrorBPWithFieldBP(String sourceFile, String assertFile) { + testFile(sourceFile, assertFile); + } + + @DataProvider(name = "onFailClauseErrorBPWithOtherTypeDescTestDataProvider") + public Object[][] onFailClauseErrorBPWithOtherTypeDescTestDataProvider() { + return new Object[][]{ + {"while-stmt/while_stmt_source_22.bal", "while-stmt/while_stmt_assert_22.json"}, + {"while-stmt/while_stmt_source_23.bal", "while-stmt/while_stmt_assert_23.json"}, + {"while-stmt/while_stmt_source_24.bal", "while-stmt/while_stmt_assert_24.json"} + }; + } + + @Test(dataProvider = "onFailClauseErrorBPWithOtherTypeDescTestDataProvider") + public void testWhileOnFailClausHavingErrorBPWithOtherTypeDesc(String sourceFile, String assertFile) { + testFile(sourceFile, assertFile); + } + // Recovery tests @Test @@ -73,12 +117,19 @@ public void testWhileStmtRecovery() { testFile("while-stmt/while_stmt_source_03.bal", "while-stmt/while_stmt_assert_03.json"); } - @Test - public void testWhileOnFailClauseRecovery() { - testFile("while-stmt/while_stmt_source_05.bal", "while-stmt/while_stmt_assert_05.json"); - testFile("while-stmt/while_stmt_source_11.bal", "while-stmt/while_stmt_assert_11.json"); - testFile("while-stmt/while_stmt_source_12.bal", "while-stmt/while_stmt_assert_12.json"); - testFile("while-stmt/while_stmt_source_13.bal", "while-stmt/while_stmt_assert_13.json"); - testFile("while-stmt/while_stmt_source_14.bal", "while-stmt/while_stmt_assert_14.json"); + @DataProvider(name = "onFailClauseRecoveryTestDataProvider") + public Object[][] onFailClauseRecoveryTestDataProvider() { + return new Object[][]{ + {"while-stmt/while_stmt_source_05.bal", "while-stmt/while_stmt_assert_05.json"}, + {"while-stmt/while_stmt_source_11.bal", "while-stmt/while_stmt_assert_11.json"}, + {"while-stmt/while_stmt_source_12.bal", "while-stmt/while_stmt_assert_12.json"}, + {"while-stmt/while_stmt_source_13.bal", "while-stmt/while_stmt_assert_13.json"}, + {"while-stmt/while_stmt_source_14.bal", "while-stmt/while_stmt_assert_14.json"} + }; + } + + @Test(dataProvider = "onFailClauseRecoveryTestDataProvider") + public void testWhileOnFailClauseRecovery(String sourceFile, String assertFile) { + testFile(sourceFile, assertFile); } } diff --git a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_12.json b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_12.json index 45b69bcec56b..c6559f868c0b 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_12.json +++ b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_12.json @@ -1,5 +1,6 @@ { "kind": "FUNCTION_DEFINITION", + "hasDiagnostics": true, "children": [ { "kind": "LIST", @@ -55,6 +56,7 @@ }, { "kind": "FUNCTION_BODY_BLOCK", + "hasDiagnostics": true, "children": [ { "kind": "OPEN_BRACE_TOKEN", @@ -67,9 +69,11 @@ }, { "kind": "LIST", + "hasDiagnostics": true, "children": [ { "kind": "DO_STATEMENT", + "hasDiagnostics": true, "children": [ { "kind": "DO_KEYWORD", @@ -408,6 +412,7 @@ }, { "kind": "ON_FAIL_CLAUSE", + "hasDiagnostics": true, "children": [ { "kind": "ON_KEYWORD", @@ -585,6 +590,7 @@ }, { "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, "children": [ { "kind": "OPEN_BRACE_TOKEN", @@ -597,267 +603,86 @@ }, { "kind": "LIST", + "hasDiagnostics": true, "children": [ { - "kind": "CALL_STATEMENT", + "kind": "LOCAL_VAR_DECL", + "hasDiagnostics": true, "children": [ { - "kind": "FUNCTION_CALL", - "children": [ - { - "kind": "QUALIFIED_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "message" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] + "kind": "LIST", + "children": [] }, { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "CALL_STATEMENT", - "children": [ - { - "kind": "FUNCTION_CALL", + "kind": "TYPED_BINDING_PATTERN", "children": [ { - "kind": "QUALIFIED_NAME_REFERENCE", + "kind": "INT_TYPE_DESC", "children": [ { - "kind": "IDENTIFIER_TOKEN", - "value": "io", + "kind": "INT_KEYWORD", "leadingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", "value": " " } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ + ], + "trailingMinutiae": [ { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "cause" - } - ] + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] } ] }, { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "CALL_STATEMENT", - "children": [ - { - "kind": "FUNCTION_CALL", - "children": [ - { - "kind": "QUALIFIED_NAME_REFERENCE", + "kind": "CAPTURE_BINDING_PATTERN", "children": [ { "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ + "value": "a", + "trailingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "code" - } - ] + "value": " " } ] } ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" } ] }, { - "kind": "SEMICOLON_TOKEN", + "kind": "EQUAL_TOKEN", "trailingMinutiae": [ { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] - } - ] - }, - { - "kind": "CALL_STATEMENT", - "children": [ + }, { - "kind": "FUNCTION_CALL", + "kind": "SIMPLE_NAME_REFERENCE", "children": [ { - "kind": "QUALIFIED_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ + "kind": "IDENTIFIER_TOKEN", + "value": "code", + "trailingMinutiae": [ { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "reason" - } - ] - } - ] + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" } ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" } ] }, { "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_SEMICOLON_TOKEN" ] } ] diff --git a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_13.json b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_13.json index 41b502e72569..9b18e2cad695 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_13.json +++ b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_13.json @@ -598,255 +598,67 @@ "kind": "LIST", "children": [ { - "kind": "CALL_STATEMENT", + "kind": "LOCAL_VAR_DECL", "children": [ { - "kind": "FUNCTION_CALL", - "children": [ - { - "kind": "QUALIFIED_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "message" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] + "kind": "LIST", + "children": [] }, { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "CALL_STATEMENT", - "children": [ - { - "kind": "FUNCTION_CALL", + "kind": "TYPED_BINDING_PATTERN", "children": [ { - "kind": "QUALIFIED_NAME_REFERENCE", + "kind": "STRING_TYPE_DESC", "children": [ { - "kind": "IDENTIFIER_TOKEN", - "value": "io", + "kind": "STRING_KEYWORD", "leadingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", "value": " " } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ + ], + "trailingMinutiae": [ { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "cause" - } - ] + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] } ] }, { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "CALL_STATEMENT", - "children": [ - { - "kind": "FUNCTION_CALL", - "children": [ - { - "kind": "QUALIFIED_NAME_REFERENCE", + "kind": "CAPTURE_BINDING_PATTERN", "children": [ { "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ + "value": "msg", + "trailingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "code" - } - ] + "value": " " } ] } ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" } ] }, { - "kind": "SEMICOLON_TOKEN", + "kind": "EQUAL_TOKEN", "trailingMinutiae": [ { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] - } - ] - }, - { - "kind": "CALL_STATEMENT", - "children": [ + }, { - "kind": "FUNCTION_CALL", + "kind": "SIMPLE_NAME_REFERENCE", "children": [ { - "kind": "QUALIFIED_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "reason" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" + "kind": "IDENTIFIER_TOKEN", + "value": "message" } ] }, diff --git a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_18.json b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_18.json new file mode 100644 index 000000000000..a0053874923a --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_18.json @@ -0,0 +1,374 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "DO_STATEMENT", + "children": [ + { + "kind": "DO_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "LIST_BINDING_PATTERN", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_19.json b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_19.json new file mode 100644 index 000000000000..a8a236201d79 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_19.json @@ -0,0 +1,397 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "DO_STATEMENT", + "children": [ + { + "kind": "DO_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "MAPPING_BINDING_PATTERN", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FIELD_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "failError" + } + ] + }, + { + "kind": "COLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_20.json b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_20.json new file mode 100644 index 000000000000..fa081a0dd989 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_20.json @@ -0,0 +1,290 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "DO_STATEMENT", + "children": [ + { + "kind": "DO_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "WILDCARD_BINDING_PATTERN", + "children": [ + { + "kind": "UNDERSCORE_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_21.json b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_21.json new file mode 100644 index 000000000000..41ca1c547a44 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_21.json @@ -0,0 +1,399 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "DO_STATEMENT", + "children": [ + { + "kind": "DO_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "TUPLE_TYPE_DESC", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "MEMBER_TYPE_DESC", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "LIST_BINDING_PATTERN", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_22.json b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_22.json new file mode 100644 index 000000000000..1a6b2d959abe --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_22.json @@ -0,0 +1,661 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "DO_STATEMENT", + "children": [ + { + "kind": "DO_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Transaction Failure" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Database Error" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "20" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userReason", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "deadlock condition" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "msg" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userReason", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "reason" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "msg" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_23.json b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_23.json new file mode 100644 index 000000000000..808ee0f850ef --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_23.json @@ -0,0 +1,729 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "DO_STATEMENT", + "children": [ + { + "kind": "DO_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Transaction Failure" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Database Error" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "20" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "LIST_CONSTRUCTOR", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Detail_Info_1" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Detail_Info_2" + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "msg" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "LIST_BINDING_PATTERN", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info1" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info2" + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info1" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_24.json b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_24.json new file mode 100644 index 000000000000..65d6c4d43d4f --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_24.json @@ -0,0 +1,891 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "DO_STATEMENT", + "children": [ + { + "kind": "DO_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Transaction Failure" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Database Error" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "20" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "LIST_CONSTRUCTOR", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Detail_Info_1" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Detail_Info_2" + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "posInfo", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "MAPPING_CONSTRUCTOR", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "SPECIFIC_FIELD", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "row" + }, + { + "kind": "COLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "45" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "msg" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "LIST_BINDING_PATTERN", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info1" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info2" + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "posInfo", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "MAPPING_BINDING_PATTERN", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FIELD_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "row" + } + ] + }, + { + "kind": "COLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "posRow" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "posRow" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_25.json b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_25.json new file mode 100644 index 000000000000..c1e1c672c276 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_25.json @@ -0,0 +1,572 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "DO_STATEMENT", + "children": [ + { + "kind": "DO_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "20" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "reason", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "foo" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "TYPE_PARAMETER", + "children": [ + { + "kind": "LT_TOKEN" + }, + { + "kind": "RECORD_TYPE_DESC", + "children": [ + { + "kind": "RECORD_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "OPEN_BRACE_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "RECORD_FIELD", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + }, + { + "kind": "SEMICOLON_TOKEN" + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN" + } + ] + }, + { + "kind": "GT_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "errorCode" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "errorCode" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_26.json b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_26.json new file mode 100644 index 000000000000..6b2c5b534036 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_26.json @@ -0,0 +1,377 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "DO_STATEMENT", + "children": [ + { + "kind": "DO_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "ANYDATA_TYPE_DESC", + "children": [ + { + "kind": "ANYDATA_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_27.json b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_27.json new file mode 100644 index 000000000000..62281af47596 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_27.json @@ -0,0 +1,377 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "DO_STATEMENT", + "children": [ + { + "kind": "DO_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_12.bal b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_12.bal index 56d2c1019201..cb9ccf8df9c7 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_12.bal +++ b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_12.bal @@ -4,9 +4,6 @@ public function test() { userReason = "deadlock condition"); fail err; } on fail SampleError error(message, cause, userCode = code, userReason = reason) { - io:println(message); - io:println(cause); - io:println(code); - io:println(reason); + int a = code } } diff --git a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_13.bal b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_13.bal index f56d1a8ec891..7900d45e35cf 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_13.bal +++ b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_13.bal @@ -4,9 +4,6 @@ public function test() { userReason = "deadlock condition"); fail err; } on fail var error(message, cause, userCode = code, userReason = reason) { - io:println(message); - io:println(cause); - io:println(code); - io:println(reason); + string msg = message; } } diff --git a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_18.bal b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_18.bal new file mode 100644 index 000000000000..725afc22b8d3 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_18.bal @@ -0,0 +1,7 @@ +public function test() { + do { + fail error("error!"); + } on fail error [err] { + io:println(err); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_19.bal b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_19.bal new file mode 100644 index 000000000000..43a7686a8422 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_19.bal @@ -0,0 +1,7 @@ +public function test() { + do { + fail error("error!"); + } on fail error {failError: err} { + io:println(err); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_20.bal b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_20.bal new file mode 100644 index 000000000000..47cdbb4e7b35 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_20.bal @@ -0,0 +1,6 @@ +public function test() { + do { + fail error("error!"); + } on fail error _ { + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_21.bal b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_21.bal new file mode 100644 index 000000000000..54f680379a2e --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_21.bal @@ -0,0 +1,7 @@ +public function test() { + do { + fail error("error!"); + } on fail [error] [err] { + io:println(err); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_22.bal b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_22.bal new file mode 100644 index 000000000000..3f0fb6671c0d --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_22.bal @@ -0,0 +1,8 @@ +public function test() { + do { + fail error SampleError("Transaction Failure", error("Database Error"), userCode = 20, + userReason = "deadlock condition"); + } on fail SampleError error(message, error(msg), userCode = code, userReason = reason) { + io:println(msg); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_23.bal b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_23.bal new file mode 100644 index 000000000000..aa5025e755ac --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_23.bal @@ -0,0 +1,8 @@ +public function test() { + do { + fail error SampleError("Transaction Failure", error("Database Error"), userCode = 20, + info = ["Detail_Info_1", "Detail_Info_2"]); + } on fail SampleError error(message, error(msg), userCode = code, info = [info1, info2]) { + io:println(info1); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_24.bal b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_24.bal new file mode 100644 index 000000000000..ef8a55b4ed93 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_24.bal @@ -0,0 +1,8 @@ +public function test() { + do { + fail error SampleError("Transaction Failure", error("Database Error"), userCode = 20, + info = ["Detail_Info_1", "Detail_Info_2"], posInfo = {row: 45}); + } on fail SampleError error(message, error(msg), userCode = code, info = [info1, info2], posInfo = {row: posRow}) { + io:println(posRow); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_25.bal b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_25.bal new file mode 100644 index 000000000000..96288614214c --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_25.bal @@ -0,0 +1,7 @@ +public function test() { + do { + fail error SampleError("error!", code = 20, reason = "foo"); + } on fail error error(code = errorCode) { + io:println(errorCode); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_26.bal b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_26.bal new file mode 100644 index 000000000000..b6a749bc6d4a --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_26.bal @@ -0,0 +1,7 @@ +public function test() { + do { + fail error("error!"); + } on fail anydata error(err) { + io:println(err); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_27.bal b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_27.bal new file mode 100644 index 000000000000..f7ca097f90d5 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_27.bal @@ -0,0 +1,7 @@ +public function test() { + do { + fail error("error!"); + } on fail int error(err) { + io:println(err); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_35.json b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_35.json new file mode 100644 index 000000000000..2f99fa47f754 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_35.json @@ -0,0 +1,432 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FOREACH_STATEMENT", + "children": [ + { + "kind": "FOREACH_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "VAR_TYPE_DESC", + "children": [ + { + "kind": "VAR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "v", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "IN_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "membersList", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "LIST_BINDING_PATTERN", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_36.json b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_36.json new file mode 100644 index 000000000000..7472c50b4262 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_36.json @@ -0,0 +1,455 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FOREACH_STATEMENT", + "children": [ + { + "kind": "FOREACH_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "VAR_TYPE_DESC", + "children": [ + { + "kind": "VAR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "v", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "IN_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "membersList", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "MAPPING_BINDING_PATTERN", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FIELD_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "failError" + } + ] + }, + { + "kind": "COLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_37.json b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_37.json new file mode 100644 index 000000000000..f5e2ffb32130 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_37.json @@ -0,0 +1,348 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FOREACH_STATEMENT", + "children": [ + { + "kind": "FOREACH_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "VAR_TYPE_DESC", + "children": [ + { + "kind": "VAR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "v", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "IN_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "membersList", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "WILDCARD_BINDING_PATTERN", + "children": [ + { + "kind": "UNDERSCORE_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_38.json b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_38.json new file mode 100644 index 000000000000..138749649fa0 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_38.json @@ -0,0 +1,457 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FOREACH_STATEMENT", + "children": [ + { + "kind": "FOREACH_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "VAR_TYPE_DESC", + "children": [ + { + "kind": "VAR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "v", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "IN_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "membersList", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "TUPLE_TYPE_DESC", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "MEMBER_TYPE_DESC", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "LIST_BINDING_PATTERN", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_39.json b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_39.json new file mode 100644 index 000000000000..29aebd6fbe62 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_39.json @@ -0,0 +1,719 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FOREACH_STATEMENT", + "children": [ + { + "kind": "FOREACH_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "VAR_TYPE_DESC", + "children": [ + { + "kind": "VAR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "v", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "IN_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "membersList", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Transaction Failure" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Database Error" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "20" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userReason", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "deadlock condition" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "msg" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userReason", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "reason" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "msg" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_40.json b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_40.json new file mode 100644 index 000000000000..2da37d3e0d30 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_40.json @@ -0,0 +1,787 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FOREACH_STATEMENT", + "children": [ + { + "kind": "FOREACH_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "VAR_TYPE_DESC", + "children": [ + { + "kind": "VAR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "v", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "IN_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "membersList", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Transaction Failure" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Database Error" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "20" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "LIST_CONSTRUCTOR", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Detail_Info_1" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Detail_Info_2" + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "msg" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "LIST_BINDING_PATTERN", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info1" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info2" + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info1" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_41.json b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_41.json new file mode 100644 index 000000000000..4037183ec16e --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_41.json @@ -0,0 +1,949 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FOREACH_STATEMENT", + "children": [ + { + "kind": "FOREACH_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "VAR_TYPE_DESC", + "children": [ + { + "kind": "VAR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "v", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "IN_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "membersList", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Transaction Failure" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Database Error" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "20" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "LIST_CONSTRUCTOR", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Detail_Info_1" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Detail_Info_2" + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "posInfo", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "MAPPING_CONSTRUCTOR", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "SPECIFIC_FIELD", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "row" + }, + { + "kind": "COLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "45" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "msg" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "LIST_BINDING_PATTERN", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info1" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info2" + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "posInfo", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "MAPPING_BINDING_PATTERN", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FIELD_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "row" + } + ] + }, + { + "kind": "COLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "posRow" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "posRow" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_42.json b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_42.json new file mode 100644 index 000000000000..8ec5ebf5dfaf --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_42.json @@ -0,0 +1,630 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FOREACH_STATEMENT", + "children": [ + { + "kind": "FOREACH_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "VAR_TYPE_DESC", + "children": [ + { + "kind": "VAR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "v", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "IN_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "membersList", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "20" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "reason", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "foo" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "TYPE_PARAMETER", + "children": [ + { + "kind": "LT_TOKEN" + }, + { + "kind": "RECORD_TYPE_DESC", + "children": [ + { + "kind": "RECORD_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "OPEN_BRACE_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "RECORD_FIELD", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + }, + { + "kind": "SEMICOLON_TOKEN" + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN" + } + ] + }, + { + "kind": "GT_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "errorCode" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "errorCode" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_43.json b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_43.json new file mode 100644 index 000000000000..905d5d260828 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_43.json @@ -0,0 +1,435 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FOREACH_STATEMENT", + "children": [ + { + "kind": "FOREACH_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "VAR_TYPE_DESC", + "children": [ + { + "kind": "VAR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "v", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "IN_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "membersList", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "ANYDATA_TYPE_DESC", + "children": [ + { + "kind": "ANYDATA_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_44.json b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_44.json new file mode 100644 index 000000000000..11d144398dc6 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_44.json @@ -0,0 +1,435 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FOREACH_STATEMENT", + "children": [ + { + "kind": "FOREACH_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "VAR_TYPE_DESC", + "children": [ + { + "kind": "VAR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "v", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "IN_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "membersList", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_29.bal b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_29.bal index 5493ce57b7c4..dbb31f731956 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_29.bal +++ b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_29.bal @@ -11,9 +11,6 @@ public function test() { userReason = "deadlock condition"); fail err; } on fail SampleError error(message, cause, userCode = code, userReason = reason) { - io:println(message); - io:println(cause); - io:println(code); - io:println(reason); + int a = code } } diff --git a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_30.bal b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_30.bal index aba15960d9e3..21f2cb3ca4aa 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_30.bal +++ b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_30.bal @@ -11,9 +11,6 @@ public function test() { userReason = "deadlock condition"); fail err; } on fail var error(message, cause, userCode = code, userReason = reason) { - io:println(message); - io:println(cause); - io:println(code); - io:println(reason); + string msg = message; } } diff --git a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_35.bal b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_35.bal new file mode 100644 index 000000000000..c3d73eb51d6b --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_35.bal @@ -0,0 +1,7 @@ +public function test() { + foreach var v in membersList { + fail error("error!"); + } on fail error [err] { + io:println(err); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_36.bal b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_36.bal new file mode 100644 index 000000000000..39afe4f81815 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_36.bal @@ -0,0 +1,7 @@ +public function test() { + foreach var v in membersList { + fail error("error!"); + } on fail error {failError: err} { + io:println(err); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_37.bal b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_37.bal new file mode 100644 index 000000000000..894f40cbf680 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_37.bal @@ -0,0 +1,6 @@ +public function test() { + foreach var v in membersList { + fail error("error!"); + } on fail error _ { + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_38.bal b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_38.bal new file mode 100644 index 000000000000..b989d185eed8 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_38.bal @@ -0,0 +1,7 @@ +public function test() { + foreach var v in membersList { + fail error("error!"); + } on fail [error] [err] { + io:println(err); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_39.bal b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_39.bal new file mode 100644 index 000000000000..2aa7ee6f52c4 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_39.bal @@ -0,0 +1,8 @@ +public function test() { + foreach var v in membersList { + fail error SampleError("Transaction Failure", error("Database Error"), userCode = 20, + userReason = "deadlock condition"); + } on fail SampleError error(message, error(msg), userCode = code, userReason = reason) { + io:println(msg); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_40.bal b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_40.bal new file mode 100644 index 000000000000..1654432cbb99 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_40.bal @@ -0,0 +1,8 @@ +public function test() { + foreach var v in membersList { + fail error SampleError("Transaction Failure", error("Database Error"), userCode = 20, + info = ["Detail_Info_1", "Detail_Info_2"]); + } on fail SampleError error(message, error(msg), userCode = code, info = [info1, info2]) { + io:println(info1); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_41.bal b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_41.bal new file mode 100644 index 000000000000..62231ccc9d46 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_41.bal @@ -0,0 +1,8 @@ +public function test() { + foreach var v in membersList { + fail error SampleError("Transaction Failure", error("Database Error"), userCode = 20, + info = ["Detail_Info_1", "Detail_Info_2"], posInfo = {row: 45}); + } on fail SampleError error(message, error(msg), userCode = code, info = [info1, info2], posInfo = {row: posRow}) { + io:println(posRow); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_42.bal b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_42.bal new file mode 100644 index 000000000000..8197cf3bf415 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_42.bal @@ -0,0 +1,7 @@ +public function test() { + foreach var v in membersList { + fail error SampleError("error!", code = 20, reason = "foo"); + } on fail error error(code = errorCode) { + io:println(errorCode); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_43.bal b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_43.bal new file mode 100644 index 000000000000..909c6691618c --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_43.bal @@ -0,0 +1,7 @@ +public function test() { + foreach var v in membersList { + fail error("error!"); + } on fail anydata error(err) { + io:println(err); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_44.bal b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_44.bal new file mode 100644 index 000000000000..055a585706e6 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_44.bal @@ -0,0 +1,7 @@ +public function test() { + foreach var v in membersList { + fail error("error!"); + } on fail int error(err) { + io:println(err); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_19.json b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_19.json new file mode 100644 index 000000000000..15a3a4597aa8 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_19.json @@ -0,0 +1,374 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCK_STATEMENT", + "children": [ + { + "kind": "LOCK_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "LIST_BINDING_PATTERN", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_20.json b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_20.json new file mode 100644 index 000000000000..d3656eba4500 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_20.json @@ -0,0 +1,397 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCK_STATEMENT", + "children": [ + { + "kind": "LOCK_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "MAPPING_BINDING_PATTERN", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FIELD_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "failError" + } + ] + }, + { + "kind": "COLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_21.json b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_21.json new file mode 100644 index 000000000000..00b7aa8c2b07 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_21.json @@ -0,0 +1,290 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCK_STATEMENT", + "children": [ + { + "kind": "LOCK_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "WILDCARD_BINDING_PATTERN", + "children": [ + { + "kind": "UNDERSCORE_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_22.json b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_22.json new file mode 100644 index 000000000000..9ddb11cda57d --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_22.json @@ -0,0 +1,399 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCK_STATEMENT", + "children": [ + { + "kind": "LOCK_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "TUPLE_TYPE_DESC", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "MEMBER_TYPE_DESC", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "LIST_BINDING_PATTERN", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_23.json b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_23.json new file mode 100644 index 000000000000..88ad837cb869 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_23.json @@ -0,0 +1,661 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCK_STATEMENT", + "children": [ + { + "kind": "LOCK_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Transaction Failure" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Database Error" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "20" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userReason", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "deadlock condition" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "msg" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userReason", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "reason" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "msg" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_24.json b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_24.json new file mode 100644 index 000000000000..f00280b4514a --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_24.json @@ -0,0 +1,729 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCK_STATEMENT", + "children": [ + { + "kind": "LOCK_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Transaction Failure" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Database Error" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "20" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "LIST_CONSTRUCTOR", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Detail_Info_1" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Detail_Info_2" + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "msg" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "LIST_BINDING_PATTERN", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info1" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info2" + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info1" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_25.json b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_25.json new file mode 100644 index 000000000000..a4106a048a34 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_25.json @@ -0,0 +1,891 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCK_STATEMENT", + "children": [ + { + "kind": "LOCK_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Transaction Failure" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Database Error" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "20" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "LIST_CONSTRUCTOR", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Detail_Info_1" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Detail_Info_2" + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "posInfo", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "MAPPING_CONSTRUCTOR", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "SPECIFIC_FIELD", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "row" + }, + { + "kind": "COLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "45" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "msg" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "LIST_BINDING_PATTERN", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info1" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info2" + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "posInfo", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "MAPPING_BINDING_PATTERN", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FIELD_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "row" + } + ] + }, + { + "kind": "COLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "posRow" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "posRow" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_26.json b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_26.json new file mode 100644 index 000000000000..e1f9efad5149 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_26.json @@ -0,0 +1,572 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCK_STATEMENT", + "children": [ + { + "kind": "LOCK_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "20" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "reason", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "foo" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "TYPE_PARAMETER", + "children": [ + { + "kind": "LT_TOKEN" + }, + { + "kind": "RECORD_TYPE_DESC", + "children": [ + { + "kind": "RECORD_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "OPEN_BRACE_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "RECORD_FIELD", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + }, + { + "kind": "SEMICOLON_TOKEN" + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN" + } + ] + }, + { + "kind": "GT_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "errorCode" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "errorCode" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_27.json b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_27.json new file mode 100644 index 000000000000..81f34528203a --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_27.json @@ -0,0 +1,377 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCK_STATEMENT", + "children": [ + { + "kind": "LOCK_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "ANYDATA_TYPE_DESC", + "children": [ + { + "kind": "ANYDATA_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_38.json b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_38.json new file mode 100644 index 000000000000..228e7e9f444a --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_38.json @@ -0,0 +1,377 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCK_STATEMENT", + "children": [ + { + "kind": "LOCK_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_13.bal b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_13.bal index c41fb2f5f718..fc6b408ed795 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_13.bal +++ b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_13.bal @@ -11,9 +11,6 @@ public function test() { userReason = "deadlock condition"); fail err; } on fail SampleError error(message, cause, userCode = code, userReason = reason) { - io:println(message); - io:println(cause); - io:println(code); - io:println(reason); + int a = code } } diff --git a/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_14.bal b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_14.bal index efc2a8996bc7..4960d5020020 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_14.bal +++ b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_14.bal @@ -11,9 +11,6 @@ public function test() { userReason = "deadlock condition"); fail err; } on fail var error(message, cause, userCode = code, userReason = reason) { - io:println(message); - io:println(cause); - io:println(code); - io:println(reason); + string msg = message; } } diff --git a/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_19.bal b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_19.bal new file mode 100644 index 000000000000..c0021433b763 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_19.bal @@ -0,0 +1,7 @@ +public function test() { + lock { + fail error("error!"); + } on fail error [err] { + io:println(err); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_20.bal b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_20.bal new file mode 100644 index 000000000000..b03942648e38 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_20.bal @@ -0,0 +1,7 @@ +public function test() { + lock { + fail error("error!"); + } on fail error {failError: err} { + io:println(err); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_21.bal b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_21.bal new file mode 100644 index 000000000000..ada87fc7dfd2 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_21.bal @@ -0,0 +1,6 @@ +public function test() { + lock { + fail error("error!"); + } on fail error _ { + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_22.bal b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_22.bal new file mode 100644 index 000000000000..89f1bccd29fb --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_22.bal @@ -0,0 +1,7 @@ +public function test() { + lock { + fail error("error!"); + } on fail [error] [err] { + io:println(err); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_23.bal b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_23.bal new file mode 100644 index 000000000000..4fe2e00e7fc0 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_23.bal @@ -0,0 +1,8 @@ +public function test() { + lock { + fail error SampleError("Transaction Failure", error("Database Error"), userCode = 20, + userReason = "deadlock condition"); + } on fail SampleError error(message, error(msg), userCode = code, userReason = reason) { + io:println(msg); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_24.bal b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_24.bal new file mode 100644 index 000000000000..3ad057257032 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_24.bal @@ -0,0 +1,8 @@ +public function test() { + lock { + fail error SampleError("Transaction Failure", error("Database Error"), userCode = 20, + info = ["Detail_Info_1", "Detail_Info_2"]); + } on fail SampleError error(message, error(msg), userCode = code, info = [info1, info2]) { + io:println(info1); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_25.bal b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_25.bal new file mode 100644 index 000000000000..9d08ac4fb665 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_25.bal @@ -0,0 +1,8 @@ +public function test() { + lock { + fail error SampleError("Transaction Failure", error("Database Error"), userCode = 20, + info = ["Detail_Info_1", "Detail_Info_2"], posInfo = {row: 45}); + } on fail SampleError error(message, error(msg), userCode = code, info = [info1, info2], posInfo = {row: posRow}) { + io:println(posRow); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_26.bal b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_26.bal new file mode 100644 index 000000000000..9c3f8c66036a --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_26.bal @@ -0,0 +1,7 @@ +public function test() { + lock { + fail error SampleError("error!", code = 20, reason = "foo"); + } on fail error error(code = errorCode) { + io:println(errorCode); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_27.bal b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_27.bal new file mode 100644 index 000000000000..e54bfd313117 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_27.bal @@ -0,0 +1,7 @@ +public function test() { + lock { + fail error("error!"); + } on fail anydata error(err) { + io:println(err); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_28.bal b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_28.bal new file mode 100644 index 000000000000..e9ab37b01e33 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_28.bal @@ -0,0 +1,7 @@ +public function test() { + lock { + fail error("error!"); + } on fail int error(err) { + io:println(err); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_32.json b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_32.json new file mode 100644 index 000000000000..7880e96c13ef --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_32.json @@ -0,0 +1,533 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "MATCH_STATEMENT", + "children": [ + { + "kind": "MATCH_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "bar", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "MATCH_CLAUSE", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "NIL_LITERAL", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "RIGHT_DOUBLE_ARROW_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "MATCH_CLAUSE", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "east", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "RIGHT_DOUBLE_ARROW_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "LIST_BINDING_PATTERN", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_33.json b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_33.json new file mode 100644 index 000000000000..25e090628e41 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_33.json @@ -0,0 +1,556 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "MATCH_STATEMENT", + "children": [ + { + "kind": "MATCH_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "bar", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "MATCH_CLAUSE", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "NIL_LITERAL", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "RIGHT_DOUBLE_ARROW_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "MATCH_CLAUSE", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "east", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "RIGHT_DOUBLE_ARROW_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "MAPPING_BINDING_PATTERN", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FIELD_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "failError" + } + ] + }, + { + "kind": "COLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_34.json b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_34.json new file mode 100644 index 000000000000..b07d3b1310e2 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_34.json @@ -0,0 +1,449 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "MATCH_STATEMENT", + "children": [ + { + "kind": "MATCH_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "bar", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "MATCH_CLAUSE", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "NIL_LITERAL", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "RIGHT_DOUBLE_ARROW_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "MATCH_CLAUSE", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "east", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "RIGHT_DOUBLE_ARROW_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "WILDCARD_BINDING_PATTERN", + "children": [ + { + "kind": "UNDERSCORE_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_35.json b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_35.json new file mode 100644 index 000000000000..53b33535f8d9 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_35.json @@ -0,0 +1,558 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "MATCH_STATEMENT", + "children": [ + { + "kind": "MATCH_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "bar", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "MATCH_CLAUSE", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "NIL_LITERAL", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "RIGHT_DOUBLE_ARROW_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "MATCH_CLAUSE", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "east", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "RIGHT_DOUBLE_ARROW_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "TUPLE_TYPE_DESC", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "MEMBER_TYPE_DESC", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "LIST_BINDING_PATTERN", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_36.json b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_36.json new file mode 100644 index 000000000000..904d0a226452 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_36.json @@ -0,0 +1,820 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "MATCH_STATEMENT", + "children": [ + { + "kind": "MATCH_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "bar", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "MATCH_CLAUSE", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "NIL_LITERAL", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "RIGHT_DOUBLE_ARROW_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "MATCH_CLAUSE", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "east", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "RIGHT_DOUBLE_ARROW_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Transaction Failure" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Database Error" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "20" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userReason", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "deadlock condition" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "msg" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userReason", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "reason" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "msg" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_37.json b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_37.json new file mode 100644 index 000000000000..bf3ada3ed95b --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_37.json @@ -0,0 +1,888 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "MATCH_STATEMENT", + "children": [ + { + "kind": "MATCH_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "bar", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "MATCH_CLAUSE", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "NIL_LITERAL", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "RIGHT_DOUBLE_ARROW_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "MATCH_CLAUSE", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "east", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "RIGHT_DOUBLE_ARROW_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Transaction Failure" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Database Error" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "20" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "LIST_CONSTRUCTOR", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Detail_Info_1" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Detail_Info_2" + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "msg" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "LIST_BINDING_PATTERN", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info1" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info2" + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info1" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_38.json b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_38.json new file mode 100644 index 000000000000..e847d070935e --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_38.json @@ -0,0 +1,1050 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "MATCH_STATEMENT", + "children": [ + { + "kind": "MATCH_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "bar", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "MATCH_CLAUSE", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "NIL_LITERAL", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "RIGHT_DOUBLE_ARROW_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "MATCH_CLAUSE", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "east", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "RIGHT_DOUBLE_ARROW_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Transaction Failure" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Database Error" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "20" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "LIST_CONSTRUCTOR", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Detail_Info_1" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Detail_Info_2" + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "posInfo", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "MAPPING_CONSTRUCTOR", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "SPECIFIC_FIELD", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "row" + }, + { + "kind": "COLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "45" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "msg" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "LIST_BINDING_PATTERN", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info1" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info2" + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "posInfo", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "MAPPING_BINDING_PATTERN", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FIELD_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "row" + } + ] + }, + { + "kind": "COLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "posRow" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "posRow" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_39.json b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_39.json new file mode 100644 index 000000000000..4a671bc2771f --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_39.json @@ -0,0 +1,731 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "MATCH_STATEMENT", + "children": [ + { + "kind": "MATCH_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "bar", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "MATCH_CLAUSE", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "NIL_LITERAL", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "RIGHT_DOUBLE_ARROW_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "MATCH_CLAUSE", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "east", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "RIGHT_DOUBLE_ARROW_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "20" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "reason", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "foo" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "TYPE_PARAMETER", + "children": [ + { + "kind": "LT_TOKEN" + }, + { + "kind": "RECORD_TYPE_DESC", + "children": [ + { + "kind": "RECORD_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "OPEN_BRACE_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "RECORD_FIELD", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + }, + { + "kind": "SEMICOLON_TOKEN" + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN" + } + ] + }, + { + "kind": "GT_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "errorCode" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "errorCode" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_40.json b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_40.json new file mode 100644 index 000000000000..73d299432292 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_40.json @@ -0,0 +1,536 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "MATCH_STATEMENT", + "children": [ + { + "kind": "MATCH_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "bar", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "MATCH_CLAUSE", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "NIL_LITERAL", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "RIGHT_DOUBLE_ARROW_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "MATCH_CLAUSE", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "east", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "RIGHT_DOUBLE_ARROW_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "ANYDATA_TYPE_DESC", + "children": [ + { + "kind": "ANYDATA_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_41.json b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_41.json new file mode 100644 index 000000000000..b6bf0d9938ff --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_41.json @@ -0,0 +1,536 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "MATCH_STATEMENT", + "children": [ + { + "kind": "MATCH_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "bar", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "MATCH_CLAUSE", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "NIL_LITERAL", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "RIGHT_DOUBLE_ARROW_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "MATCH_CLAUSE", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "east", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "RIGHT_DOUBLE_ARROW_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_26.bal b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_26.bal index 211defb86782..11afbf1fe1a8 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_26.bal +++ b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_26.bal @@ -15,9 +15,6 @@ public function test() { fail err; } } on fail SampleError error(message, cause, userCode = code, userReason = reason) { - io:println(message); - io:println(cause); - io:println(code); - io:println(reason); + int a = code } } diff --git a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_27.bal b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_27.bal index 8a88304140f0..9def4a0d3a02 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_27.bal +++ b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_27.bal @@ -15,9 +15,6 @@ public function test() { fail err; } } on fail var error(message, cause, userCode = code, userReason = reason) { - io:println(message); - io:println(cause); - io:println(code); - io:println(reason); + string msg = message; } } diff --git a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_32.bal b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_32.bal new file mode 100644 index 000000000000..d67694e1c690 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_32.bal @@ -0,0 +1,11 @@ +public function test() { + match bar { + () => { + } + "east" => { + fail error("error!"); + } + } on fail error [err] { + io:println(err); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_33.bal b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_33.bal new file mode 100644 index 000000000000..0bc00044f149 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_33.bal @@ -0,0 +1,11 @@ +public function test() { + match bar { + () => { + } + "east" => { + fail error("error!"); + } + } on fail error {failError: err} { + io:println(err); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_34.bal b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_34.bal new file mode 100644 index 000000000000..8f63486e22bf --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_34.bal @@ -0,0 +1,10 @@ +public function test() { + match bar { + () => { + } + "east" => { + fail error("error!"); + } + } on fail error _ { + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_35.bal b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_35.bal new file mode 100644 index 000000000000..8d927ad1101e --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_35.bal @@ -0,0 +1,11 @@ +public function test() { + match bar { + () => { + } + "east" => { + fail error("error!"); + } + } on fail [error] [err] { + io:println(err); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_36.bal b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_36.bal new file mode 100644 index 000000000000..90f8b11ea692 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_36.bal @@ -0,0 +1,12 @@ +public function test() { + match bar { + () => { + } + "east" => { + fail error SampleError("Transaction Failure", error("Database Error"), userCode = 20, + userReason = "deadlock condition"); + } + } on fail SampleError error(message, error(msg), userCode = code, userReason = reason) { + io:println(msg); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_37.bal b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_37.bal new file mode 100644 index 000000000000..fe8b1197a3a7 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_37.bal @@ -0,0 +1,12 @@ +public function test() { + match bar { + () => { + } + "east" => { + fail error SampleError("Transaction Failure", error("Database Error"), userCode = 20, + info = ["Detail_Info_1", "Detail_Info_2"]); + } + } on fail SampleError error(message, error(msg), userCode = code, info = [info1, info2]) { + io:println(info1); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_38.bal b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_38.bal new file mode 100644 index 000000000000..cad921ba0b8f --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_38.bal @@ -0,0 +1,12 @@ +public function test() { + match bar { + () => { + } + "east" => { + fail error SampleError("Transaction Failure", error("Database Error"), userCode = 20, + info = ["Detail_Info_1", "Detail_Info_2"], posInfo = {row: 45}); + } + } on fail SampleError error(message, error(msg), userCode = code, info = [info1, info2], posInfo = {row: posRow}) { + io:println(posRow); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_39.bal b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_39.bal new file mode 100644 index 000000000000..4f1880add996 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_39.bal @@ -0,0 +1,11 @@ +public function test() { + match bar { + () => { + } + "east" => { + fail error SampleError("error!", code = 20, reason = "foo"); + } + } on fail error error(code = errorCode) { + io:println(errorCode); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_40.bal b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_40.bal new file mode 100644 index 000000000000..aec8423f5f40 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_40.bal @@ -0,0 +1,11 @@ +public function test() { + match bar { + () => { + } + "east" => { + fail error("error!"); + } + } on fail anydata error(err) { + io:println(err); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_41.bal b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_41.bal new file mode 100644 index 000000000000..b086a7365a0e --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_41.bal @@ -0,0 +1,11 @@ +public function test() { + match bar { + () => { + } + "east" => { + fail error("error!"); + } + } on fail int error(err) { + io:println(err); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_10.json b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_10.json index 4184595b348b..27d7c59a07c2 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_10.json +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_10.json @@ -1,5 +1,6 @@ { "kind": "FUNCTION_DEFINITION", + "hasDiagnostics": true, "children": [ { "kind": "LIST", @@ -55,6 +56,7 @@ }, { "kind": "FUNCTION_BODY_BLOCK", + "hasDiagnostics": true, "children": [ { "kind": "OPEN_BRACE_TOKEN", @@ -67,9 +69,11 @@ }, { "kind": "LIST", + "hasDiagnostics": true, "children": [ { "kind": "RETRY_STATEMENT", + "hasDiagnostics": true, "children": [ { "kind": "RETRY_KEYWORD", @@ -125,6 +129,7 @@ }, { "kind": "ON_FAIL_CLAUSE", + "hasDiagnostics": true, "children": [ { "kind": "ON_KEYWORD", @@ -302,6 +307,7 @@ }, { "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, "children": [ { "kind": "OPEN_BRACE_TOKEN", @@ -314,267 +320,86 @@ }, { "kind": "LIST", + "hasDiagnostics": true, "children": [ { - "kind": "CALL_STATEMENT", + "kind": "LOCAL_VAR_DECL", + "hasDiagnostics": true, "children": [ { - "kind": "FUNCTION_CALL", - "children": [ - { - "kind": "QUALIFIED_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "message" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] + "kind": "LIST", + "children": [] }, { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "CALL_STATEMENT", - "children": [ - { - "kind": "FUNCTION_CALL", + "kind": "TYPED_BINDING_PATTERN", "children": [ { - "kind": "QUALIFIED_NAME_REFERENCE", + "kind": "INT_TYPE_DESC", "children": [ { - "kind": "IDENTIFIER_TOKEN", - "value": "io", + "kind": "INT_KEYWORD", "leadingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", "value": " " } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ + ], + "trailingMinutiae": [ { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "cause" - } - ] + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] } ] }, { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "CALL_STATEMENT", - "children": [ - { - "kind": "FUNCTION_CALL", - "children": [ - { - "kind": "QUALIFIED_NAME_REFERENCE", + "kind": "CAPTURE_BINDING_PATTERN", "children": [ { "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ + "value": "a", + "trailingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", - "value": " " + "value": " " } ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" } ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "code" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" } ] }, { - "kind": "SEMICOLON_TOKEN", + "kind": "EQUAL_TOKEN", "trailingMinutiae": [ { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] - } - ] - }, - { - "kind": "CALL_STATEMENT", - "children": [ + }, { - "kind": "FUNCTION_CALL", + "kind": "SIMPLE_NAME_REFERENCE", "children": [ { - "kind": "QUALIFIED_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ + "kind": "IDENTIFIER_TOKEN", + "value": "code", + "trailingMinutiae": [ { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "reason" - } - ] - } - ] + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" } ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" } ] }, { "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_SEMICOLON_TOKEN" ] } ] diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_11.json b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_11.json index 178a22ef2b55..7409084d6fbe 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_11.json +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_11.json @@ -1,5 +1,6 @@ { "kind": "FUNCTION_DEFINITION", + "hasDiagnostics": true, "children": [ { "kind": "LIST", @@ -55,6 +56,7 @@ }, { "kind": "FUNCTION_BODY_BLOCK", + "hasDiagnostics": true, "children": [ { "kind": "OPEN_BRACE_TOKEN", @@ -67,9 +69,11 @@ }, { "kind": "LIST", + "hasDiagnostics": true, "children": [ { "kind": "RETRY_STATEMENT", + "hasDiagnostics": true, "children": [ { "kind": "RETRY_KEYWORD", @@ -125,6 +129,7 @@ }, { "kind": "ON_FAIL_CLAUSE", + "hasDiagnostics": true, "children": [ { "kind": "ON_KEYWORD", @@ -301,6 +306,7 @@ }, { "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, "children": [ { "kind": "OPEN_BRACE_TOKEN", @@ -313,267 +319,86 @@ }, { "kind": "LIST", + "hasDiagnostics": true, "children": [ { - "kind": "CALL_STATEMENT", + "kind": "LOCAL_VAR_DECL", + "hasDiagnostics": true, "children": [ { - "kind": "FUNCTION_CALL", - "children": [ - { - "kind": "QUALIFIED_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "message" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] + "kind": "LIST", + "children": [] }, { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "CALL_STATEMENT", - "children": [ - { - "kind": "FUNCTION_CALL", + "kind": "TYPED_BINDING_PATTERN", "children": [ { - "kind": "QUALIFIED_NAME_REFERENCE", + "kind": "INT_TYPE_DESC", "children": [ { - "kind": "IDENTIFIER_TOKEN", - "value": "io", + "kind": "INT_KEYWORD", "leadingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", "value": " " } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ + ], + "trailingMinutiae": [ { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "cause" - } - ] + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] } ] }, { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "CALL_STATEMENT", - "children": [ - { - "kind": "FUNCTION_CALL", - "children": [ - { - "kind": "QUALIFIED_NAME_REFERENCE", + "kind": "CAPTURE_BINDING_PATTERN", "children": [ { "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ + "value": "a", + "trailingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", - "value": " " + "value": " " } ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" } ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "code" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" } ] }, { - "kind": "SEMICOLON_TOKEN", + "kind": "EQUAL_TOKEN", "trailingMinutiae": [ { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] - } - ] - }, - { - "kind": "CALL_STATEMENT", - "children": [ + }, { - "kind": "FUNCTION_CALL", + "kind": "SIMPLE_NAME_REFERENCE", "children": [ { - "kind": "QUALIFIED_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ + "kind": "IDENTIFIER_TOKEN", + "value": "code", + "trailingMinutiae": [ { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "reason" - } - ] - } - ] + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" } ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" } ] }, { "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_SEMICOLON_TOKEN" ] } ] diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_16.json b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_16.json new file mode 100644 index 000000000000..f65be67acafa --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_16.json @@ -0,0 +1,374 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "RETRY_STATEMENT", + "children": [ + { + "kind": "RETRY_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "LIST_BINDING_PATTERN", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_17.json b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_17.json new file mode 100644 index 000000000000..a2c8762d8d42 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_17.json @@ -0,0 +1,397 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "RETRY_STATEMENT", + "children": [ + { + "kind": "RETRY_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "MAPPING_BINDING_PATTERN", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FIELD_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "failError" + } + ] + }, + { + "kind": "COLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_18.json b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_18.json new file mode 100644 index 000000000000..ecbdb0afd698 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_18.json @@ -0,0 +1,290 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "RETRY_STATEMENT", + "children": [ + { + "kind": "RETRY_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "WILDCARD_BINDING_PATTERN", + "children": [ + { + "kind": "UNDERSCORE_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_19.json b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_19.json new file mode 100644 index 000000000000..2d3e959883f9 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_19.json @@ -0,0 +1,399 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "RETRY_STATEMENT", + "children": [ + { + "kind": "RETRY_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "TUPLE_TYPE_DESC", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "MEMBER_TYPE_DESC", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "LIST_BINDING_PATTERN", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_20.json b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_20.json new file mode 100644 index 000000000000..6efc2310ea5b --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_20.json @@ -0,0 +1,661 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "RETRY_STATEMENT", + "children": [ + { + "kind": "RETRY_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Transaction Failure" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Database Error" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "20" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userReason", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "deadlock condition" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "msg" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userReason", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "reason" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "msg" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_21json b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_21json new file mode 100644 index 000000000000..d29ed7ce81f3 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_21json @@ -0,0 +1,729 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "RETRY_STATEMENT", + "children": [ + { + "kind": "RETRY_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Transaction Failure" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Database Error" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "20" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "LIST_CONSTRUCTOR", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Detail_Info_1" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Detail_Info_2" + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "msg" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "LIST_BINDING_PATTERN", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info1" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info2" + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info1" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_22.json b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_22.json new file mode 100644 index 000000000000..7e6f34f7a191 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_22.json @@ -0,0 +1,891 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "RETRY_STATEMENT", + "children": [ + { + "kind": "RETRY_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Transaction Failure" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Database Error" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "20" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "LIST_CONSTRUCTOR", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Detail_Info_1" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Detail_Info_2" + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "posInfo", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "MAPPING_CONSTRUCTOR", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "SPECIFIC_FIELD", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "row" + }, + { + "kind": "COLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "45" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "msg" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "LIST_BINDING_PATTERN", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info1" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info2" + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "posInfo", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "MAPPING_BINDING_PATTERN", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FIELD_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "row" + } + ] + }, + { + "kind": "COLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "posRow" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "posRow" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_23.json b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_23.json new file mode 100644 index 000000000000..52ae965d73d3 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_23.json @@ -0,0 +1,572 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "RETRY_STATEMENT", + "children": [ + { + "kind": "RETRY_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "20" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "reason", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "foo" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "TYPE_PARAMETER", + "children": [ + { + "kind": "LT_TOKEN" + }, + { + "kind": "RECORD_TYPE_DESC", + "children": [ + { + "kind": "RECORD_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "OPEN_BRACE_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "RECORD_FIELD", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + }, + { + "kind": "SEMICOLON_TOKEN" + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN" + } + ] + }, + { + "kind": "GT_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "errorCode" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "errorCode" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_24.json b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_24.json new file mode 100644 index 000000000000..ab85c6873219 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_24.json @@ -0,0 +1,377 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "RETRY_STATEMENT", + "children": [ + { + "kind": "RETRY_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "ANYDATA_TYPE_DESC", + "children": [ + { + "kind": "ANYDATA_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_25.json b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_25.json new file mode 100644 index 000000000000..5e7bf7dd6176 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_25.json @@ -0,0 +1,377 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "RETRY_STATEMENT", + "children": [ + { + "kind": "RETRY_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_10.bal b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_10.bal index 9ef2af2ff0d9..e4bba38a0590 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_10.bal +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_10.bal @@ -2,9 +2,6 @@ public function test() { retry { } on fail SampleError error(message, cause, userCode = code, userReason = reason) { - io:println(message); - io:println(cause); - io:println(code); - io:println(reason); + int a = code } } diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_11.bal b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_11.bal index 6eae67aebe99..50908a7fad71 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_11.bal +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_11.bal @@ -2,9 +2,6 @@ public function test() { retry { } on fail var error(message, cause, userCode = code, userReason = reason) { - io:println(message); - io:println(cause); - io:println(code); - io:println(reason); + int a = code } } diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_16.bal b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_16.bal new file mode 100644 index 000000000000..1f2c0f45c2db --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_16.bal @@ -0,0 +1,7 @@ +public function test() { + retry { + fail error("error!"); + } on fail error [err] { + io:println(err); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_17.bal b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_17.bal new file mode 100644 index 000000000000..32f540475dd3 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_17.bal @@ -0,0 +1,7 @@ +public function test() { + retry { + fail error("error!"); + } on fail error {failError: err} { + io:println(err); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_18.bal b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_18.bal new file mode 100644 index 000000000000..7e0a900752f4 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_18.bal @@ -0,0 +1,6 @@ +public function test() { + retry { + fail error("error!"); + } on fail error _ { + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_19.bal b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_19.bal new file mode 100644 index 000000000000..9a79be67a912 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_19.bal @@ -0,0 +1,7 @@ +public function test() { + retry { + fail error("error!"); + } on fail [error] [err] { + io:println(err); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_20.bal b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_20.bal new file mode 100644 index 000000000000..4040b39bd53e --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_20.bal @@ -0,0 +1,8 @@ +public function test() { + retry { + fail error SampleError("Transaction Failure", error("Database Error"), userCode = 20, + userReason = "deadlock condition"); + } on fail SampleError error(message, error(msg), userCode = code, userReason = reason) { + io:println(msg); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_21.bal b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_21.bal new file mode 100644 index 000000000000..a2a0139b85d6 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_21.bal @@ -0,0 +1,8 @@ +public function test() { + retry { + fail error SampleError("Transaction Failure", error("Database Error"), userCode = 20, + info = ["Detail_Info_1", "Detail_Info_2"]); + } on fail SampleError error(message, error(msg), userCode = code, info = [info1, info2]) { + io:println(info1); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_22.bal b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_22.bal new file mode 100644 index 000000000000..05aca03a0545 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_22.bal @@ -0,0 +1,8 @@ +public function test() { + retry { + fail error SampleError("Transaction Failure", error("Database Error"), userCode = 20, + info = ["Detail_Info_1", "Detail_Info_2"], posInfo = {row: 45}); + } on fail SampleError error(message, error(msg), userCode = code, info = [info1, info2], posInfo = {row: posRow}) { + io:println(posRow); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_23.bal b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_23.bal new file mode 100644 index 000000000000..6d4f392507ad --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_23.bal @@ -0,0 +1,7 @@ +public function test() { + retry { + fail error SampleError("error!", code = 20, reason = "foo"); + } on fail error error(code = errorCode) { + io:println(errorCode); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_24.bal b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_24.bal new file mode 100644 index 000000000000..439d79b001d3 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_24.bal @@ -0,0 +1,7 @@ +public function test() { + retry { + fail error("error!"); + } on fail anydata error(err) { + io:println(err); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_25.bal b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_25.bal new file mode 100644 index 000000000000..5efdb824f211 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_25.bal @@ -0,0 +1,7 @@ +public function test() { + retry { + fail error("error!"); + } on fail int error(err) { + io:println(err); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_07.json b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_07.json index 8a42c39b91f2..29b5cfbdb4d6 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_07.json +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_07.json @@ -1,5 +1,6 @@ { "kind": "FUNCTION_DEFINITION", + "hasDiagnostics": true, "children": [ { "kind": "LIST", @@ -45,6 +46,7 @@ }, { "kind": "FUNCTION_BODY_BLOCK", + "hasDiagnostics": true, "children": [ { "kind": "OPEN_BRACE_TOKEN", @@ -57,9 +59,11 @@ }, { "kind": "LIST", + "hasDiagnostics": true, "children": [ { "kind": "TRANSACTION_STATEMENT", + "hasDiagnostics": true, "children": [ { "kind": "TRANSACTION_KEYWORD", @@ -111,6 +115,7 @@ }, { "kind": "ON_FAIL_CLAUSE", + "hasDiagnostics": true, "children": [ { "kind": "ON_KEYWORD", @@ -288,6 +293,7 @@ }, { "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, "children": [ { "kind": "OPEN_BRACE_TOKEN", @@ -300,267 +306,86 @@ }, { "kind": "LIST", + "hasDiagnostics": true, "children": [ { - "kind": "CALL_STATEMENT", + "kind": "LOCAL_VAR_DECL", + "hasDiagnostics": true, "children": [ { - "kind": "FUNCTION_CALL", - "children": [ - { - "kind": "QUALIFIED_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "message" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] + "kind": "LIST", + "children": [] }, { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "CALL_STATEMENT", - "children": [ - { - "kind": "FUNCTION_CALL", + "kind": "TYPED_BINDING_PATTERN", "children": [ { - "kind": "QUALIFIED_NAME_REFERENCE", + "kind": "INT_TYPE_DESC", "children": [ { - "kind": "IDENTIFIER_TOKEN", - "value": "io", + "kind": "INT_KEYWORD", "leadingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", "value": " " } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ + ], + "trailingMinutiae": [ { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "cause" - } - ] + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] } ] }, { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "CALL_STATEMENT", - "children": [ - { - "kind": "FUNCTION_CALL", - "children": [ - { - "kind": "QUALIFIED_NAME_REFERENCE", + "kind": "CAPTURE_BINDING_PATTERN", "children": [ { "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ + "value": "a", + "trailingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "code" - } - ] + "value": " " } ] } ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" } ] }, { - "kind": "SEMICOLON_TOKEN", + "kind": "EQUAL_TOKEN", "trailingMinutiae": [ { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] - } - ] - }, - { - "kind": "CALL_STATEMENT", - "children": [ + }, { - "kind": "FUNCTION_CALL", + "kind": "SIMPLE_NAME_REFERENCE", "children": [ { - "kind": "QUALIFIED_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ + "kind": "IDENTIFIER_TOKEN", + "value": "code", + "trailingMinutiae": [ { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "reason" - } - ] - } - ] + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" } ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" } ] }, { "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_SEMICOLON_TOKEN" ] } ] @@ -590,6 +415,7 @@ }, { "kind": "TRANSACTION_STATEMENT", + "hasDiagnostics": true, "children": [ { "kind": "TRANSACTION_KEYWORD", @@ -722,6 +548,7 @@ }, { "kind": "ON_FAIL_CLAUSE", + "hasDiagnostics": true, "children": [ { "kind": "ON_KEYWORD", @@ -899,6 +726,7 @@ }, { "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, "children": [ { "kind": "OPEN_BRACE_TOKEN", @@ -911,267 +739,86 @@ }, { "kind": "LIST", + "hasDiagnostics": true, "children": [ { - "kind": "CALL_STATEMENT", + "kind": "LOCAL_VAR_DECL", + "hasDiagnostics": true, "children": [ { - "kind": "FUNCTION_CALL", + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", "children": [ { - "kind": "QUALIFIED_NAME_REFERENCE", + "kind": "INT_TYPE_DESC", "children": [ { - "kind": "IDENTIFIER_TOKEN", - "value": "io", + "kind": "INT_KEYWORD", "leadingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", "value": " " } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" } ] }, { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", + "kind": "CAPTURE_BINDING_PATTERN", "children": [ { - "kind": "POSITIONAL_ARG", - "children": [ + "kind": "IDENTIFIER_TOKEN", + "value": "a", + "trailingMinutiae": [ { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "message" - } - ] + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] } ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" } ] }, { - "kind": "SEMICOLON_TOKEN", + "kind": "EQUAL_TOKEN", "trailingMinutiae": [ { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] - } - ] - }, - { - "kind": "CALL_STATEMENT", - "children": [ + }, { - "kind": "FUNCTION_CALL", + "kind": "SIMPLE_NAME_REFERENCE", "children": [ { - "kind": "QUALIFIED_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ + "kind": "IDENTIFIER_TOKEN", + "value": "code", + "trailingMinutiae": [ { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "cause" - } - ] - } - ] + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" } ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" } ] }, { "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "CALL_STATEMENT", - "children": [ - { - "kind": "FUNCTION_CALL", - "children": [ - { - "kind": "QUALIFIED_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "code" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "CALL_STATEMENT", - "children": [ - { - "kind": "FUNCTION_CALL", - "children": [ - { - "kind": "QUALIFIED_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "reason" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_SEMICOLON_TOKEN" ] } ] @@ -1201,6 +848,7 @@ }, { "kind": "TRANSACTION_STATEMENT", + "hasDiagnostics": true, "children": [ { "kind": "TRANSACTION_KEYWORD", @@ -1417,6 +1065,7 @@ }, { "kind": "ON_FAIL_CLAUSE", + "hasDiagnostics": true, "children": [ { "kind": "ON_KEYWORD", @@ -1594,6 +1243,7 @@ }, { "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, "children": [ { "kind": "OPEN_BRACE_TOKEN", @@ -1606,276 +1256,95 @@ }, { "kind": "LIST", + "hasDiagnostics": true, "children": [ { - "kind": "CALL_STATEMENT", + "kind": "LOCAL_VAR_DECL", + "hasDiagnostics": true, "children": [ { - "kind": "FUNCTION_CALL", + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", "children": [ { - "kind": "QUALIFIED_NAME_REFERENCE", + "kind": "INT_TYPE_DESC", "children": [ { - "kind": "IDENTIFIER_TOKEN", - "value": "io", + "kind": "INT_KEYWORD", "leadingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", "value": " " } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ + ], + "trailingMinutiae": [ { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "message" - } - ] + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] } ] }, { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "CALL_STATEMENT", - "children": [ - { - "kind": "FUNCTION_CALL", - "children": [ - { - "kind": "QUALIFIED_NAME_REFERENCE", + "kind": "CAPTURE_BINDING_PATTERN", "children": [ { "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ + "value": "a", + "trailingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "cause" - } - ] + "value": " " } ] } ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" } ] }, { - "kind": "SEMICOLON_TOKEN", + "kind": "EQUAL_TOKEN", "trailingMinutiae": [ { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] - } - ] - }, - { - "kind": "CALL_STATEMENT", - "children": [ + }, { - "kind": "FUNCTION_CALL", + "kind": "SIMPLE_NAME_REFERENCE", "children": [ { - "kind": "QUALIFIED_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ + "kind": "IDENTIFIER_TOKEN", + "value": "code", + "trailingMinutiae": [ { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "code" - } - ] - } - ] + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" } ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" } ] }, { "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_SEMICOLON_TOKEN" ] } ] - }, - { - "kind": "CALL_STATEMENT", - "children": [ - { - "kind": "FUNCTION_CALL", - "children": [ - { - "kind": "QUALIFIED_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "reason" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "leadingMinutiae": [ + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", "value": " " @@ -1896,6 +1365,7 @@ }, { "kind": "TRANSACTION_STATEMENT", + "hasDiagnostics": true, "children": [ { "kind": "TRANSACTION_KEYWORD", @@ -1918,6 +1388,7 @@ }, { "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, "children": [ { "kind": "OPEN_BRACE_TOKEN", @@ -1930,9 +1401,11 @@ }, { "kind": "LIST", + "hasDiagnostics": true, "children": [ { "kind": "TRANSACTION_STATEMENT", + "hasDiagnostics": true, "children": [ { "kind": "TRANSACTION_KEYWORD", @@ -1951,6 +1424,7 @@ }, { "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, "children": [ { "kind": "OPEN_BRACE_TOKEN", @@ -1963,9 +1437,11 @@ }, { "kind": "LIST", + "hasDiagnostics": true, "children": [ { "kind": "TRANSACTION_STATEMENT", + "hasDiagnostics": true, "children": [ { "kind": "TRANSACTION_KEYWORD", @@ -2070,6 +1546,7 @@ }, { "kind": "ON_FAIL_CLAUSE", + "hasDiagnostics": true, "children": [ { "kind": "ON_KEYWORD", @@ -2247,6 +1724,7 @@ }, { "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, "children": [ { "kind": "OPEN_BRACE_TOKEN", @@ -2259,267 +1737,86 @@ }, { "kind": "LIST", + "hasDiagnostics": true, "children": [ { - "kind": "CALL_STATEMENT", + "kind": "LOCAL_VAR_DECL", + "hasDiagnostics": true, "children": [ { - "kind": "FUNCTION_CALL", - "children": [ - { - "kind": "QUALIFIED_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "message" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] + "kind": "LIST", + "children": [] }, { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "CALL_STATEMENT", - "children": [ - { - "kind": "FUNCTION_CALL", + "kind": "TYPED_BINDING_PATTERN", "children": [ { - "kind": "QUALIFIED_NAME_REFERENCE", + "kind": "INT_TYPE_DESC", "children": [ { - "kind": "IDENTIFIER_TOKEN", - "value": "io", + "kind": "INT_KEYWORD", "leadingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", "value": " " } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ + ], + "trailingMinutiae": [ { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "cause" - } - ] + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] } ] }, { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "CALL_STATEMENT", - "children": [ - { - "kind": "FUNCTION_CALL", - "children": [ - { - "kind": "QUALIFIED_NAME_REFERENCE", + "kind": "CAPTURE_BINDING_PATTERN", "children": [ { "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ + "value": "a", + "trailingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", - "value": " " + "value": " " } ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" } ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "code" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" } ] }, { - "kind": "SEMICOLON_TOKEN", + "kind": "EQUAL_TOKEN", "trailingMinutiae": [ { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] - } - ] - }, - { - "kind": "CALL_STATEMENT", - "children": [ + }, { - "kind": "FUNCTION_CALL", + "kind": "SIMPLE_NAME_REFERENCE", "children": [ { - "kind": "QUALIFIED_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ + "kind": "IDENTIFIER_TOKEN", + "value": "code", + "trailingMinutiae": [ { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "reason" - } - ] - } - ] + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" } ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" } ] }, { "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_SEMICOLON_TOKEN" ] } ] @@ -2589,6 +1886,7 @@ }, { "kind": "ON_FAIL_CLAUSE", + "hasDiagnostics": true, "children": [ { "kind": "ON_KEYWORD", @@ -2766,6 +2064,7 @@ }, { "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, "children": [ { "kind": "OPEN_BRACE_TOKEN", @@ -2778,267 +2077,86 @@ }, { "kind": "LIST", + "hasDiagnostics": true, "children": [ { - "kind": "CALL_STATEMENT", + "kind": "LOCAL_VAR_DECL", + "hasDiagnostics": true, "children": [ { - "kind": "FUNCTION_CALL", - "children": [ - { - "kind": "QUALIFIED_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "message" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] + "kind": "LIST", + "children": [] }, { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "CALL_STATEMENT", - "children": [ - { - "kind": "FUNCTION_CALL", + "kind": "TYPED_BINDING_PATTERN", "children": [ { - "kind": "QUALIFIED_NAME_REFERENCE", + "kind": "INT_TYPE_DESC", "children": [ { - "kind": "IDENTIFIER_TOKEN", - "value": "io", + "kind": "INT_KEYWORD", "leadingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", "value": " " } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ + ], + "trailingMinutiae": [ { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "cause" - } - ] + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] } ] }, { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "CALL_STATEMENT", - "children": [ - { - "kind": "FUNCTION_CALL", - "children": [ - { - "kind": "QUALIFIED_NAME_REFERENCE", + "kind": "CAPTURE_BINDING_PATTERN", "children": [ { "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ + "value": "a", + "trailingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "code" - } - ] + "value": " " } ] } ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" } ] }, { - "kind": "SEMICOLON_TOKEN", + "kind": "EQUAL_TOKEN", "trailingMinutiae": [ { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] - } - ] - }, - { - "kind": "CALL_STATEMENT", - "children": [ + }, { - "kind": "FUNCTION_CALL", + "kind": "SIMPLE_NAME_REFERENCE", "children": [ { - "kind": "QUALIFIED_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ + "kind": "IDENTIFIER_TOKEN", + "value": "code", + "trailingMinutiae": [ { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "reason" - } - ] - } - ] + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" } ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" } ] }, { "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_SEMICOLON_TOKEN" ] } ] diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_08.json b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_08.json index 6417eea794d8..f0381d556e70 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_08.json +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_08.json @@ -1,5 +1,6 @@ { "kind": "FUNCTION_DEFINITION", + "hasDiagnostics": true, "children": [ { "kind": "LIST", @@ -45,6 +46,7 @@ }, { "kind": "FUNCTION_BODY_BLOCK", + "hasDiagnostics": true, "children": [ { "kind": "OPEN_BRACE_TOKEN", @@ -57,9 +59,11 @@ }, { "kind": "LIST", + "hasDiagnostics": true, "children": [ { "kind": "TRANSACTION_STATEMENT", + "hasDiagnostics": true, "children": [ { "kind": "TRANSACTION_KEYWORD", @@ -111,6 +115,7 @@ }, { "kind": "ON_FAIL_CLAUSE", + "hasDiagnostics": true, "children": [ { "kind": "ON_KEYWORD", @@ -287,6 +292,7 @@ }, { "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, "children": [ { "kind": "OPEN_BRACE_TOKEN", @@ -299,267 +305,86 @@ }, { "kind": "LIST", + "hasDiagnostics": true, "children": [ { - "kind": "CALL_STATEMENT", + "kind": "LOCAL_VAR_DECL", + "hasDiagnostics": true, "children": [ { - "kind": "FUNCTION_CALL", - "children": [ - { - "kind": "QUALIFIED_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "message" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] + "kind": "LIST", + "children": [] }, { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "CALL_STATEMENT", - "children": [ - { - "kind": "FUNCTION_CALL", + "kind": "TYPED_BINDING_PATTERN", "children": [ { - "kind": "QUALIFIED_NAME_REFERENCE", + "kind": "INT_TYPE_DESC", "children": [ { - "kind": "IDENTIFIER_TOKEN", - "value": "io", + "kind": "INT_KEYWORD", "leadingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", "value": " " } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ + ], + "trailingMinutiae": [ { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "cause" - } - ] + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] } ] }, { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "CALL_STATEMENT", - "children": [ - { - "kind": "FUNCTION_CALL", - "children": [ - { - "kind": "QUALIFIED_NAME_REFERENCE", + "kind": "CAPTURE_BINDING_PATTERN", "children": [ { "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ + "value": "a", + "trailingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "code" - } - ] + "value": " " } ] } ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" } ] }, { - "kind": "SEMICOLON_TOKEN", + "kind": "EQUAL_TOKEN", "trailingMinutiae": [ { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] - } - ] - }, - { - "kind": "CALL_STATEMENT", - "children": [ + }, { - "kind": "FUNCTION_CALL", + "kind": "SIMPLE_NAME_REFERENCE", "children": [ { - "kind": "QUALIFIED_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ + "kind": "IDENTIFIER_TOKEN", + "value": "code", + "trailingMinutiae": [ { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "reason" - } - ] - } - ] + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" } ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" } ] }, { "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_SEMICOLON_TOKEN" ] } ] @@ -589,6 +414,7 @@ }, { "kind": "TRANSACTION_STATEMENT", + "hasDiagnostics": true, "children": [ { "kind": "TRANSACTION_KEYWORD", @@ -721,6 +547,7 @@ }, { "kind": "ON_FAIL_CLAUSE", + "hasDiagnostics": true, "children": [ { "kind": "ON_KEYWORD", @@ -897,6 +724,7 @@ }, { "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, "children": [ { "kind": "OPEN_BRACE_TOKEN", @@ -909,267 +737,86 @@ }, { "kind": "LIST", + "hasDiagnostics": true, "children": [ { - "kind": "CALL_STATEMENT", + "kind": "LOCAL_VAR_DECL", + "hasDiagnostics": true, "children": [ { - "kind": "FUNCTION_CALL", + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", "children": [ { - "kind": "QUALIFIED_NAME_REFERENCE", + "kind": "INT_TYPE_DESC", "children": [ { - "kind": "IDENTIFIER_TOKEN", - "value": "io", + "kind": "INT_KEYWORD", "leadingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", "value": " " } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" } ] }, { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", + "kind": "CAPTURE_BINDING_PATTERN", "children": [ { - "kind": "POSITIONAL_ARG", - "children": [ + "kind": "IDENTIFIER_TOKEN", + "value": "a", + "trailingMinutiae": [ { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "message" - } - ] + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] } ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" } ] }, { - "kind": "SEMICOLON_TOKEN", + "kind": "EQUAL_TOKEN", "trailingMinutiae": [ { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] - } - ] - }, - { - "kind": "CALL_STATEMENT", - "children": [ + }, { - "kind": "FUNCTION_CALL", + "kind": "SIMPLE_NAME_REFERENCE", "children": [ { - "kind": "QUALIFIED_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ + "kind": "IDENTIFIER_TOKEN", + "value": "code", + "trailingMinutiae": [ { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "cause" - } - ] - } - ] + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" } ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" } ] }, { "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "CALL_STATEMENT", - "children": [ - { - "kind": "FUNCTION_CALL", - "children": [ - { - "kind": "QUALIFIED_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "code" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "CALL_STATEMENT", - "children": [ - { - "kind": "FUNCTION_CALL", - "children": [ - { - "kind": "QUALIFIED_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "reason" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_SEMICOLON_TOKEN" ] } ] @@ -1199,6 +846,7 @@ }, { "kind": "TRANSACTION_STATEMENT", + "hasDiagnostics": true, "children": [ { "kind": "TRANSACTION_KEYWORD", @@ -1415,6 +1063,7 @@ }, { "kind": "ON_FAIL_CLAUSE", + "hasDiagnostics": true, "children": [ { "kind": "ON_KEYWORD", @@ -1591,6 +1240,7 @@ }, { "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, "children": [ { "kind": "OPEN_BRACE_TOKEN", @@ -1603,276 +1253,95 @@ }, { "kind": "LIST", + "hasDiagnostics": true, "children": [ { - "kind": "CALL_STATEMENT", + "kind": "LOCAL_VAR_DECL", + "hasDiagnostics": true, "children": [ { - "kind": "FUNCTION_CALL", + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", "children": [ { - "kind": "QUALIFIED_NAME_REFERENCE", + "kind": "INT_TYPE_DESC", "children": [ { - "kind": "IDENTIFIER_TOKEN", - "value": "io", + "kind": "INT_KEYWORD", "leadingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", "value": " " } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ + ], + "trailingMinutiae": [ { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "message" - } - ] + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] } ] }, { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "CALL_STATEMENT", - "children": [ - { - "kind": "FUNCTION_CALL", - "children": [ - { - "kind": "QUALIFIED_NAME_REFERENCE", + "kind": "CAPTURE_BINDING_PATTERN", "children": [ { "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ + "value": "a", + "trailingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "cause" - } - ] + "value": " " } ] } ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" } ] }, { - "kind": "SEMICOLON_TOKEN", + "kind": "EQUAL_TOKEN", "trailingMinutiae": [ { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] - } - ] - }, - { - "kind": "CALL_STATEMENT", - "children": [ + }, { - "kind": "FUNCTION_CALL", + "kind": "SIMPLE_NAME_REFERENCE", "children": [ { - "kind": "QUALIFIED_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ + "kind": "IDENTIFIER_TOKEN", + "value": "code", + "trailingMinutiae": [ { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "code" - } - ] - } - ] + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" } ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" } ] }, { "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_SEMICOLON_TOKEN" ] } ] - }, - { - "kind": "CALL_STATEMENT", - "children": [ - { - "kind": "FUNCTION_CALL", - "children": [ - { - "kind": "QUALIFIED_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "reason" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_BRACE_TOKEN", - "leadingMinutiae": [ + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", "value": " " @@ -1893,6 +1362,7 @@ }, { "kind": "TRANSACTION_STATEMENT", + "hasDiagnostics": true, "children": [ { "kind": "TRANSACTION_KEYWORD", @@ -1915,6 +1385,7 @@ }, { "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, "children": [ { "kind": "OPEN_BRACE_TOKEN", @@ -1927,9 +1398,11 @@ }, { "kind": "LIST", + "hasDiagnostics": true, "children": [ { "kind": "TRANSACTION_STATEMENT", + "hasDiagnostics": true, "children": [ { "kind": "TRANSACTION_KEYWORD", @@ -1948,6 +1421,7 @@ }, { "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, "children": [ { "kind": "OPEN_BRACE_TOKEN", @@ -1960,9 +1434,11 @@ }, { "kind": "LIST", + "hasDiagnostics": true, "children": [ { "kind": "TRANSACTION_STATEMENT", + "hasDiagnostics": true, "children": [ { "kind": "TRANSACTION_KEYWORD", @@ -2067,6 +1543,7 @@ }, { "kind": "ON_FAIL_CLAUSE", + "hasDiagnostics": true, "children": [ { "kind": "ON_KEYWORD", @@ -2243,6 +1720,7 @@ }, { "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, "children": [ { "kind": "OPEN_BRACE_TOKEN", @@ -2255,267 +1733,86 @@ }, { "kind": "LIST", + "hasDiagnostics": true, "children": [ { - "kind": "CALL_STATEMENT", + "kind": "LOCAL_VAR_DECL", + "hasDiagnostics": true, "children": [ { - "kind": "FUNCTION_CALL", - "children": [ - { - "kind": "QUALIFIED_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "message" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] + "kind": "LIST", + "children": [] }, { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "CALL_STATEMENT", - "children": [ - { - "kind": "FUNCTION_CALL", + "kind": "TYPED_BINDING_PATTERN", "children": [ { - "kind": "QUALIFIED_NAME_REFERENCE", + "kind": "INT_TYPE_DESC", "children": [ { - "kind": "IDENTIFIER_TOKEN", - "value": "io", + "kind": "INT_KEYWORD", "leadingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", "value": " " } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ + ], + "trailingMinutiae": [ { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "cause" - } - ] + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] } ] }, { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "CALL_STATEMENT", - "children": [ - { - "kind": "FUNCTION_CALL", - "children": [ - { - "kind": "QUALIFIED_NAME_REFERENCE", + "kind": "CAPTURE_BINDING_PATTERN", "children": [ { "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ + "value": "a", + "trailingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", - "value": " " + "value": " " } ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" } ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "code" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" } ] }, { - "kind": "SEMICOLON_TOKEN", + "kind": "EQUAL_TOKEN", "trailingMinutiae": [ { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] - } - ] - }, - { - "kind": "CALL_STATEMENT", - "children": [ + }, { - "kind": "FUNCTION_CALL", + "kind": "SIMPLE_NAME_REFERENCE", "children": [ { - "kind": "QUALIFIED_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ + "kind": "IDENTIFIER_TOKEN", + "value": "code", + "trailingMinutiae": [ { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "reason" - } - ] - } - ] + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" } ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" } ] }, { "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_SEMICOLON_TOKEN" ] } ] @@ -2585,6 +1882,7 @@ }, { "kind": "ON_FAIL_CLAUSE", + "hasDiagnostics": true, "children": [ { "kind": "ON_KEYWORD", @@ -2761,6 +2059,7 @@ }, { "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, "children": [ { "kind": "OPEN_BRACE_TOKEN", @@ -2773,267 +2072,86 @@ }, { "kind": "LIST", + "hasDiagnostics": true, "children": [ { - "kind": "CALL_STATEMENT", + "kind": "LOCAL_VAR_DECL", + "hasDiagnostics": true, "children": [ { - "kind": "FUNCTION_CALL", - "children": [ - { - "kind": "QUALIFIED_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "message" - } - ] - } - ] - } - ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" - } - ] + "kind": "LIST", + "children": [] }, { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "CALL_STATEMENT", - "children": [ - { - "kind": "FUNCTION_CALL", + "kind": "TYPED_BINDING_PATTERN", "children": [ { - "kind": "QUALIFIED_NAME_REFERENCE", + "kind": "INT_TYPE_DESC", "children": [ { - "kind": "IDENTIFIER_TOKEN", - "value": "io", + "kind": "INT_KEYWORD", "leadingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", "value": " " } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ + ], + "trailingMinutiae": [ { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "cause" - } - ] + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] } ] }, { - "kind": "CLOSE_PAREN_TOKEN" - } - ] - }, - { - "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } - ] - } - ] - }, - { - "kind": "CALL_STATEMENT", - "children": [ - { - "kind": "FUNCTION_CALL", - "children": [ - { - "kind": "QUALIFIED_NAME_REFERENCE", + "kind": "CAPTURE_BINDING_PATTERN", "children": [ { "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ + "value": "a", + "trailingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ - { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "code" - } - ] + "value": " " } ] } ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" } ] }, { - "kind": "SEMICOLON_TOKEN", + "kind": "EQUAL_TOKEN", "trailingMinutiae": [ { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" + "kind": "WHITESPACE_MINUTIAE", + "value": " " } ] - } - ] - }, - { - "kind": "CALL_STATEMENT", - "children": [ + }, { - "kind": "FUNCTION_CALL", + "kind": "SIMPLE_NAME_REFERENCE", "children": [ { - "kind": "QUALIFIED_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "io", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] - }, - { - "kind": "COLON_TOKEN" - }, - { - "kind": "IDENTIFIER_TOKEN", - "value": "println" - } - ] - }, - { - "kind": "OPEN_PAREN_TOKEN" - }, - { - "kind": "LIST", - "children": [ + "kind": "IDENTIFIER_TOKEN", + "value": "code", + "trailingMinutiae": [ { - "kind": "POSITIONAL_ARG", - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "value": "reason" - } - ] - } - ] + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" } ] - }, - { - "kind": "CLOSE_PAREN_TOKEN" } ] }, { "kind": "SEMICOLON_TOKEN", - "trailingMinutiae": [ - { - "kind": "END_OF_LINE_MINUTIAE", - "value": "\n" - } + "isMissing": true, + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_MISSING_SEMICOLON_TOKEN" ] } ] diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_13.json b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_13.json new file mode 100644 index 000000000000..f7fc01a2bd14 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_13.json @@ -0,0 +1,1563 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "foo" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "LIST_BINDING_PATTERN", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "a", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "5" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "LIST_BINDING_PATTERN", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "STRING_TYPE_DESC", + "children": [ + { + "kind": "STRING_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "b" + } + ] + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "LIST_BINDING_PATTERN", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "STRING_TYPE_DESC", + "children": [ + { + "kind": "STRING_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "b" + } + ] + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "LIST_BINDING_PATTERN", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "LIST_BINDING_PATTERN", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_14.json b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_14.json new file mode 100644 index 000000000000..4e62ced83955 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_14.json @@ -0,0 +1,1678 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "foo" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "MAPPING_BINDING_PATTERN", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FIELD_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "failError" + } + ] + }, + { + "kind": "COLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "a", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "5" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "MAPPING_BINDING_PATTERN", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FIELD_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "failError" + } + ] + }, + { + "kind": "COLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "STRING_TYPE_DESC", + "children": [ + { + "kind": "STRING_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "b" + } + ] + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "MAPPING_BINDING_PATTERN", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FIELD_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "failError" + } + ] + }, + { + "kind": "COLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "STRING_TYPE_DESC", + "children": [ + { + "kind": "STRING_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "b" + } + ] + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "MAPPING_BINDING_PATTERN", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FIELD_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "failError" + } + ] + }, + { + "kind": "COLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "MAPPING_BINDING_PATTERN", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FIELD_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "failError" + } + ] + }, + { + "kind": "COLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_15.json b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_15.json new file mode 100644 index 000000000000..f962470fb1de --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_15.json @@ -0,0 +1,1143 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "foo" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "WILDCARD_BINDING_PATTERN", + "children": [ + { + "kind": "UNDERSCORE_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "a", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "5" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "WILDCARD_BINDING_PATTERN", + "children": [ + { + "kind": "UNDERSCORE_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "STRING_TYPE_DESC", + "children": [ + { + "kind": "STRING_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "b" + } + ] + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "WILDCARD_BINDING_PATTERN", + "children": [ + { + "kind": "UNDERSCORE_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "STRING_TYPE_DESC", + "children": [ + { + "kind": "STRING_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "b" + } + ] + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "WILDCARD_BINDING_PATTERN", + "children": [ + { + "kind": "UNDERSCORE_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "WILDCARD_BINDING_PATTERN", + "children": [ + { + "kind": "UNDERSCORE_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_16.json b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_16.json new file mode 100644 index 000000000000..0acf7c927371 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_16.json @@ -0,0 +1,1688 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "foo" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "TUPLE_TYPE_DESC", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "MEMBER_TYPE_DESC", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "LIST_BINDING_PATTERN", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "a", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "5" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "TUPLE_TYPE_DESC", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "MEMBER_TYPE_DESC", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "LIST_BINDING_PATTERN", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "STRING_TYPE_DESC", + "children": [ + { + "kind": "STRING_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "b" + } + ] + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "TUPLE_TYPE_DESC", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "MEMBER_TYPE_DESC", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "LIST_BINDING_PATTERN", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "STRING_TYPE_DESC", + "children": [ + { + "kind": "STRING_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "b" + } + ] + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "TUPLE_TYPE_DESC", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "MEMBER_TYPE_DESC", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "LIST_BINDING_PATTERN", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "TUPLE_TYPE_DESC", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "MEMBER_TYPE_DESC", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "LIST_BINDING_PATTERN", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_17.json b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_17.json new file mode 100644 index 000000000000..889bdd437086 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_17.json @@ -0,0 +1,2188 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "foo" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "msg" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userReason", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "reason" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "msg" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "a", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "5" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "msg" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userReason", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "reason" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "msg" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "STRING_TYPE_DESC", + "children": [ + { + "kind": "STRING_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "b" + } + ] + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "msg" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userReason", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "reason" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "msg" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "STRING_TYPE_DESC", + "children": [ + { + "kind": "STRING_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "b" + } + ] + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "msg" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userReason", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "reason" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "msg" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "msg" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userReason", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "reason" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "msg" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_18.json b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_18.json new file mode 100644 index 000000000000..498b505bca76 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_18.json @@ -0,0 +1,2358 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "foo" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "msg" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "LIST_BINDING_PATTERN", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info1" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info2" + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info1" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "a", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "5" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "msg" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "LIST_BINDING_PATTERN", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info1" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info2" + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info1" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "STRING_TYPE_DESC", + "children": [ + { + "kind": "STRING_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "b" + } + ] + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "msg" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "LIST_BINDING_PATTERN", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info1" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info2" + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info1" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "STRING_TYPE_DESC", + "children": [ + { + "kind": "STRING_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "b" + } + ] + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "msg" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "LIST_BINDING_PATTERN", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info1" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info2" + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info1" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "msg" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "LIST_BINDING_PATTERN", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info1" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info2" + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info1" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_19.json b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_19.json new file mode 100644 index 000000000000..e6023a117d31 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_19.json @@ -0,0 +1,2763 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "foo" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "msg" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "LIST_BINDING_PATTERN", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info1" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info2" + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "posInfo", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "MAPPING_BINDING_PATTERN", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FIELD_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "row" + } + ] + }, + { + "kind": "COLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "posRow" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "posRow" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "a", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "5" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "msg" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "LIST_BINDING_PATTERN", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info1" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info2" + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "posInfo", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "MAPPING_BINDING_PATTERN", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FIELD_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "row" + } + ] + }, + { + "kind": "COLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "posRow" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "posRow" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "STRING_TYPE_DESC", + "children": [ + { + "kind": "STRING_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "b" + } + ] + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "msg" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "LIST_BINDING_PATTERN", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info1" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info2" + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "posInfo", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "MAPPING_BINDING_PATTERN", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FIELD_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "row" + } + ] + }, + { + "kind": "COLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "posRow" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "posRow" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "STRING_TYPE_DESC", + "children": [ + { + "kind": "STRING_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "b" + } + ] + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "msg" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "LIST_BINDING_PATTERN", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info1" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info2" + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "posInfo", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "MAPPING_BINDING_PATTERN", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FIELD_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "row" + } + ] + }, + { + "kind": "COLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "posRow" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "posRow" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "msg" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "LIST_BINDING_PATTERN", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info1" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info2" + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "posInfo", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "MAPPING_BINDING_PATTERN", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FIELD_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "row" + } + ] + }, + { + "kind": "COLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "posRow" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "posRow" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_20.json b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_20.json new file mode 100644 index 000000000000..609d5aa1d98c --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_20.json @@ -0,0 +1,2008 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "foo" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "TYPE_PARAMETER", + "children": [ + { + "kind": "LT_TOKEN" + }, + { + "kind": "RECORD_TYPE_DESC", + "children": [ + { + "kind": "RECORD_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "OPEN_BRACE_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "RECORD_FIELD", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + }, + { + "kind": "SEMICOLON_TOKEN" + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN" + } + ] + }, + { + "kind": "GT_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "errorCode" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "errorCode" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "a", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "5" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "TYPE_PARAMETER", + "children": [ + { + "kind": "LT_TOKEN" + }, + { + "kind": "RECORD_TYPE_DESC", + "children": [ + { + "kind": "RECORD_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "OPEN_BRACE_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "RECORD_FIELD", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + }, + { + "kind": "SEMICOLON_TOKEN" + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN" + } + ] + }, + { + "kind": "GT_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "errorCode" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "errorCode" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "STRING_TYPE_DESC", + "children": [ + { + "kind": "STRING_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "b" + } + ] + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "TYPE_PARAMETER", + "children": [ + { + "kind": "LT_TOKEN" + }, + { + "kind": "RECORD_TYPE_DESC", + "children": [ + { + "kind": "RECORD_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "OPEN_BRACE_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "RECORD_FIELD", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + }, + { + "kind": "SEMICOLON_TOKEN" + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN" + } + ] + }, + { + "kind": "GT_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "errorCode" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "errorCode" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "STRING_TYPE_DESC", + "children": [ + { + "kind": "STRING_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "b" + } + ] + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "TYPE_PARAMETER", + "children": [ + { + "kind": "LT_TOKEN" + }, + { + "kind": "RECORD_TYPE_DESC", + "children": [ + { + "kind": "RECORD_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "OPEN_BRACE_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "RECORD_FIELD", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + }, + { + "kind": "SEMICOLON_TOKEN" + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN" + } + ] + }, + { + "kind": "GT_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "errorCode" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "errorCode" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "TYPE_PARAMETER", + "children": [ + { + "kind": "LT_TOKEN" + }, + { + "kind": "RECORD_TYPE_DESC", + "children": [ + { + "kind": "RECORD_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "OPEN_BRACE_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "RECORD_FIELD", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + }, + { + "kind": "SEMICOLON_TOKEN" + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN" + } + ] + }, + { + "kind": "GT_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "errorCode" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "errorCode" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_21.json b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_21.json new file mode 100644 index 000000000000..ea410b177357 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_21.json @@ -0,0 +1,1578 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "foo" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "ANYDATA_TYPE_DESC", + "children": [ + { + "kind": "ANYDATA_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "a", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "5" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "ANYDATA_TYPE_DESC", + "children": [ + { + "kind": "ANYDATA_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "STRING_TYPE_DESC", + "children": [ + { + "kind": "STRING_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "b" + } + ] + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "ANYDATA_TYPE_DESC", + "children": [ + { + "kind": "ANYDATA_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "STRING_TYPE_DESC", + "children": [ + { + "kind": "STRING_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "b" + } + ] + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "ANYDATA_TYPE_DESC", + "children": [ + { + "kind": "ANYDATA_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "ANYDATA_TYPE_DESC", + "children": [ + { + "kind": "ANYDATA_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_22.json b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_22.json new file mode 100644 index 000000000000..190d8ca6eace --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_22.json @@ -0,0 +1,1578 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "foo" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "a", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "5" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "STRING_TYPE_DESC", + "children": [ + { + "kind": "STRING_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "b" + } + ] + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "STRING_TYPE_DESC", + "children": [ + { + "kind": "STRING_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "b" + } + ] + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_07.bal b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_07.bal index aa8987c4ad00..ea549705bc99 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_07.bal +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_07.bal @@ -1,19 +1,13 @@ function foo() { transaction { } on fail SampleError error(message, cause, userCode = code, userReason = reason) { - io:println(message); - io:println(cause); - io:println(code); - io:println(reason); + int a = code } transaction { int a = 5; } on fail SampleError error(message, cause, userCode = code, userReason = reason) { - io:println(message); - io:println(cause); - io:println(code); - io:println(reason); + int a = code } transaction { @@ -23,10 +17,7 @@ function foo() { } } } on fail SampleError error(message, cause, userCode = code, userReason = reason) { - io:println(message); - io:println(cause); - io:println(code); - io:println(reason); + int a = code } transaction { @@ -34,16 +25,10 @@ function foo() { transaction { string b; } on fail SampleError error(message, cause, userCode = code, userReason = reason) { - io:println(message); - io:println(cause); - io:println(code); - io:println(reason); + int a = code } } } on fail SampleError error(message, cause, userCode = code, userReason = reason) { - io:println(message); - io:println(cause); - io:println(code); - io:println(reason); + int a = code } } diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_08.bal b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_08.bal index 54c6451d9eb3..8e49a3551bc4 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_08.bal +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_08.bal @@ -1,19 +1,13 @@ function foo() { transaction { } on fail var error(message, cause, userCode = code, userReason = reason) { - io:println(message); - io:println(cause); - io:println(code); - io:println(reason); + int a = code } transaction { int a = 5; } on fail var error(message, cause, userCode = code, userReason = reason) { - io:println(message); - io:println(cause); - io:println(code); - io:println(reason); + int a = code } transaction { @@ -23,10 +17,7 @@ function foo() { } } } on fail var error(message, cause, userCode = code, userReason = reason) { - io:println(message); - io:println(cause); - io:println(code); - io:println(reason); + int a = code } transaction { @@ -34,16 +25,10 @@ function foo() { transaction { string b; } on fail var error(message, cause, userCode = code, userReason = reason) { - io:println(message); - io:println(cause); - io:println(code); - io:println(reason); + int a = code } } } on fail var error(message, cause, userCode = code, userReason = reason) { - io:println(message); - io:println(cause); - io:println(code); - io:println(reason); + int a = code } } diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_13.bal b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_13.bal new file mode 100644 index 000000000000..edc275af9635 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_13.bal @@ -0,0 +1,34 @@ +function foo() { + transaction { + } on fail error [err] { + io:println(err); + } + + transaction { + int a = 5; + } on fail error [err] { + io:println(err); + } + + transaction { + transaction { + transaction { + string b; + } + } + } on fail error [err] { + io:println(err); + } + + transaction { + transaction { + transaction { + string b; + } on fail error [err] { + io:println(err); + } + } + } on fail error [err] { + io:println(err); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_14.bal b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_14.bal new file mode 100644 index 000000000000..f7bb79af5fa3 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_14.bal @@ -0,0 +1,34 @@ +function foo() { + transaction { + } on fail error {failError: err} { + io:println(err); + } + + transaction { + int a = 5; + } on fail error {failError: err} { + io:println(err); + } + + transaction { + transaction { + transaction { + string b; + } + } + } on fail error {failError: err} { + io:println(err); + } + + transaction { + transaction { + transaction { + string b; + } on fail error {failError: err} { + io:println(err); + } + } + } on fail error {failError: err} { + io:println(err); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_15.bal b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_15.bal new file mode 100644 index 000000000000..3965acb46f8c --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_15.bal @@ -0,0 +1,29 @@ +function foo() { + transaction { + } on fail error _ { + } + + transaction { + int a = 5; + } on fail error _ { + } + + transaction { + transaction { + transaction { + string b; + } + } + } on fail error _ { + } + + transaction { + transaction { + transaction { + string b; + } on fail error _ { + } + } + } on fail error _ { + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_16.bal b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_16.bal new file mode 100644 index 000000000000..07ad3da34e76 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_16.bal @@ -0,0 +1,34 @@ +function foo() { + transaction { + } on fail [error] [err] { + io:println(err); + } + + transaction { + int a = 5; + } on fail [error] [err] { + io:println(err); + } + + transaction { + transaction { + transaction { + string b; + } + } + } on fail [error] [err] { + io:println(err); + } + + transaction { + transaction { + transaction { + string b; + } on fail [error] [err] { + io:println(err); + } + } + } on fail [error] [err] { + io:println(err); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_17.bal b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_17.bal new file mode 100644 index 000000000000..942860d57ad8 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_17.bal @@ -0,0 +1,34 @@ +function foo() { + transaction { + } on fail SampleError error(message, error(msg), userCode = code, userReason = reason) { + io:println(msg); + } + + transaction { + int a = 5; + } on fail SampleError error(message, error(msg), userCode = code, userReason = reason) { + io:println(msg); + } + + transaction { + transaction { + transaction { + string b; + } + } + } on fail SampleError error(message, error(msg), userCode = code, userReason = reason) { + io:println(msg); + } + + transaction { + transaction { + transaction { + string b; + } on fail SampleError error(message, error(msg), userCode = code, userReason = reason) { + io:println(msg); + } + } + } on fail SampleError error(message, error(msg), userCode = code, userReason = reason) { + io:println(msg); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_18.bal b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_18.bal new file mode 100644 index 000000000000..f3cf4ce1b154 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_18.bal @@ -0,0 +1,34 @@ +function foo() { + transaction { + } on fail SampleError error(message, error(msg), userCode = code, info = [info1, info2]) { + io:println(info1); + } + + transaction { + int a = 5; + } on fail SampleError error(message, error(msg), userCode = code, info = [info1, info2]) { + io:println(info1); + } + + transaction { + transaction { + transaction { + string b; + } + } + } on fail SampleError error(message, error(msg), userCode = code, info = [info1, info2]) { + io:println(info1); + } + + transaction { + transaction { + transaction { + string b; + } on fail SampleError error(message, error(msg), userCode = code, info = [info1, info2]) { + io:println(info1); + } + } + } on fail SampleError error(message, error(msg), userCode = code, info = [info1, info2]) { + io:println(info1); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_19.bal b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_19.bal new file mode 100644 index 000000000000..e2ce1b8c8d17 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_19.bal @@ -0,0 +1,34 @@ +function foo() { + transaction { + } on fail SampleError error(message, error(msg), userCode = code, info = [info1, info2], posInfo = {row: posRow}) { + io:println(posRow); + } + + transaction { + int a = 5; + } on fail SampleError error(message, error(msg), userCode = code, info = [info1, info2], posInfo = {row: posRow}) { + io:println(posRow); + } + + transaction { + transaction { + transaction { + string b; + } + } + } on fail SampleError error(message, error(msg), userCode = code, info = [info1, info2], posInfo = {row: posRow}) { + io:println(posRow); + } + + transaction { + transaction { + transaction { + string b; + } on fail SampleError error(message, error(msg), userCode = code, info = [info1, info2], posInfo = {row: posRow}) { + io:println(posRow); + } + } + } on fail SampleError error(message, error(msg), userCode = code, info = [info1, info2], posInfo = {row: posRow}) { + io:println(posRow); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_20.bal b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_20.bal new file mode 100644 index 000000000000..d8a57c83cf7c --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_20.bal @@ -0,0 +1,34 @@ +function foo() { + transaction { + } on fail error error(code = errorCode) { + io:println(errorCode); + } + + transaction { + int a = 5; + } on fail error error(code = errorCode) { + io:println(errorCode); + } + + transaction { + transaction { + transaction { + string b; + } + } + } on fail error error(code = errorCode) { + io:println(errorCode); + } + + transaction { + transaction { + transaction { + string b; + } on fail error error(code = errorCode) { + io:println(errorCode); + } + } + } on fail error error(code = errorCode) { + io:println(errorCode); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_21.bal b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_21.bal new file mode 100644 index 000000000000..af6caf9e7dd4 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_21.bal @@ -0,0 +1,34 @@ +function foo() { + transaction { + } on fail anydata error(err) { + io:println(err); + } + + transaction { + int a = 5; + } on fail anydata error(err) { + io:println(err); + } + + transaction { + transaction { + transaction { + string b; + } + } + } on fail anydata error(err) { + io:println(err); + } + + transaction { + transaction { + transaction { + string b; + } on fail anydata error(err) { + io:println(err); + } + } + } on fail anydata error(err) { + io:println(err); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_22.bal b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_22.bal new file mode 100644 index 000000000000..171a62cb9bd7 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_22.bal @@ -0,0 +1,34 @@ +function foo() { + transaction { + } on fail int error(err) { + io:println(err); + } + + transaction { + int a = 5; + } on fail int error(err) { + io:println(err); + } + + transaction { + transaction { + transaction { + string b; + } + } + } on fail int error(err) { + io:println(err); + } + + transaction { + transaction { + transaction { + string b; + } on fail int error(err) { + io:println(err); + } + } + } on fail int error(err) { + io:println(err); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_15.json b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_15.json new file mode 100644 index 000000000000..87d88d496525 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_15.json @@ -0,0 +1,576 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "0" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "WHILE_STATEMENT", + "children": [ + { + "kind": "WHILE_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BINARY_EXPRESSION", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "LT_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "3", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "ASSIGNMENT_STATEMENT", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BINARY_EXPRESSION", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "PLUS_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "1" + } + ] + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "LIST_BINDING_PATTERN", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_16.json b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_16.json new file mode 100644 index 000000000000..eed9dec76c39 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_16.json @@ -0,0 +1,599 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "0" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "WHILE_STATEMENT", + "children": [ + { + "kind": "WHILE_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BINARY_EXPRESSION", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "LT_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "3", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "ASSIGNMENT_STATEMENT", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BINARY_EXPRESSION", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "PLUS_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "1" + } + ] + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "MAPPING_BINDING_PATTERN", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FIELD_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "failError" + } + ] + }, + { + "kind": "COLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_17.json b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_17.json new file mode 100644 index 000000000000..87026b3008e5 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_17.json @@ -0,0 +1,492 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "0" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "WHILE_STATEMENT", + "children": [ + { + "kind": "WHILE_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BINARY_EXPRESSION", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "LT_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "3", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "ASSIGNMENT_STATEMENT", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BINARY_EXPRESSION", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "PLUS_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "1" + } + ] + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "WILDCARD_BINDING_PATTERN", + "children": [ + { + "kind": "UNDERSCORE_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_18.json b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_18.json new file mode 100644 index 000000000000..27c9da78c49f --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_18.json @@ -0,0 +1,601 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "0" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "WHILE_STATEMENT", + "children": [ + { + "kind": "WHILE_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BINARY_EXPRESSION", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "LT_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "3", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "ASSIGNMENT_STATEMENT", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BINARY_EXPRESSION", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "PLUS_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "1" + } + ] + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "TUPLE_TYPE_DESC", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "MEMBER_TYPE_DESC", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "LIST_BINDING_PATTERN", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_19.json b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_19.json new file mode 100644 index 000000000000..9d7b9d1eb5cf --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_19.json @@ -0,0 +1,863 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "0" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "WHILE_STATEMENT", + "children": [ + { + "kind": "WHILE_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BINARY_EXPRESSION", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "LT_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "3", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "ASSIGNMENT_STATEMENT", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BINARY_EXPRESSION", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "PLUS_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "1" + } + ] + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Transaction Failure" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Database Error" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "20" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userReason", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "deadlock condition" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "msg" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userReason", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "reason" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "msg" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_20.json b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_20.json new file mode 100644 index 000000000000..e79066092797 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_20.json @@ -0,0 +1,931 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "0" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "WHILE_STATEMENT", + "children": [ + { + "kind": "WHILE_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BINARY_EXPRESSION", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "LT_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "3", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "ASSIGNMENT_STATEMENT", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BINARY_EXPRESSION", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "PLUS_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "1" + } + ] + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Transaction Failure" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Database Error" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "20" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "LIST_CONSTRUCTOR", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Detail_Info_1" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Detail_Info_2" + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "msg" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "LIST_BINDING_PATTERN", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info1" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info2" + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info1" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_21.json b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_21.json new file mode 100644 index 000000000000..adeeb1327719 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_21.json @@ -0,0 +1,1093 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "0" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "WHILE_STATEMENT", + "children": [ + { + "kind": "WHILE_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BINARY_EXPRESSION", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "LT_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "3", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "ASSIGNMENT_STATEMENT", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BINARY_EXPRESSION", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "PLUS_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "1" + } + ] + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Transaction Failure" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Database Error" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "20" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "LIST_CONSTRUCTOR", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Detail_Info_1" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "Detail_Info_2" + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "posInfo", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "MAPPING_CONSTRUCTOR", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "SPECIFIC_FIELD", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "row" + }, + { + "kind": "COLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "45" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "message" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "msg" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "userCode", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "LIST_BINDING_PATTERN", + "children": [ + { + "kind": "OPEN_BRACKET_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info1" + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "info2" + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACKET_TOKEN" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "posInfo", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "MAPPING_BINDING_PATTERN", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FIELD_BINDING_PATTERN", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "row" + } + ] + }, + { + "kind": "COLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "posRow" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "posRow" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_22.json b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_22.json new file mode 100644 index 000000000000..36468231bb33 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_22.json @@ -0,0 +1,774 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "0" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "WHILE_STATEMENT", + "children": [ + { + "kind": "WHILE_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BINARY_EXPRESSION", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "LT_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "3", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "ASSIGNMENT_STATEMENT", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BINARY_EXPRESSION", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "PLUS_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "1" + } + ] + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "SampleError" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "20" + } + ] + } + ] + }, + { + "kind": "COMMA_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NAMED_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "reason", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "foo" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_TYPE_DESC", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "TYPE_PARAMETER", + "children": [ + { + "kind": "LT_TOKEN" + }, + { + "kind": "RECORD_TYPE_DESC", + "children": [ + { + "kind": "RECORD_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "OPEN_BRACE_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "RECORD_FIELD", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "code" + }, + { + "kind": "SEMICOLON_TOKEN" + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN" + } + ] + }, + { + "kind": "GT_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "NAMED_ARG_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "code", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "errorCode" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "errorCode" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_23.json b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_23.json new file mode 100644 index 000000000000..fd37417eedca --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_23.json @@ -0,0 +1,579 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "0" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "WHILE_STATEMENT", + "children": [ + { + "kind": "WHILE_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BINARY_EXPRESSION", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "LT_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "3", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "ASSIGNMENT_STATEMENT", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BINARY_EXPRESSION", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "PLUS_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "1" + } + ] + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "ANYDATA_TYPE_DESC", + "children": [ + { + "kind": "ANYDATA_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_24.json b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_24.json new file mode 100644 index 000000000000..68731e2960c6 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_24.json @@ -0,0 +1,579 @@ +{ + "kind": "FUNCTION_DEFINITION", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "0" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "WHILE_STATEMENT", + "children": [ + { + "kind": "WHILE_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BINARY_EXPRESSION", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "LT_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "3", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "ASSIGNMENT_STATEMENT", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BINARY_EXPRESSION", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "PLUS_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "1" + } + ] + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ERROR_BINDING_PATTERN", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "CALL_STATEMENT", + "children": [ + { + "kind": "FUNCTION_CALL", + "children": [ + { + "kind": "QUALIFIED_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "io", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "COLON_TOKEN" + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "println" + } + ] + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "err" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_09.bal b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_09.bal index 90630166b3f4..2a93404682fb 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_09.bal +++ b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_09.bal @@ -13,9 +13,6 @@ public function test() { userReason = "deadlock condition"); fail err; } on fail SampleError error(message, cause, userCode = code, userReason = reason) { - io:println(message); - io:println(cause); - io:println(code); - io:println(reason); + int a = code } } diff --git a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_10.bal b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_10.bal index 1ad041418f07..3ff8fcf676f7 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_10.bal +++ b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_10.bal @@ -13,9 +13,6 @@ public function test() { userReason = "deadlock condition"); fail err; } on fail var error(message, cause, userCode = code, userReason = reason) { - io:println(message); - io:println(cause); - io:println(code); - io:println(reason); + string msg = message; } } diff --git a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_15.bal b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_15.bal new file mode 100644 index 000000000000..f9b99010a816 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_15.bal @@ -0,0 +1,9 @@ +public function test() { + int i = 0; + while i < 3 { + i = i + 1; + fail error("error!"); + } on fail error [err] { + io:println(err); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_16.bal b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_16.bal new file mode 100644 index 000000000000..39de57ad52eb --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_16.bal @@ -0,0 +1,9 @@ +public function test() { + int i = 0; + while i < 3 { + i = i + 1; + fail error("error!"); + } on fail error {failError: err} { + io:println(err); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_17.bal b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_17.bal new file mode 100644 index 000000000000..eb36357d4278 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_17.bal @@ -0,0 +1,8 @@ +public function test() { + int i = 0; + while i < 3 { + i = i + 1; + fail error("error!"); + } on fail error _ { + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_18.bal b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_18.bal new file mode 100644 index 000000000000..b5ab16497b8f --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_18.bal @@ -0,0 +1,9 @@ +public function test() { + int i = 0; + while i < 3 { + i = i + 1; + fail error("error!"); + } on fail [error] [err] { + io:println(err); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_19.bal b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_19.bal new file mode 100644 index 000000000000..34d5fddd9b1f --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_19.bal @@ -0,0 +1,10 @@ +public function test() { + int i = 0; + while i < 3 { + i = i + 1; + fail error SampleError("Transaction Failure", error("Database Error"), userCode = 20, + userReason = "deadlock condition"); + } on fail SampleError error(message, error(msg), userCode = code, userReason = reason) { + io:println(msg); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_20.bal b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_20.bal new file mode 100644 index 000000000000..bfa0ab72ab58 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_20.bal @@ -0,0 +1,10 @@ +public function test() { + int i = 0; + while i < 3 { + i = i + 1; + fail error SampleError("Transaction Failure", error("Database Error"), userCode = 20, + info = ["Detail_Info_1", "Detail_Info_2"]); + } on fail SampleError error(message, error(msg), userCode = code, info = [info1, info2]) { + io:println(info1); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_21.bal b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_21.bal new file mode 100644 index 000000000000..23e1ca4936cd --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_21.bal @@ -0,0 +1,10 @@ +public function test() { + int i = 0; + while i < 3 { + i = i + 1; + fail error SampleError("Transaction Failure", error("Database Error"), userCode = 20, + info = ["Detail_Info_1", "Detail_Info_2"], posInfo = {row: 45}); + } on fail SampleError error(message, error(msg), userCode = code, info = [info1, info2], posInfo = {row: posRow}) { + io:println(posRow); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_22.bal b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_22.bal new file mode 100644 index 000000000000..5bc406b9bb12 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_22.bal @@ -0,0 +1,9 @@ +public function test() { + int i = 0; + while i < 3 { + i = i + 1; + fail error SampleError("error!", code = 20, reason = "foo"); + } on fail error error(code = errorCode) { + io:println(errorCode); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_23.bal b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_23.bal new file mode 100644 index 000000000000..854be10f303d --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_23.bal @@ -0,0 +1,9 @@ +public function test() { + int i = 0; + while i < 3 { + i = i + 1; + fail error("error!"); + } on fail anydata error(err) { + io:println(err); + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_24.bal b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_24.bal new file mode 100644 index 000000000000..c5b489b0db45 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_24.bal @@ -0,0 +1,9 @@ +public function test() { + int i = 0; + while i < 3 { + i = i + 1; + fail error("error!"); + } on fail int error(err) { + io:println(err); + } +} From 6edaf153f1cfd626d8299b4101738c4bcf36c153 Mon Sep 17 00:00:00 2001 From: suleka96 Date: Tue, 25 Apr 2023 03:46:04 +0530 Subject: [PATCH 12/33] Add dataFlow, codeAnalyzer and desugar changes --- .../compiler/desugar/ASTBuilderUtil.java | 16 +++++++++ .../compiler/desugar/Desugar.java | 35 ++++++++++++++----- .../semantics/analyzer/CodeAnalyzer.java | 1 + .../semantics/analyzer/DataflowAnalyzer.java | 9 +++-- 4 files changed, 50 insertions(+), 11 deletions(-) diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/ASTBuilderUtil.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/ASTBuilderUtil.java index 977f838261e5..1da3556f467a 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/ASTBuilderUtil.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/ASTBuilderUtil.java @@ -53,6 +53,7 @@ import org.wso2.ballerinalang.compiler.tree.BLangService; import org.wso2.ballerinalang.compiler.tree.BLangSimpleVariable; import org.wso2.ballerinalang.compiler.tree.BLangTupleVariable; +import org.wso2.ballerinalang.compiler.tree.BLangVariable; import org.wso2.ballerinalang.compiler.tree.bindingpatterns.BLangBindingPattern; import org.wso2.ballerinalang.compiler.tree.bindingpatterns.BLangCaptureBindingPattern; import org.wso2.ballerinalang.compiler.tree.clauses.BLangMatchClause; @@ -552,6 +553,21 @@ static BLangRecordVariableDef createRecordVariableDef(Location pos, BLangRecordV return variableDef; } + static BLangErrorVariable createErrorVariable(Location pos, BType type, BLangExpression expr, + BLangSimpleVariable message, BLangVariable cause, + BLangSimpleVariable restDetail, + List detail) { + final BLangErrorVariable errVariable = (BLangErrorVariable) TreeBuilder.createErrorVariableNode(); + errVariable.pos = pos; + errVariable.setBType(type); + errVariable.expr = expr; + errVariable.message = message; + errVariable.cause = cause; + errVariable.restDetail = restDetail; + errVariable.detail = detail; + return errVariable; + } + static BLangErrorVariableDef createErrorVariableDef(Location pos, BLangErrorVariable variable) { final BLangErrorVariableDef variableDef = (BLangErrorVariableDef) TreeBuilder.createErrorVariableDefinitionNode(); diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java index c9f8ecc5ffd4..6f46928d3eef 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java @@ -27,6 +27,7 @@ import org.ballerinalang.model.elements.PackageID; import org.ballerinalang.model.symbols.SymbolKind; import org.ballerinalang.model.symbols.SymbolOrigin; +import org.ballerinalang.model.symbols.VariableSymbol; import org.ballerinalang.model.tree.BlockFunctionBodyNode; import org.ballerinalang.model.tree.BlockNode; import org.ballerinalang.model.tree.NodeKind; @@ -5151,6 +5152,26 @@ private void analyzeOnFailClause(BLangOnFailClause onFailClause, BLangBlockStmt } } } + private void handleErrorBP(BLangErrorVariable varNode, BLangBlockStmt onFailBody, BLangFail fail) { + BLangErrorVariable errorVar = ASTBuilderUtil.createErrorVariable(varNode.pos, + varNode.getBType(), rewrite(fail.expr, env), varNode.message, varNode.cause, varNode.restDetail, + varNode.detail); + + BLangErrorVariableDef errorVarDef = ASTBuilderUtil.createErrorVariableDef(onFailClause.pos, errorVar); + + BLangStatement stmt = rewrite(errorVarDef, env); + onFailBody.stmts.add(0, stmt); + } + + private void handleCaptureBP(BLangSimpleVariable varNode, BLangBlockStmt onFailBody, BLangFail fail) { + BVarSymbol onFailErrorVariableSymbol = varNode.symbol; + BLangSimpleVariable errorVar = ASTBuilderUtil.createVariable(onFailErrorVariableSymbol.pos, + onFailErrorVariableSymbol.name.value, onFailErrorVariableSymbol.type, rewrite(fail.expr, env), + onFailErrorVariableSymbol); + BLangSimpleVariableDef errorVarDef = ASTBuilderUtil.createVariableDef(onFailClause.pos, errorVar); + env.scope.define(onFailErrorVariableSymbol.name, onFailErrorVariableSymbol); + onFailBody.stmts.add(0, errorVarDef); + } private BLangFail createOnFailInvocation(BLangOnFailClause onFailClause, BLangFail fail) { BLangBlockStmt onFailBody = ASTBuilderUtil.createBlockStmt(onFailClause.pos); @@ -5160,14 +5181,12 @@ private BLangFail createOnFailInvocation(BLangOnFailClause onFailClause, BLangFa VariableDefinitionNode onFailVarDefNode = onFailClause.variableDefinitionNode; if (onFailVarDefNode != null) { - BVarSymbol onFailErrorVariableSymbol = - ((BLangSimpleVariableDef) onFailVarDefNode).var.symbol; - BLangSimpleVariable errorVar = ASTBuilderUtil.createVariable(onFailErrorVariableSymbol.pos, - onFailErrorVariableSymbol.name.value, onFailErrorVariableSymbol.type, rewrite(fail.expr, env), - onFailErrorVariableSymbol); - BLangSimpleVariableDef errorVarDef = ASTBuilderUtil.createVariableDef(onFailClause.pos, errorVar); - env.scope.define(onFailErrorVariableSymbol.name, onFailErrorVariableSymbol); - onFailBody.stmts.add(0, errorVarDef); + BLangVariable variableNode = (BLangVariable) onFailVarDefNode.getVariable(); + if (variableNode.getKind() == NodeKind.ERROR_VARIABLE) { + handleErrorBP((BLangErrorVariable) variableNode, onFailBody, fail); + } else { + handleCaptureBP((BLangSimpleVariable) variableNode, onFailBody, fail); + } } if (onFailClause.isInternal && fail.exprStmt != null) { diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/CodeAnalyzer.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/CodeAnalyzer.java index 4b2d41e23a0a..8919a2644685 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/CodeAnalyzer.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/CodeAnalyzer.java @@ -3357,6 +3357,7 @@ public void visit(BLangOnFailClause onFailClause, AnalyzerData data) { onFailVarNode.getBType()); } } + analyzeNode((BLangNode) onFailClause.getVariableDefinitionNode().getVariable().getTypeNode(), data); } data.errorTypes.pop(); analyzeNode(onFailClause.body, data); diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/DataflowAnalyzer.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/DataflowAnalyzer.java index 35446de14f2c..addf2016626d 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/DataflowAnalyzer.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/DataflowAnalyzer.java @@ -2269,9 +2269,12 @@ public void visit(BLangRecordVariableDef bLangRecordVariableDef) { public void visit(BLangErrorVariable bLangErrorVariable) { analyzeNode(bLangErrorVariable.typeNode, env); populateUnusedVariableMapForNonSimpleBindingPatternVariables(this.unusedLocalVariables, bLangErrorVariable); - this.currDependentSymbolDeque.push(bLangErrorVariable.symbol); - analyzeNode(bLangErrorVariable.expr, env); - this.currDependentSymbolDeque.pop(); + // When we visit this path from on fail clause the symbol is null + if (bLangErrorVariable.symbol != null) { + this.currDependentSymbolDeque.push(bLangErrorVariable.symbol); + analyzeNode(bLangErrorVariable.expr, env); + this.currDependentSymbolDeque.pop(); + } } @Override From 512d310d75eeaeb7a93fe32ba6214d4ae59025f6 Mon Sep 17 00:00:00 2001 From: suleka96 Date: Tue, 25 Apr 2023 16:37:03 +0530 Subject: [PATCH 13/33] Update parser logic --- .../internal/parser/BallerinaParser.java | 15 +- .../syntax/statements/DoStatementTest.java | 3 +- .../statements/ForEachStatementTest.java | 3 +- .../syntax/statements/LockStatementTest.java | 3 +- .../syntax/statements/MatchStatementTest.java | 4 +- .../statements/TransactionStatementTest.java | 6 +- .../syntax/statements/WhileStatementTest.java | 3 +- .../misc/completion/completion_assert_07.json | 34 - .../statements/do-stmt/do_stmt_assert_14.json | 22 +- .../statements/do-stmt/do_stmt_assert_16.json | 8 +- .../statements/do-stmt/do_stmt_assert_28.json | 286 +++++ .../statements/do-stmt/do_stmt_source_14.bal | 6 +- .../statements/do-stmt/do_stmt_source_16.bal | 2 +- .../statements/do-stmt/do_stmt_source_28.bal | 6 + .../forEach-stmt/forEach_stmt_assert_31.json | 22 +- .../forEach-stmt/forEach_stmt_assert_33.json | 8 +- .../forEach-stmt/forEach_stmt_assert_45.json | 344 +++++ .../forEach-stmt/forEach_stmt_source_31.bal | 6 +- .../forEach-stmt/forEach_stmt_source_33.bal | 2 +- .../forEach-stmt/forEach_stmt_source_45.bal | 6 + .../lock-stmt/lock_stmt_assert_15.json | 22 +- .../lock-stmt/lock_stmt_assert_17.json | 8 +- .../lock-stmt/lock_stmt_source_15.bal | 6 +- .../lock-stmt/lock_stmt_source_17.bal | 2 +- .../lock-stmt/lock_stmt_source_29.bal | 6 + .../match-stmt/match_stmt_assert_28.json | 22 +- .../match-stmt/match_stmt_assert_30.json | 8 +- .../match-stmt/match_stmt_assert_42.json | 445 +++++++ .../match-stmt/match_stmt_source_28.bal | 6 +- .../match-stmt/match_stmt_source_30.bal | 2 +- .../match-stmt/match_stmt_source_42.bal | 10 + .../retry_stmt_assert_12.json | 22 +- .../retry_stmt_assert_14.json | 8 +- .../retry_stmt_assert_26.json | 286 +++++ .../transaction-stmt/retry_stmt_source_12.bal | 6 +- .../transaction-stmt/retry_stmt_source_14.bal | 2 +- .../transaction-stmt/retry_stmt_source_26.bal | 6 + .../transaction_stmt_assert_09.json | 120 +- .../transaction_stmt_assert_11.json | 40 +- .../transaction_stmt_assert_23.json | 1116 +++++++++++++++++ .../transaction_stmt_source_09.bal | 54 +- .../transaction_stmt_source_11.bal | 10 +- .../transaction_stmt_source_23.bal | 29 + .../while-stmt/while_stmt_assert_11.json | 22 +- .../while-stmt/while_stmt_assert_13.json | 8 +- .../while-stmt/while_stmt_assert_25.json | 488 +++++++ .../while-stmt/while_stmt_source_11.bal | 6 +- .../while-stmt/while_stmt_source_13.bal | 2 +- .../while-stmt/while_stmt_source_25.bal | 8 + .../formatter/core/ParserTestFormatter.java | 10 +- 50 files changed, 3268 insertions(+), 301 deletions(-) create mode 100644 compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_28.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_28.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_45.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_45.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_29.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_42.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_42.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_26.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_26.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_23.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_23.bal create mode 100644 compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_25.json create mode 100644 compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_25.bal diff --git a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/BallerinaParser.java b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/BallerinaParser.java index fc252f4368ca..6dd5ae45cebf 100644 --- a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/BallerinaParser.java +++ b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/BallerinaParser.java @@ -13829,6 +13829,18 @@ private boolean isStatementStartingToken(SyntaxKind nodeKind) { } } + private boolean isTypedBPPresent() { + SyntaxKind nextTokenKind = peek().kind; + if (nextTokenKind == SyntaxKind.OPEN_BRACE_TOKEN) { + return false; + } else if (isTypeStartingToken(nextTokenKind)) { + return true; + } else { + recover(peek(), ParserRuleContext.ON_FAIL_OPTIONAL_BINDING_PATTERN); + return isTypedBPPresent(); + } + } + /** * Parse on fail clause. *

@@ -13842,9 +13854,8 @@ private STNode parseOnFailClause() { startContext(ParserRuleContext.ON_FAIL_CLAUSE); STNode onKeyword = parseOnKeyword(); STNode failKeyword = parseFailKeyword(); - STToken token = peek(); STNode typedBindingPattern = STNodeFactory.createEmptyNode(); - if (token.kind != SyntaxKind.OPEN_BRACE_TOKEN) { + if (isTypedBPPresent()) { typedBindingPattern = parseTypedBindingPattern(); } STNode blockStatement = parseBlockNode(); diff --git a/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/DoStatementTest.java b/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/DoStatementTest.java index 10d9ad6d567e..e62bc2fd0061 100644 --- a/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/DoStatementTest.java +++ b/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/DoStatementTest.java @@ -126,7 +126,8 @@ public Object[][] onFailClauseRecoveryTestDataProvider() { {"do-stmt/do_stmt_source_14.bal", "do-stmt/do_stmt_assert_14.json"}, {"do-stmt/do_stmt_source_15.bal", "do-stmt/do_stmt_assert_15.json"}, {"do-stmt/do_stmt_source_16.bal", "do-stmt/do_stmt_assert_16.json"}, - {"do-stmt/do_stmt_source_17.bal", "do-stmt/do_stmt_assert_17.json"} + {"do-stmt/do_stmt_source_17.bal", "do-stmt/do_stmt_assert_17.json"}, + {"do-stmt/do_stmt_source_28.bal", "do-stmt/do_stmt_assert_28.json"} }; } diff --git a/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/ForEachStatementTest.java b/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/ForEachStatementTest.java index 8084bc710ad5..c9857d97e66e 100644 --- a/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/ForEachStatementTest.java +++ b/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/ForEachStatementTest.java @@ -249,7 +249,8 @@ public Object[][] onFailClauseRecoveryTestDataProvider() { {"forEach-stmt/forEach_stmt_source_31.bal", "forEach-stmt/forEach_stmt_assert_31.json"}, {"forEach-stmt/forEach_stmt_source_32.bal", "forEach-stmt/forEach_stmt_assert_32.json"}, {"forEach-stmt/forEach_stmt_source_33.bal", "forEach-stmt/forEach_stmt_assert_33.json"}, - {"forEach-stmt/forEach_stmt_source_34.bal", "forEach-stmt/forEach_stmt_assert_34.json"} + {"forEach-stmt/forEach_stmt_source_34.bal", "forEach-stmt/forEach_stmt_assert_34.json"}, + {"forEach-stmt/forEach_stmt_source_45.bal", "forEach-stmt/forEach_stmt_assert_45.json"} }; } diff --git a/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/LockStatementTest.java b/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/LockStatementTest.java index ddda9c0b0ef6..b4086f85d4a8 100644 --- a/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/LockStatementTest.java +++ b/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/LockStatementTest.java @@ -153,7 +153,8 @@ public Object[][] onFailClauseRecoveryTestDataProvider() { {"lock-stmt/lock_stmt_source_15.bal", "lock-stmt/lock_stmt_assert_15.json"}, {"lock-stmt/lock_stmt_source_16.bal", "lock-stmt/lock_stmt_assert_16.json"}, {"lock-stmt/lock_stmt_source_17.bal", "lock-stmt/lock_stmt_assert_17.json"}, - {"lock-stmt/lock_stmt_source_18.bal", "lock-stmt/lock_stmt_assert_18.json"} + {"lock-stmt/lock_stmt_source_18.bal", "lock-stmt/lock_stmt_assert_18.json"}, + {"lock-stmt/lock_stmt_source_19.bal", "lock-stmt/lock_stmt_assert_19.json"} }; } diff --git a/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/MatchStatementTest.java b/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/MatchStatementTest.java index 65cab54693ba..27230037dc45 100644 --- a/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/MatchStatementTest.java +++ b/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/MatchStatementTest.java @@ -183,7 +183,9 @@ public Object[][] onFailClauseRecoveryTestDataProvider() { {"match-stmt/match_stmt_source_28.bal", "match-stmt/match_stmt_assert_28.json"}, {"match-stmt/match_stmt_source_29.bal", "match-stmt/match_stmt_assert_29.json"}, {"match-stmt/match_stmt_source_30.bal", "match-stmt/match_stmt_assert_30.json"}, - {"match-stmt/match_stmt_source_31.bal", "match-stmt/match_stmt_assert_31.json"} + {"match-stmt/match_stmt_source_31.bal", "match-stmt/match_stmt_assert_31.json"}, + {"match-stmt/match_stmt_source_42.bal", "match-stmt/match_stmt_assert_42.json"} + }; } diff --git a/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/TransactionStatementTest.java b/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/TransactionStatementTest.java index ceb223849ea2..74fba818053f 100644 --- a/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/TransactionStatementTest.java +++ b/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/TransactionStatementTest.java @@ -253,7 +253,8 @@ public Object[][] transactionOnFailClauseRecoveryTestDataProvider() { {"transaction-stmt/transaction_stmt_source_09.bal", "transaction-stmt/transaction_stmt_assert_09.json"}, {"transaction-stmt/transaction_stmt_source_10.bal", "transaction-stmt/transaction_stmt_assert_10.json"}, {"transaction-stmt/transaction_stmt_source_11.bal", "transaction-stmt/transaction_stmt_assert_11.json"}, - {"transaction-stmt/transaction_stmt_source_12.bal", "transaction-stmt/transaction_stmt_assert_12.json"} + {"transaction-stmt/transaction_stmt_source_12.bal", "transaction-stmt/transaction_stmt_assert_12.json"}, + {"transaction-stmt/transaction_stmt_source_23.bal", "transaction-stmt/transaction_stmt_assert_23.json"} }; } @@ -269,7 +270,8 @@ public Object[][] retryOnFailClauseRecoveryTestDataProvider() { {"transaction-stmt/retry_stmt_source_12.bal", "transaction-stmt/retry_stmt_assert_12.json"}, {"transaction-stmt/retry_stmt_source_13.bal", "transaction-stmt/retry_stmt_assert_13.json"}, {"transaction-stmt/retry_stmt_source_14.bal", "transaction-stmt/retry_stmt_assert_14.json"}, - {"transaction-stmt/retry_stmt_source_15.bal", "transaction-stmt/retry_stmt_assert_15.json"} + {"transaction-stmt/retry_stmt_source_15.bal", "transaction-stmt/retry_stmt_assert_15.json"}, + {"transaction-stmt/retry_stmt_source_26.bal", "transaction-stmt/retry_stmt_assert_26.json"} }; } diff --git a/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/WhileStatementTest.java b/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/WhileStatementTest.java index a444496ed8af..71cfbd70d2e3 100644 --- a/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/WhileStatementTest.java +++ b/compiler/ballerina-parser/src/test/java/io/ballerinalang/compiler/parser/test/syntax/statements/WhileStatementTest.java @@ -124,7 +124,8 @@ public Object[][] onFailClauseRecoveryTestDataProvider() { {"while-stmt/while_stmt_source_11.bal", "while-stmt/while_stmt_assert_11.json"}, {"while-stmt/while_stmt_source_12.bal", "while-stmt/while_stmt_assert_12.json"}, {"while-stmt/while_stmt_source_13.bal", "while-stmt/while_stmt_assert_13.json"}, - {"while-stmt/while_stmt_source_14.bal", "while-stmt/while_stmt_assert_14.json"} + {"while-stmt/while_stmt_source_14.bal", "while-stmt/while_stmt_assert_14.json"}, + {"while-stmt/while_stmt_source_25.bal", "while-stmt/while_stmt_assert_25.json"} }; } diff --git a/compiler/ballerina-parser/src/test/resources/misc/completion/completion_assert_07.json b/compiler/ballerina-parser/src/test/resources/misc/completion/completion_assert_07.json index 26c58789b4e6..b9624ed9e294 100644 --- a/compiler/ballerina-parser/src/test/resources/misc/completion/completion_assert_07.json +++ b/compiler/ballerina-parser/src/test/resources/misc/completion/completion_assert_07.json @@ -589,40 +589,6 @@ "ERROR_MISSING_FAIL_KEYWORD" ] }, - { - "kind": "TYPED_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "SIMPLE_NAME_REFERENCE", - "hasDiagnostics": true, - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_TYPE_DESC" - ] - } - ] - }, - { - "kind": "CAPTURE_BINDING_PATTERN", - "hasDiagnostics": true, - "children": [ - { - "kind": "IDENTIFIER_TOKEN", - "isMissing": true, - "hasDiagnostics": true, - "diagnostics": [ - "ERROR_MISSING_IDENTIFIER" - ] - } - ] - } - ] - }, { "kind": "BLOCK_STATEMENT", "hasDiagnostics": true, diff --git a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_14.json b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_14.json index 6a316de48e3d..3cb4febf1221 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_14.json +++ b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_14.json @@ -244,13 +244,7 @@ "children": [ { "kind": "IDENTIFIER_TOKEN", - "value": "err", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] + "value": "err" } ] }, @@ -294,10 +288,6 @@ "kind": "END_OF_LINE_MINUTIAE", "value": "\n" }, - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - }, { "kind": "INVALID_NODE_MINUTIAE", "invalidNode": { @@ -387,10 +377,6 @@ "kind": "END_OF_LINE_MINUTIAE", "value": "\n" }, - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - }, { "kind": "INVALID_NODE_MINUTIAE", "invalidNode": { @@ -430,6 +416,12 @@ }, { "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], "trailingMinutiae": [ { "kind": "END_OF_LINE_MINUTIAE", diff --git a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_16.json b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_16.json index 75ca7a37b414..1eeff1a268b3 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_16.json +++ b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_16.json @@ -216,7 +216,13 @@ "kind": "ERROR_TYPE_DESC", "children": [ { - "kind": "ERROR_KEYWORD" + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] } ] }, diff --git a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_28.json b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_28.json new file mode 100644 index 000000000000..bf90442bcd04 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_assert_28.json @@ -0,0 +1,286 @@ +{ + "kind": "FUNCTION_DEFINITION", + "hasDiagnostics": true, + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "DO_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "DO_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "hasDiagnostics": true, + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "hasDiagnostics": true, + "leadingMinutiae": [ + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "hasDiagnostics": true, + "children": [ + { + "kind": "EQUAL_TOKEN", + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_INVALID_TOKEN" + ] + } + ] + } + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_14.bal b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_14.bal index 7cebfd2bcf0a..557657a29b83 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_14.bal +++ b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_14.bal @@ -1,7 +1,7 @@ public function test() { do { fail error("error!"); - } on fail error error err { - io:println(err); - } + } on fail error error err{ +io:println(err); } + } diff --git a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_16.bal b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_16.bal index c5fd66d29027..c9074d613ea3 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_16.bal +++ b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_16.bal @@ -1,7 +1,7 @@ public function test() { do { fail error("error!"); - } on fail error(m) { + } on fail error (m) { io:println(m); } } diff --git a/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_28.bal b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_28.bal new file mode 100644 index 000000000000..b4d9d08af9e6 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/do-stmt/do_stmt_source_28.bal @@ -0,0 +1,6 @@ +public function test() { + do { + fail error("error!"); + } on fail = { + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_31.json b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_31.json index 56be005e4e64..cbf486e2eca7 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_31.json +++ b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_31.json @@ -302,13 +302,7 @@ "children": [ { "kind": "IDENTIFIER_TOKEN", - "value": "err", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] + "value": "err" } ] }, @@ -352,10 +346,6 @@ "kind": "END_OF_LINE_MINUTIAE", "value": "\n" }, - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - }, { "kind": "INVALID_NODE_MINUTIAE", "invalidNode": { @@ -445,10 +435,6 @@ "kind": "END_OF_LINE_MINUTIAE", "value": "\n" }, - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - }, { "kind": "INVALID_NODE_MINUTIAE", "invalidNode": { @@ -488,6 +474,12 @@ }, { "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], "trailingMinutiae": [ { "kind": "END_OF_LINE_MINUTIAE", diff --git a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_33.json b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_33.json index 07109f4ff1b9..427a196825bd 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_33.json +++ b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_33.json @@ -274,7 +274,13 @@ "kind": "ERROR_TYPE_DESC", "children": [ { - "kind": "ERROR_KEYWORD" + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] } ] }, diff --git a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_45.json b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_45.json new file mode 100644 index 000000000000..ea4d1f8ace22 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_assert_45.json @@ -0,0 +1,344 @@ +{ + "kind": "FUNCTION_DEFINITION", + "hasDiagnostics": true, + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "FOREACH_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "FOREACH_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "VAR_TYPE_DESC", + "children": [ + { + "kind": "VAR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "v", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "IN_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "membersList", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "hasDiagnostics": true, + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "hasDiagnostics": true, + "leadingMinutiae": [ + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "hasDiagnostics": true, + "children": [ + { + "kind": "EQUAL_TOKEN", + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_INVALID_TOKEN" + ] + } + ] + } + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_31.bal b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_31.bal index 2dc698a24358..fef61ff78846 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_31.bal +++ b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_31.bal @@ -1,7 +1,7 @@ public function test() { foreach var v in membersList { fail error("error!"); - } on fail error error err { - io:println(err); - } + } on fail error error err{ +io:println(err); } + } diff --git a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_33.bal b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_33.bal index a9c9041805a4..7d5302b86770 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_33.bal +++ b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_33.bal @@ -1,7 +1,7 @@ public function test() { foreach var v in membersList { fail error("error!"); - } on fail error(m) { + } on fail error (m) { io:println(m); } } diff --git a/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_45.bal b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_45.bal new file mode 100644 index 000000000000..380083ff670f --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/forEach-stmt/forEach_stmt_source_45.bal @@ -0,0 +1,6 @@ +public function test() { + foreach var v in membersList { + fail error("error!"); + } on fail = { + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_15.json b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_15.json index f0fd352f6e45..29bb2c2e505b 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_15.json +++ b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_15.json @@ -244,13 +244,7 @@ "children": [ { "kind": "IDENTIFIER_TOKEN", - "value": "err", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] + "value": "err" } ] }, @@ -294,10 +288,6 @@ "kind": "END_OF_LINE_MINUTIAE", "value": "\n" }, - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - }, { "kind": "INVALID_NODE_MINUTIAE", "invalidNode": { @@ -387,10 +377,6 @@ "kind": "END_OF_LINE_MINUTIAE", "value": "\n" }, - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - }, { "kind": "INVALID_NODE_MINUTIAE", "invalidNode": { @@ -430,6 +416,12 @@ }, { "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], "trailingMinutiae": [ { "kind": "END_OF_LINE_MINUTIAE", diff --git a/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_17.json b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_17.json index 637bf1143407..e6a323ec92a8 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_17.json +++ b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_assert_17.json @@ -216,7 +216,13 @@ "kind": "ERROR_TYPE_DESC", "children": [ { - "kind": "ERROR_KEYWORD" + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] } ] }, diff --git a/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_15.bal b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_15.bal index cc26de9a6c5f..4b39d1712307 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_15.bal +++ b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_15.bal @@ -1,7 +1,7 @@ public function test() { lock { fail error("error!"); - } on fail error error err { - io:println(err); - } + } on fail error error err{ +io:println(err); } + } diff --git a/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_17.bal b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_17.bal index 38487a2f35a4..162c133e10dc 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_17.bal +++ b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_17.bal @@ -1,7 +1,7 @@ public function test() { lock { fail error("error!"); - } on fail error(m) { + } on fail error (m) { io:println(m); } } diff --git a/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_29.bal b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_29.bal new file mode 100644 index 000000000000..4d5964f35fd5 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/lock-stmt/lock_stmt_source_29.bal @@ -0,0 +1,6 @@ +public function test() { + lock { + fail error("error!"); + } on fail = { + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_28.json b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_28.json index 535e3c6f8cc0..41b25acfe38a 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_28.json +++ b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_28.json @@ -403,13 +403,7 @@ "children": [ { "kind": "IDENTIFIER_TOKEN", - "value": "err", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] + "value": "err" } ] }, @@ -453,10 +447,6 @@ "kind": "END_OF_LINE_MINUTIAE", "value": "\n" }, - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - }, { "kind": "INVALID_NODE_MINUTIAE", "invalidNode": { @@ -546,10 +536,6 @@ "kind": "END_OF_LINE_MINUTIAE", "value": "\n" }, - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - }, { "kind": "INVALID_NODE_MINUTIAE", "invalidNode": { @@ -589,6 +575,12 @@ }, { "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], "trailingMinutiae": [ { "kind": "END_OF_LINE_MINUTIAE", diff --git a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_30.json b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_30.json index 1553515291bb..2a7ee79728f4 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_30.json +++ b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_30.json @@ -375,7 +375,13 @@ "kind": "ERROR_TYPE_DESC", "children": [ { - "kind": "ERROR_KEYWORD" + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] } ] }, diff --git a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_42.json b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_42.json new file mode 100644 index 000000000000..8c43d3564e6d --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_assert_42.json @@ -0,0 +1,445 @@ +{ + "kind": "FUNCTION_DEFINITION", + "hasDiagnostics": true, + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "MATCH_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "MATCH_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "bar", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "MATCH_CLAUSE", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "NIL_LITERAL", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "RIGHT_DOUBLE_ARROW_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "MATCH_CLAUSE", + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "east", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "RIGHT_DOUBLE_ARROW_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "hasDiagnostics": true, + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "hasDiagnostics": true, + "leadingMinutiae": [ + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "hasDiagnostics": true, + "children": [ + { + "kind": "EQUAL_TOKEN", + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_INVALID_TOKEN" + ] + } + ] + } + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_28.bal b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_28.bal index 4efd220c760c..e56fb364ce57 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_28.bal +++ b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_28.bal @@ -5,7 +5,7 @@ public function test() { "east" => { fail error("error!"); } - } on fail error error err { - io:println(err); - } + } on fail error error err{ +io:println(err); } + } diff --git a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_30.bal b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_30.bal index a4f4f1f0933a..4d91b96de0cf 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_30.bal +++ b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_30.bal @@ -5,7 +5,7 @@ public function test() { "east" => { fail error("error!"); } - } on fail error(m) { + } on fail error (m) { io:println(m); } } diff --git a/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_42.bal b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_42.bal new file mode 100644 index 000000000000..7cacc34b965e --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/match-stmt/match_stmt_source_42.bal @@ -0,0 +1,10 @@ +public function test() { + match bar { + () => { + } + "east" => { + fail error("error!"); + } + } on fail = { + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_12.json b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_12.json index f1f7427d7ca1..e7adfffe2ba2 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_12.json +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_12.json @@ -185,13 +185,7 @@ "children": [ { "kind": "IDENTIFIER_TOKEN", - "value": "err", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] + "value": "err" } ] }, @@ -235,10 +229,6 @@ "kind": "END_OF_LINE_MINUTIAE", "value": "\n" }, - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - }, { "kind": "INVALID_NODE_MINUTIAE", "invalidNode": { @@ -328,10 +318,6 @@ "kind": "END_OF_LINE_MINUTIAE", "value": "\n" }, - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - }, { "kind": "INVALID_NODE_MINUTIAE", "invalidNode": { @@ -371,6 +357,12 @@ }, { "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], "trailingMinutiae": [ { "kind": "END_OF_LINE_MINUTIAE", diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_14.json b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_14.json index 711814eadb27..93983da4eb9d 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_14.json +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_14.json @@ -157,7 +157,13 @@ "kind": "ERROR_TYPE_DESC", "children": [ { - "kind": "ERROR_KEYWORD" + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] } ] }, diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_26.json b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_26.json new file mode 100644 index 000000000000..c9c00060054b --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_assert_26.json @@ -0,0 +1,286 @@ +{ + "kind": "FUNCTION_DEFINITION", + "hasDiagnostics": true, + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "RETRY_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "RETRY_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "hasDiagnostics": true, + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "hasDiagnostics": true, + "leadingMinutiae": [ + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "hasDiagnostics": true, + "children": [ + { + "kind": "EQUAL_TOKEN", + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_INVALID_TOKEN" + ] + } + ] + } + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_12.bal b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_12.bal index bf54fb15d440..058bd9607656 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_12.bal +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_12.bal @@ -1,7 +1,7 @@ public function test() { retry { - } on fail error error err { - io:println(err); - } + } on fail error error err{ +io:println(err); } + } diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_14.bal b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_14.bal index 2c2af2f7e24b..b64b625159d7 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_14.bal +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_14.bal @@ -1,7 +1,7 @@ public function test() { retry { - } on fail error(m) { + } on fail error (m) { io:println(m); } } diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_26.bal b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_26.bal new file mode 100644 index 000000000000..7fc7b740af7d --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/retry_stmt_source_26.bal @@ -0,0 +1,6 @@ +public function test() { + retry { + fail error("error!"); + } on fail = { + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_09.json b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_09.json index 54b5fb2c10c0..f83d4e10ea87 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_09.json +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_09.json @@ -171,13 +171,7 @@ "children": [ { "kind": "IDENTIFIER_TOKEN", - "value": "err", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] + "value": "err" } ] }, @@ -221,10 +215,6 @@ "kind": "END_OF_LINE_MINUTIAE", "value": "\n" }, - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - }, { "kind": "INVALID_NODE_MINUTIAE", "invalidNode": { @@ -314,10 +304,6 @@ "kind": "END_OF_LINE_MINUTIAE", "value": "\n" }, - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - }, { "kind": "INVALID_NODE_MINUTIAE", "invalidNode": { @@ -368,7 +354,7 @@ }, { "kind": "WHITESPACE_MINUTIAE", - "value": " " + "value": " " } ], "trailingMinutiae": [ @@ -411,7 +397,7 @@ "leadingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", - "value": " " + "value": " " } ], "trailingMinutiae": [ @@ -476,7 +462,7 @@ "leadingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", - "value": " " + "value": " " } ], "trailingMinutiae": [ @@ -546,13 +532,7 @@ "children": [ { "kind": "IDENTIFIER_TOKEN", - "value": "err", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] + "value": "err" } ] }, @@ -596,10 +576,6 @@ "kind": "END_OF_LINE_MINUTIAE", "value": "\n" }, - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - }, { "kind": "INVALID_NODE_MINUTIAE", "invalidNode": { @@ -689,10 +665,6 @@ "kind": "END_OF_LINE_MINUTIAE", "value": "\n" }, - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - }, { "kind": "INVALID_NODE_MINUTIAE", "invalidNode": { @@ -743,7 +715,7 @@ }, { "kind": "WHITESPACE_MINUTIAE", - "value": " " + "value": " " } ], "trailingMinutiae": [ @@ -776,7 +748,7 @@ "leadingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", - "value": " " + "value": " " } ], "trailingMinutiae": [ @@ -809,7 +781,7 @@ "leadingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", - "value": " " + "value": " " } ], "trailingMinutiae": [ @@ -852,7 +824,7 @@ "leadingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", - "value": " " + "value": " " } ], "trailingMinutiae": [ @@ -893,7 +865,7 @@ "leadingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", - "value": " " + "value": " " } ], "trailingMinutiae": [ @@ -914,7 +886,7 @@ "leadingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", - "value": " " + "value": " " } ], "trailingMinutiae": [ @@ -935,7 +907,7 @@ "leadingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", - "value": " " + "value": " " } ], "trailingMinutiae": [ @@ -1005,13 +977,7 @@ "children": [ { "kind": "IDENTIFIER_TOKEN", - "value": "err", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] + "value": "err" } ] }, @@ -1055,10 +1021,6 @@ "kind": "END_OF_LINE_MINUTIAE", "value": "\n" }, - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - }, { "kind": "INVALID_NODE_MINUTIAE", "invalidNode": { @@ -1148,10 +1110,6 @@ "kind": "END_OF_LINE_MINUTIAE", "value": "\n" }, - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - }, { "kind": "INVALID_NODE_MINUTIAE", "invalidNode": { @@ -1202,7 +1160,7 @@ }, { "kind": "WHITESPACE_MINUTIAE", - "value": " " + "value": " " } ], "trailingMinutiae": [ @@ -1238,7 +1196,7 @@ "leadingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", - "value": " " + "value": " " } ], "trailingMinutiae": [ @@ -1274,7 +1232,7 @@ "leadingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", - "value": " " + "value": " " } ], "trailingMinutiae": [ @@ -1317,7 +1275,7 @@ "leadingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", - "value": " " + "value": " " } ], "trailingMinutiae": [ @@ -1358,7 +1316,7 @@ "leadingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", - "value": " " + "value": " " } ], "trailingMinutiae": [ @@ -1428,13 +1386,7 @@ "children": [ { "kind": "IDENTIFIER_TOKEN", - "value": "err", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] + "value": "err" } ] }, @@ -1478,10 +1430,6 @@ "kind": "END_OF_LINE_MINUTIAE", "value": "\n" }, - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - }, { "kind": "INVALID_NODE_MINUTIAE", "invalidNode": { @@ -1571,10 +1519,6 @@ "kind": "END_OF_LINE_MINUTIAE", "value": "\n" }, - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - }, { "kind": "INVALID_NODE_MINUTIAE", "invalidNode": { @@ -1617,7 +1561,7 @@ "leadingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", - "value": " " + "value": " " } ], "trailingMinutiae": [ @@ -1640,7 +1584,7 @@ "leadingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", - "value": " " + "value": " " } ], "trailingMinutiae": [ @@ -1710,13 +1654,7 @@ "children": [ { "kind": "IDENTIFIER_TOKEN", - "value": "err", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] + "value": "err" } ] }, @@ -1760,10 +1698,6 @@ "kind": "END_OF_LINE_MINUTIAE", "value": "\n" }, - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - }, { "kind": "INVALID_NODE_MINUTIAE", "invalidNode": { @@ -1853,10 +1787,6 @@ "kind": "END_OF_LINE_MINUTIAE", "value": "\n" }, - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - }, { "kind": "INVALID_NODE_MINUTIAE", "invalidNode": { @@ -1896,6 +1826,12 @@ }, { "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], "trailingMinutiae": [ { "kind": "END_OF_LINE_MINUTIAE", diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_11.json b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_11.json index e4bf323b969e..b6cd5f2161a5 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_11.json +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_11.json @@ -143,7 +143,13 @@ "kind": "ERROR_TYPE_DESC", "children": [ { - "kind": "ERROR_KEYWORD" + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] } ] }, @@ -456,7 +462,13 @@ "kind": "ERROR_TYPE_DESC", "children": [ { - "kind": "ERROR_KEYWORD" + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] } ] }, @@ -853,7 +865,13 @@ "kind": "ERROR_TYPE_DESC", "children": [ { - "kind": "ERROR_KEYWORD" + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] } ] }, @@ -1214,7 +1232,13 @@ "kind": "ERROR_TYPE_DESC", "children": [ { - "kind": "ERROR_KEYWORD" + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] } ] }, @@ -1434,7 +1458,13 @@ "kind": "ERROR_TYPE_DESC", "children": [ { - "kind": "ERROR_KEYWORD" + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] } ] }, diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_23.json b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_23.json new file mode 100644 index 000000000000..d8fbeee112a6 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_23.json @@ -0,0 +1,1116 @@ +{ + "kind": "FUNCTION_DEFINITION", + "hasDiagnostics": true, + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "foo" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "hasDiagnostics": true, + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "hasDiagnostics": true, + "leadingMinutiae": [ + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "hasDiagnostics": true, + "children": [ + { + "kind": "EQUAL_TOKEN", + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_INVALID_TOKEN" + ] + } + ] + } + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "TRANSACTION_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "a", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "5" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "hasDiagnostics": true, + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "hasDiagnostics": true, + "leadingMinutiae": [ + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "hasDiagnostics": true, + "children": [ + { + "kind": "EQUAL_TOKEN", + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_INVALID_TOKEN" + ] + } + ] + } + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "TRANSACTION_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "STRING_TYPE_DESC", + "children": [ + { + "kind": "STRING_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "b" + } + ] + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "hasDiagnostics": true, + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "hasDiagnostics": true, + "leadingMinutiae": [ + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "hasDiagnostics": true, + "children": [ + { + "kind": "EQUAL_TOKEN", + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_INVALID_TOKEN" + ] + } + ] + } + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "TRANSACTION_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "TRANSACTION_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "TRANSACTION_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "STRING_TYPE_DESC", + "children": [ + { + "kind": "STRING_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "b" + } + ] + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "hasDiagnostics": true, + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "hasDiagnostics": true, + "leadingMinutiae": [ + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "hasDiagnostics": true, + "children": [ + { + "kind": "EQUAL_TOKEN", + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_INVALID_TOKEN" + ] + } + ] + } + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "hasDiagnostics": true, + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "hasDiagnostics": true, + "leadingMinutiae": [ + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "hasDiagnostics": true, + "children": [ + { + "kind": "EQUAL_TOKEN", + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_INVALID_TOKEN" + ] + } + ] + } + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_09.bal b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_09.bal index 78e41d69de03..ea972ba03bab 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_09.bal +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_09.bal @@ -1,34 +1,34 @@ function foo() { transaction { - } on fail error error err { - io:println(err); - } - - transaction { - int a = 5; - } on fail error error err { - io:println(err); - } + } on fail error error err{ +io:println(err); +} - transaction { transaction { - transaction { - string b; - } - } - } on fail error error err { - io:println(err); - } + int a = 5; + } on fail error error err{ +io:println(err); +} - transaction { - transaction { transaction { - string b; - } on fail error error err { - io:println(err); - } - } - } on fail error error err { - io:println(err); - } + transaction { + transaction { + string b; + } + } + } on fail error error err{ +io:println(err); +} + + transaction { + transaction { + transaction { + string b; + } on fail error error err{ +io:println(err); +} + } + } on fail error error err{ +io:println(err); } + } diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_11.bal b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_11.bal index e39796bd0c1a..bc5348111f8a 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_11.bal +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_11.bal @@ -1,12 +1,12 @@ function foo() { transaction { - } on fail error(m) { + } on fail error (m) { io:println(m); } transaction { int a = 5; - } on fail error(m) { + } on fail error (m) { io:println(m); } @@ -16,7 +16,7 @@ function foo() { string b; } } - } on fail error(m) { + } on fail error (m) { io:println(m); } @@ -24,11 +24,11 @@ function foo() { transaction { transaction { string b; - } on fail error(m) { + } on fail error (m) { io:println(m); } } - } on fail error(m) { + } on fail error (m) { io:println(m); } } diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_23.bal b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_23.bal new file mode 100644 index 000000000000..e5487cd59687 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_23.bal @@ -0,0 +1,29 @@ +function foo() { + transaction { + } on fail = { + } + + transaction { + int a = 5; + } on fail = { + } + + transaction { + transaction { + transaction { + string b; + } + } + } on fail = { + } + + transaction { + transaction { + transaction { + string b; + } on fail = { + } + } + } on fail = { + } +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_11.json b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_11.json index b28e29bfac2f..7d772ab86549 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_11.json +++ b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_11.json @@ -446,13 +446,7 @@ "children": [ { "kind": "IDENTIFIER_TOKEN", - "value": "err", - "trailingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ] + "value": "err" } ] }, @@ -496,10 +490,6 @@ "kind": "END_OF_LINE_MINUTIAE", "value": "\n" }, - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - }, { "kind": "INVALID_NODE_MINUTIAE", "invalidNode": { @@ -589,10 +579,6 @@ "kind": "END_OF_LINE_MINUTIAE", "value": "\n" }, - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - }, { "kind": "INVALID_NODE_MINUTIAE", "invalidNode": { @@ -632,6 +618,12 @@ }, { "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], "trailingMinutiae": [ { "kind": "END_OF_LINE_MINUTIAE", diff --git a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_13.json b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_13.json index 79af61ad7d5e..ef8fbf7fa881 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_13.json +++ b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_13.json @@ -418,7 +418,13 @@ "kind": "ERROR_TYPE_DESC", "children": [ { - "kind": "ERROR_KEYWORD" + "kind": "ERROR_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] } ] }, diff --git a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_25.json b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_25.json new file mode 100644 index 000000000000..02ba6b59c7a0 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_assert_25.json @@ -0,0 +1,488 @@ +{ + "kind": "FUNCTION_DEFINITION", + "hasDiagnostics": true, + "children": [ + { + "kind": "LIST", + "children": [ + { + "kind": "PUBLIC_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "IDENTIFIER_TOKEN", + "value": "test" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "FUNCTION_SIGNATURE", + "children": [ + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_PAREN_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "FUNCTION_BODY_BLOCK", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "hasDiagnostics": true, + "children": [ + { + "kind": "LOCAL_VAR_DECL", + "children": [ + { + "kind": "LIST", + "children": [] + }, + { + "kind": "TYPED_BINDING_PATTERN", + "children": [ + { + "kind": "INT_TYPE_DESC", + "children": [ + { + "kind": "INT_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "CAPTURE_BINDING_PATTERN", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "0" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "WHILE_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "WHILE_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BINARY_EXPRESSION", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "LT_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "3", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [ + { + "kind": "ASSIGNMENT_STATEMENT", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "EQUAL_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BINARY_EXPRESSION", + "children": [ + { + "kind": "SIMPLE_NAME_REFERENCE", + "children": [ + { + "kind": "IDENTIFIER_TOKEN", + "value": "i", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "PLUS_TOKEN", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "NUMERIC_LITERAL", + "children": [ + { + "kind": "DECIMAL_INTEGER_LITERAL_TOKEN", + "value": "1" + } + ] + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + }, + { + "kind": "FAIL_STATEMENT", + "children": [ + { + "kind": "FAIL_KEYWORD", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "ERROR_CONSTRUCTOR", + "children": [ + { + "kind": "ERROR_KEYWORD" + }, + { + "kind": "OPEN_PAREN_TOKEN" + }, + { + "kind": "LIST", + "children": [ + { + "kind": "POSITIONAL_ARG", + "children": [ + { + "kind": "STRING_LITERAL", + "children": [ + { + "kind": "STRING_LITERAL_TOKEN", + "value": "error!" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_PAREN_TOKEN" + } + ] + }, + { + "kind": "SEMICOLON_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + } + ] + }, + { + "kind": "ON_FAIL_CLAUSE", + "hasDiagnostics": true, + "children": [ + { + "kind": "ON_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "FAIL_KEYWORD", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] + }, + { + "kind": "BLOCK_STATEMENT", + "hasDiagnostics": true, + "children": [ + { + "kind": "OPEN_BRACE_TOKEN", + "hasDiagnostics": true, + "leadingMinutiae": [ + { + "kind": "INVALID_NODE_MINUTIAE", + "invalidNode": { + "kind": "INVALID_TOKEN_MINUTIAE_NODE", + "hasDiagnostics": true, + "children": [ + { + "kind": "EQUAL_TOKEN", + "hasDiagnostics": true, + "diagnostics": [ + "ERROR_INVALID_TOKEN" + ] + } + ] + } + }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + }, + { + "kind": "LIST", + "children": [] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "leadingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ], + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "kind": "CLOSE_BRACE_TOKEN", + "trailingMinutiae": [ + { + "kind": "END_OF_LINE_MINUTIAE", + "value": "\n" + } + ] + } + ] + } + ] +} diff --git a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_11.bal b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_11.bal index 874f0d648c3f..77d55a480f90 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_11.bal +++ b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_11.bal @@ -3,7 +3,7 @@ public function test() { while i < 3 { i = i + 1; fail error("error!"); - } on fail error error err { - io:println(err); - } + } on fail error error err{ +io:println(err); } + } diff --git a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_13.bal b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_13.bal index 4facab1a8dbd..23b504293926 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_13.bal +++ b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_13.bal @@ -3,7 +3,7 @@ public function test() { while i < 3 { i = i + 1; fail error("error!"); - } on fail error(m) { + } on fail error (m) { io:println(m); } } diff --git a/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_25.bal b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_25.bal new file mode 100644 index 000000000000..02321b984d74 --- /dev/null +++ b/compiler/ballerina-parser/src/test/resources/statements/while-stmt/while_stmt_source_25.bal @@ -0,0 +1,8 @@ +public function test() { + int i = 0; + while i < 3 { + i = i + 1; + fail error("error!"); + } on fail = { + } +} diff --git a/misc/formatter/modules/formatter-core/src/test/java/org/ballerinalang/formatter/core/ParserTestFormatter.java b/misc/formatter/modules/formatter-core/src/test/java/org/ballerinalang/formatter/core/ParserTestFormatter.java index 523a509bed6c..4525011ce097 100644 --- a/misc/formatter/modules/formatter-core/src/test/java/org/ballerinalang/formatter/core/ParserTestFormatter.java +++ b/misc/formatter/modules/formatter-core/src/test/java/org/ballerinalang/formatter/core/ParserTestFormatter.java @@ -183,15 +183,7 @@ public List skipList() { "resiliency_source_05.bal", "regexp_constructor_source_26.bal", "regexp_constructor_source_28.bal", "regexp_constructor_source_44.bal", "regexp_constructor_source_47.bal", "regexp_constructor_source_52.bal", "regexp_constructor_source_53.bal", "completion_source_07.bal", - "do_stmt_source_14.bal", "do_stmt_source_15.bal", "do_stmt_source_16.bal", "do_stmt_source_17.bal", - "forEach_stmt_source_31.bal", "foreach_stmt_source_32.bal", "forEach_stmt_source_33.bal", - "foreach_stmt_source_34.bal", "lock_stmt_source_15.bal", "lock_stmt_source_16.bal", - "lock_stmt_source_17.bal", "lock_stmt_source_18.bal", "match_stmt_source_28.bal", - "match_stmt_source_29.bal", "match_stmt_source_30.bal", "match_stmt_source_31.bal", - "retry_stmt_source_12.bal", "retry_stmt_source_13.bal", "retry_stmt_source_14.bal", - "retry_stmt_source_15.bal", "transaction_stmt_source_09.bal", "transaction_stmt_source_10.bal", - "transaction_stmt_source_11.bal", "transaction_stmt_source_12.bal", "while_stmt_source_11.bal", - "while_stmt_source_12.bal", "while_stmt_source_13.bal", "while_stmt_source_14.bal"); + "transaction_stmt_source_09.bal"); } @DataProvider(name = "test-file-provider") From 9e46ae6c8bca9d17be2189d54585eb9519d5257b Mon Sep 17 00:00:00 2001 From: suleka96 Date: Tue, 25 Apr 2023 16:45:50 +0530 Subject: [PATCH 14/33] Remove import --- .../java/org/wso2/ballerinalang/compiler/desugar/Desugar.java | 1 - 1 file changed, 1 deletion(-) diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java index 6f46928d3eef..4435f54a941b 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java @@ -27,7 +27,6 @@ import org.ballerinalang.model.elements.PackageID; import org.ballerinalang.model.symbols.SymbolKind; import org.ballerinalang.model.symbols.SymbolOrigin; -import org.ballerinalang.model.symbols.VariableSymbol; import org.ballerinalang.model.tree.BlockFunctionBodyNode; import org.ballerinalang.model.tree.BlockNode; import org.ballerinalang.model.tree.NodeKind; From 702e132aa30de34a15442b3d6f64236aae9624fe Mon Sep 17 00:00:00 2001 From: suleka96 Date: Fri, 19 May 2023 16:36:28 +0530 Subject: [PATCH 15/33] Add all tests --- .../compiler/desugar/Desugar.java | 74 ++- .../semantics/analyzer/CodeAnalyzer.java | 71 +-- .../semantics/analyzer/SemanticAnalyzer.java | 111 +++- .../semantics/analyzer/TypeChecker.java | 4 + .../compiler/semantics/analyzer/Types.java | 36 ++ .../foreach/ForeachNegativeTests.java | 2 + .../foreach/ForeachOnFailTests.java | 33 ++ .../statements/foreach/foreach-on-fail.bal | 409 +++++++++++++++ .../foreach/foreach-semantics-negative.bal | 28 + .../test/lock/LocksWithOnFailTest.java | 48 +- .../matchstmt/MatchStatementOnFailTest.java | 85 ++- .../statements/onfail/OnFailClauseTest.java | 56 +- .../retrystmt/RetryStmtWithOnFailTest.java | 80 ++- .../whilestatement/WhileStmtTest.java | 81 ++- .../test-src/lock/lock-on-fail-negative.bal | 41 ++ .../resources/test-src/lock/lock-on-fail.bal | 351 +++++++++++++ .../matchstmt/matchstmt_on_fail.bal | 431 ++++++++++++++++ .../matchstmt/matchstmt_on_fail_negative.bal | 58 +-- ...matchstmt_on_fail_negative_unreachable.bal | 66 +++ .../onfail/on-fail-clause-negative.bal | 90 ++++ .../statements/onfail/on-fail-clause.bal | 391 ++++++++++++++ .../retrystmt/retry_on_fail_negative.bal | 90 +--- .../retry_on_fail_negative_unreachable.bal | 89 ++++ .../retrystmt/retry_stmt_with_on_fail.bal | 392 ++++++++++++++ ...ile-stmt-on-fail-negative-reachability.bal | 114 +++++ .../while-stmt-on-fail-negative.bal | 93 +--- .../whilestatement/while-stmt-on-fail.bal | 484 ++++++++++++++++++ 27 files changed, 3460 insertions(+), 348 deletions(-) create mode 100644 tests/jballerina-unit-test/src/test/resources/test-src/lock/lock-on-fail-negative.bal create mode 100644 tests/jballerina-unit-test/src/test/resources/test-src/statements/matchstmt/matchstmt_on_fail_negative_unreachable.bal create mode 100644 tests/jballerina-unit-test/src/test/resources/test-src/statements/retrystmt/retry_on_fail_negative_unreachable.bal create mode 100644 tests/jballerina-unit-test/src/test/resources/test-src/statements/whilestatement/while-stmt-on-fail-negative-reachability.bal diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java index 4435f54a941b..1002e4ee40f5 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java @@ -5151,42 +5151,14 @@ private void analyzeOnFailClause(BLangOnFailClause onFailClause, BLangBlockStmt } } } - private void handleErrorBP(BLangErrorVariable varNode, BLangBlockStmt onFailBody, BLangFail fail) { - BLangErrorVariable errorVar = ASTBuilderUtil.createErrorVariable(varNode.pos, - varNode.getBType(), rewrite(fail.expr, env), varNode.message, varNode.cause, varNode.restDetail, - varNode.detail); - - BLangErrorVariableDef errorVarDef = ASTBuilderUtil.createErrorVariableDef(onFailClause.pos, errorVar); - - BLangStatement stmt = rewrite(errorVarDef, env); - onFailBody.stmts.add(0, stmt); - } - - private void handleCaptureBP(BLangSimpleVariable varNode, BLangBlockStmt onFailBody, BLangFail fail) { - BVarSymbol onFailErrorVariableSymbol = varNode.symbol; - BLangSimpleVariable errorVar = ASTBuilderUtil.createVariable(onFailErrorVariableSymbol.pos, - onFailErrorVariableSymbol.name.value, onFailErrorVariableSymbol.type, rewrite(fail.expr, env), - onFailErrorVariableSymbol); - BLangSimpleVariableDef errorVarDef = ASTBuilderUtil.createVariableDef(onFailClause.pos, errorVar); - env.scope.define(onFailErrorVariableSymbol.name, onFailErrorVariableSymbol); - onFailBody.stmts.add(0, errorVarDef); - } private BLangFail createOnFailInvocation(BLangOnFailClause onFailClause, BLangFail fail) { BLangBlockStmt onFailBody = ASTBuilderUtil.createBlockStmt(onFailClause.pos); onFailBody.stmts.addAll(onFailClause.body.stmts); env.scope.entries.putAll(onFailClause.body.scope.entries); onFailBody.failureBreakMode = onFailClause.body.failureBreakMode; - VariableDefinitionNode onFailVarDefNode = onFailClause.variableDefinitionNode; - if (onFailVarDefNode != null) { - BLangVariable variableNode = (BLangVariable) onFailVarDefNode.getVariable(); - if (variableNode.getKind() == NodeKind.ERROR_VARIABLE) { - handleErrorBP((BLangErrorVariable) variableNode, onFailBody, fail); - } else { - handleCaptureBP((BLangSimpleVariable) variableNode, onFailBody, fail); - } - } + handleOnFailErrorVarDefNode(onFailClause.variableDefinitionNode, onFailBody, fail); if (onFailClause.isInternal && fail.exprStmt != null) { if (fail.exprStmt instanceof BLangPanic) { @@ -5205,6 +5177,38 @@ private BLangFail createOnFailInvocation(BLangOnFailClause onFailClause, BLangFa return fail; } + private void handleOnFailErrorVarDefNode(VariableDefinitionNode onFailVarDefNode, BLangBlockStmt onFailBody, + BLangFail fail) { + if (onFailVarDefNode != null) { + BLangStatement stmt; + BLangVariable variableNode = (BLangVariable) onFailVarDefNode.getVariable(); + if (variableNode.getKind() == NodeKind.ERROR_VARIABLE) { + stmt = handleErrorBPInOnFail((BLangErrorVariable) variableNode, onFailBody, fail); + } else { + stmt = handleCaptureBPInOnFail((BLangSimpleVariable) variableNode, onFailBody, fail); + } + onFailBody.stmts.add(0, stmt); + } + } + + private BLangStatement handleErrorBPInOnFail (BLangErrorVariable varNode, BLangBlockStmt onFailBody, BLangFail fail) { + BLangErrorVariable errorVar = ASTBuilderUtil.createErrorVariable(varNode.pos, + varNode.getBType(), rewrite(fail.expr, env), varNode.message, varNode.cause, varNode.restDetail, + varNode.detail); + BLangErrorVariableDef errorVarDef = ASTBuilderUtil.createErrorVariableDef(onFailClause.pos, errorVar); + return rewrite(errorVarDef, env); + } + + private BLangStatement handleCaptureBPInOnFail(BLangSimpleVariable varNode, BLangBlockStmt onFailBody, BLangFail fail) { + BVarSymbol onFailErrorVariableSymbol = varNode.symbol; + BLangSimpleVariable errorVar = ASTBuilderUtil.createVariable(onFailErrorVariableSymbol.pos, + onFailErrorVariableSymbol.name.value, onFailErrorVariableSymbol.type, rewrite(fail.expr, env), + onFailErrorVariableSymbol); + BLangSimpleVariableDef errorVarDef = ASTBuilderUtil.createVariableDef(onFailClause.pos, errorVar); + env.scope.define(onFailErrorVariableSymbol.name, onFailErrorVariableSymbol); + return errorVarDef; + } + private BLangBlockStmt rewriteNestedOnFail(BLangOnFailClause onFailClause, BLangFail fail) { BLangOnFailClause currentOnFail = this.onFailClause; @@ -5213,18 +5217,8 @@ private BLangBlockStmt rewriteNestedOnFail(BLangOnFailClause onFailClause, BLang onFailBody.scope = onFailClause.body.scope; onFailBody.mapSymbol = onFailClause.body.mapSymbol; onFailBody.failureBreakMode = onFailClause.body.failureBreakMode; - VariableDefinitionNode onFailVarDefNode = onFailClause.variableDefinitionNode; - if (onFailVarDefNode != null) { - BVarSymbol onFailErrorVariableSymbol = - ((BLangSimpleVariableDef) onFailVarDefNode).var.symbol; - BLangSimpleVariable errorVar = ASTBuilderUtil.createVariable(onFailErrorVariableSymbol.pos, - onFailErrorVariableSymbol.name.value, onFailErrorVariableSymbol.type, rewrite(fail.expr, env), - onFailErrorVariableSymbol); - BLangSimpleVariableDef errorVarDef = ASTBuilderUtil.createVariableDef(onFailClause.pos, errorVar); - onFailBody.scope.define(onFailErrorVariableSymbol.name, onFailErrorVariableSymbol); - onFailBody.stmts.add(0, errorVarDef); - } + handleOnFailErrorVarDefNode(onFailClause.variableDefinitionNode, onFailBody, fail); int currentOnFailIndex = this.enclosingOnFailClause.indexOf(this.onFailClause); int enclosingOnFailIndex = currentOnFailIndex <= 0 ? this.enclosingOnFailClause.size() - 1 diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/CodeAnalyzer.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/CodeAnalyzer.java index 8919a2644685..c9ef485b71fd 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/CodeAnalyzer.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/CodeAnalyzer.java @@ -579,7 +579,6 @@ public void visit(BLangTransaction transactionNode, AnalyzerData data) { boolean onFailExists = transactionNode.onFailClause != null; boolean failureHandled = data.failureHandled; if (onFailExists) { - data.errorTypes.push(new LinkedHashSet<>()); data.failureHandled = true; } analyzeNode(transactionNode.transactionBody, data); @@ -654,7 +653,6 @@ public void visit(BLangRetry retryNode, AnalyzerData data) { boolean onFailExists = retryNode.onFailClause != null; boolean failureHandled = data.failureHandled; if (onFailExists) { - data.errorTypes.push(new LinkedHashSet<>()); data.failureHandled = true; } visitNode(retryNode.retrySpec, data); @@ -771,7 +769,6 @@ public void visit(BLangMatchStatement matchStatement, AnalyzerData data) { boolean onFailExists = matchStatement.onFailClause != null; boolean failureHandled = data.failureHandled; if (onFailExists) { - data.errorTypes.push(new LinkedHashSet<>()); data.failureHandled = true; } List matchClauses = matchStatement.matchClauses; @@ -1471,7 +1468,6 @@ public void visit(BLangForeach foreach, AnalyzerData data) { boolean onFailExists = foreach.onFailClause != null; boolean failureHandled = data.failureHandled; if (onFailExists) { - data.errorTypes.push(new LinkedHashSet<>()); data.failureHandled = true; } data.loopCount++; @@ -1492,7 +1488,6 @@ public void visit(BLangWhile whileNode, AnalyzerData data) { boolean failureHandled = data.failureHandled; if (onFailExists) { - data.errorTypes.push(new LinkedHashSet<>()); data.failureHandled = true; } data.loopCount++; @@ -1511,7 +1506,6 @@ public void visit(BLangDo doNode, AnalyzerData data) { boolean onFailExists = doNode.onFailClause != null; boolean failureHandled = data.failureHandled; if (onFailExists) { - data.errorTypes.push(new LinkedHashSet<>()); data.failureHandled = true; } analyzeNode(doNode.body, data); @@ -1529,29 +1523,20 @@ public void visit(BLangFail failNode, AnalyzerData data) { return; } typeChecker.checkExpr(failNode.expr, data.env); - if (!data.errorTypes.empty()) { - data.errorTypes.peek().add(getErrorTypes(failNode.expr.getBType())); - } if (!data.failureHandled) { BType exprType = data.env.enclInvokable.getReturnTypeNode().getBType(); data.returnTypes.peek().add(exprType); - if (!types.isAssignable(getErrorTypes(failNode.expr.getBType()), exprType)) { + if (!types.isAssignable(types.getErrorTypes(failNode.expr.getBType()), exprType)) { dlog.error(failNode.pos, DiagnosticErrorCode.FAIL_EXPR_NO_MATCHING_ERROR_RETURN_IN_ENCL_INVOKABLE); } } } - private BLangBlockStmt.FailureBreakMode getPossibleBreakMode(boolean possibleFailurePresent) { - return possibleFailurePresent ? BLangBlockStmt.FailureBreakMode.BREAK_TO_OUTER_BLOCK - : BLangBlockStmt.FailureBreakMode.NOT_BREAKABLE; - } - @Override public void visit(BLangLock lockNode, AnalyzerData data) { boolean onFailExists = lockNode.onFailClause != null; boolean failureHandled = data.failureHandled; if (onFailExists) { - data.errorTypes.push(new LinkedHashSet<>()); data.failureHandled = true; } boolean previousWithinLockBlock = data.withinLockBlock; @@ -3188,7 +3173,7 @@ public void visit(BLangCheckedExpr checkedExpr, AnalyzerData data) { return; } - BType exprErrorTypes = getErrorTypes(checkedExpr.expr.getBType()); + BType exprErrorTypes = types.getErrorTypes(checkedExpr.expr.getBType()); BType initMethodReturnType = initializerFunc.type.retType; if (!types.isAssignable(exprErrorTypes, initMethodReturnType)) { dlog.error(checkedExpr.pos, DiagnosticErrorCode @@ -3205,7 +3190,7 @@ public void visit(BLangCheckedExpr checkedExpr, AnalyzerData data) { BType exprType = enclInvokable.getReturnTypeNode().getBType(); BType checkedExprType = checkedExpr.expr.getBType(); - BType errorType = getErrorTypes(checkedExprType); + BType errorType = types.getErrorTypes(checkedExprType); if (errorType == symTable.semanticError) { return; @@ -3217,9 +3202,6 @@ public void visit(BLangCheckedExpr checkedExpr, AnalyzerData data) { dlog.error(checkedExpr.pos, DiagnosticErrorCode.CHECKED_EXPR_NO_MATCHING_ERROR_RETURN_IN_ENCL_INVOKABLE); } - if (!data.errorTypes.empty()) { - data.errorTypes.peek().add(getErrorTypes(checkedExpr.expr.getBType())); - } BType errorTypes; if (exprType.tag == TypeTags.UNION) { @@ -3350,16 +3332,11 @@ public void visit(BLangOnFailClause onFailClause, AnalyzerData data) { VariableDefinitionNode onFailVarDefNode = onFailClause.variableDefinitionNode; if (onFailVarDefNode != null) { - BLangVariable onFailVarNode = (BLangVariable) onFailVarDefNode.getVariable(); - for (BType errorType : data.errorTypes.peek()) { - if (!types.isAssignable(errorType, onFailVarNode.getBType())) { - dlog.error(onFailVarNode.pos, DiagnosticErrorCode.INCOMPATIBLE_ON_FAIL_ERROR_DEFINITION, errorType, - onFailVarNode.getBType()); - } + BLangNode onFailVarNode = (BLangNode) onFailClause.getVariableDefinitionNode().getVariable(); + if (onFailVarNode != null) { + analyzeNode(onFailVarNode, data); } - analyzeNode((BLangNode) onFailClause.getVariableDefinitionNode().getVariable().getTypeNode(), data); } - data.errorTypes.pop(); analyzeNode(onFailClause.body, data); onFailClause.bodyContainsFail = data.failVisited; data.failVisited = currentFailVisited; @@ -3368,7 +3345,6 @@ public void visit(BLangOnFailClause onFailClause, AnalyzerData data) { private void analyseOnFailAndUpdateBreakMode(boolean onFailExists, BLangBlockStmt blockStmt, BLangOnFailClause onFailClause, AnalyzerData data) { if (onFailExists) { - blockStmt.failureBreakMode = getPossibleBreakMode(!data.errorTypes.peek().isEmpty()); analyzeOnFailClause(onFailClause, data); } } @@ -3864,40 +3840,6 @@ private void validateModuleInitFunction(BLangFunction funcNode) { types.validateErrorOrNilReturn(funcNode, DiagnosticErrorCode.MODULE_INIT_RETURN_SHOULD_BE_ERROR_OR_NIL); } - private BType getErrorTypes(BType bType) { - if (bType == null) { - return symTable.semanticError; - } - - BType errorType = symTable.semanticError; - - int tag = bType.tag; - if (tag == TypeTags.TYPEREFDESC) { - return getErrorTypes(Types.getReferredType(bType)); - } - if (tag == TypeTags.ERROR) { - errorType = bType; - } else if (tag == TypeTags.READONLY) { - errorType = symTable.errorType; - } else if (tag == TypeTags.UNION) { - LinkedHashSet errTypes = new LinkedHashSet<>(); - Set memTypes = ((BUnionType) bType).getMemberTypes(); - for (BType memType : memTypes) { - BType memErrType = getErrorTypes(memType); - - if (memErrType != symTable.semanticError) { - errTypes.add(memErrType); - } - } - - if (!errTypes.isEmpty()) { - errorType = errTypes.size() == 1 ? errTypes.iterator().next() : BUnionType.create(null, errTypes); - } - } - - return errorType; - } - /** * This class contains the state machines for a set of workers. */ @@ -4178,7 +4120,6 @@ public static class AnalyzerData { boolean withinQuery; Types.QueryConstructType queryConstructType; Stack> returnTypes = new Stack<>(); - Stack> errorTypes = new Stack<>(); DefaultValueState defaultValueState = DefaultValueState.NOT_IN_DEFAULT_VALUE; } } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SemanticAnalyzer.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SemanticAnalyzer.java index b1403056120a..ba818e572b48 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SemanticAnalyzer.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SemanticAnalyzer.java @@ -2106,12 +2106,12 @@ void handleDeclaredVarInForeach(BLangVariable variable, BType rhsType, SymbolEnv break; case ERROR_VARIABLE: BLangErrorVariable errorVariable = (BLangErrorVariable) variable; + errorVariable.setBType(rhsType); if (TypeTags.ERROR != Types.getReferredType(rhsType).tag) { dlog.error(variable.pos, DiagnosticErrorCode.INVALID_TYPE_DEFINITION_FOR_ERROR_VAR, rhsType); recursivelyDefineVariables(errorVariable, blockEnv); return; } - errorVariable.setBType(rhsType); this.symbolEnter.validateErrorVariable(errorVariable, blockEnv); recursivelySetFinalFlag(errorVariable); break; @@ -2882,6 +2882,10 @@ public void visit(BLangMatchStatement matchStatement, AnalyzerData data) { if (matchClauses.size() == 0) { return; } + boolean onFailExists = matchStatement.onFailClause != null; + if (onFailExists) { + data.commonAnalyzerData.errorTypes.push(new LinkedHashSet<>()); + } analyzeNode(matchClauses.get(0), data); SymbolEnv matchClauseEnv = data.env; @@ -2894,7 +2898,7 @@ public void visit(BLangMatchStatement matchStatement, AnalyzerData data) { analyzeNode(currentMatchClause, data); } - if (matchStatement.onFailClause != null) { + if (onFailExists) { this.analyzeNode(matchStatement.onFailClause, data); } } @@ -3853,13 +3857,16 @@ public void visit(BLangForeach foreach, AnalyzerData data) { handleForeachDefinitionVariables(foreach.variableDefinitionNode, foreach.varType, foreach.isDeclaredWithVar, false, blockEnv); boolean prevBreakFound = data.breakFound; + boolean onFailExists = foreach.onFailClause != null; + if (onFailExists) { + data.commonAnalyzerData.errorTypes.push(new LinkedHashSet<>()); + } + // Analyze foreach node's statements. data.env = blockEnv; analyzeStmt(foreach.body, data); - if (foreach.onFailClause != null) { - this.analyzeNode(foreach.onFailClause, data); - } + updateBreakMode(onFailExists, foreach.body, foreach.onFailClause, data); data.notCompletedNormally = false; data.breakFound = prevBreakFound; } @@ -3869,33 +3876,71 @@ public void visit(BLangOnFailClause onFailClause, AnalyzerData data) { // Create a new block environment for the on-fail node. SymbolEnv onFailEnv = SymbolEnv.createBlockEnv(onFailClause.body, data.env); VariableDefinitionNode onFailVarDefNode = onFailClause.variableDefinitionNode; + Stack> onFailErrTypes = data.commonAnalyzerData.errorTypes; + if (onFailVarDefNode != null) { BLangVariable variableNode = (BLangVariable) onFailVarDefNode.getVariable(); if (variableNode.getKind() != NodeKind.VARIABLE && variableNode.getKind() != NodeKind.ERROR_VARIABLE) { dlog.error(variableNode.pos, DiagnosticErrorCode.INVALID_BINDING_PATTERN_IN_ON_FAIL); - return; } + + BType failErrorType; + LinkedHashSet onFailErrType = onFailErrTypes.peek(); + boolean isVarTypeHardcoded = false; + if (onFailErrType.size() == 1) { + failErrorType = onFailErrType.iterator().next(); + } else if (onFailErrType.size() > 1) { + failErrorType = BUnionType.create(null, onFailErrType); + } else { + failErrorType = symTable.errorType; + isVarTypeHardcoded = true; + } + // Check on-fail node's variables and set types. - handleForeachDefinitionVariables(onFailVarDefNode, symTable.errorType, - onFailClause.isDeclaredWithVar, true, onFailEnv); + handleForeachDefinitionVariables(onFailVarDefNode, failErrorType, + onFailClause.isDeclaredWithVar, isVarTypeHardcoded, onFailEnv); BLangVariable onFailVarNode = (BLangVariable) onFailVarDefNode.getVariable(); - if (!types.isAssignable(onFailVarNode.getBType(), symTable.errorType)) { + + if (onFailVarNode.getBType() != null && !types.isAssignable(onFailVarNode.getBType(), symTable.errorType)) { dlog.error(onFailVarNode.pos, DiagnosticErrorCode.INVALID_TYPE_DEFINITION_FOR_ERROR_VAR, onFailVarNode.getBType()); } + + for (BType errorType : onFailErrTypes.peek()) { + if (onFailVarNode.getBType() != null && !types.isAssignable(errorType, onFailVarNode.getBType())) { + dlog.error(onFailVarNode.pos, DiagnosticErrorCode.INCOMPATIBLE_ON_FAIL_ERROR_DEFINITION, errorType, + onFailVarNode.getBType()); + } + } } + + onFailErrTypes.pop(); data.env = onFailEnv; analyzeStmt(onFailClause.body, data); } + private void updateBreakMode(boolean onFailExists, BLangBlockStmt blockStmt, BLangOnFailClause onFailClause, + AnalyzerData data) { + if (onFailExists) { + blockStmt.failureBreakMode = getPossibleBreakMode(!data.commonAnalyzerData.errorTypes.peek().isEmpty()); + this.analyzeNode(onFailClause, data); + } + } + + private BLangBlockStmt.FailureBreakMode getPossibleBreakMode(boolean possibleFailurePresent) { + return possibleFailurePresent ? BLangBlockStmt.FailureBreakMode.BREAK_TO_OUTER_BLOCK + : BLangBlockStmt.FailureBreakMode.NOT_BREAKABLE; + } + @Override public void visit(BLangWhile whileNode, AnalyzerData data) { SymbolEnv currentEnv = data.env; typeChecker.checkExpr(whileNode.expr, currentEnv, symTable.booleanType, data.prevEnvs, data.commonAnalyzerData); - if (whileNode.onFailClause != null) { - this.analyzeNode(whileNode.onFailClause, data); + boolean onFailExists = whileNode.onFailClause != null; + if (onFailExists) { + data.commonAnalyzerData.errorTypes.push(new LinkedHashSet<>()); } BType actualType = whileNode.expr.getBType(); @@ -3911,15 +3956,18 @@ public void visit(BLangWhile whileNode, AnalyzerData data) { ConditionResolver.checkConstCondition(types, symTable, whileNode.expr) == symTable.trueType && !data.breakFound; data.breakFound = prevBreakFound; + updateBreakMode(onFailExists, whileNode.body, whileNode.onFailClause, data); } @Override public void visit(BLangDo doNode, AnalyzerData data) { data.env = SymbolEnv.createTypeNarrowedEnv(doNode, data.env); - if (doNode.onFailClause != null) { - this.analyzeNode(doNode.onFailClause, data); + boolean onFailExists = doNode.onFailClause != null; + if (onFailExists) { + data.commonAnalyzerData.errorTypes.push(new LinkedHashSet<>()); } analyzeStmt(doNode.body, data); + updateBreakMode(onFailExists, doNode.body, doNode.onFailClause, data); } @Override @@ -3927,7 +3975,9 @@ public void visit(BLangFail failNode, AnalyzerData data) { BLangExpression errorExpression = failNode.expr; BType errorExpressionType = typeChecker.checkExpr(errorExpression, data.env, data.prevEnvs, data.commonAnalyzerData); - + if (!data.commonAnalyzerData.errorTypes.empty()) { + data.commonAnalyzerData.errorTypes.peek().add(types.getErrorTypes(failNode.expr.getBType())); + } if (errorExpressionType == symTable.semanticError || !types.isSubTypeOfBaseType(errorExpressionType, symTable.errorType.tag)) { dlog.error(errorExpression.pos, DiagnosticErrorCode.ERROR_TYPE_EXPECTED, errorExpressionType); @@ -3938,10 +3988,12 @@ public void visit(BLangFail failNode, AnalyzerData data) { @Override public void visit(BLangLock lockNode, AnalyzerData data) { data.env = SymbolEnv.createLockEnv(lockNode, data.env); - analyzeStmt(lockNode.body, data); - if (lockNode.onFailClause != null) { - this.analyzeNode(lockNode.onFailClause, data); + boolean onFailExists = lockNode.onFailClause != null; + if (onFailExists) { + data.commonAnalyzerData.errorTypes.push(new LinkedHashSet<>()); } + analyzeStmt(lockNode.body, data); + updateBreakMode(onFailExists, lockNode.body, lockNode.onFailClause, data); } @Override @@ -4150,11 +4202,12 @@ private void validateDefaultable(BLangRecordTypeNode recordTypeNode) { @Override public void visit(BLangTransaction transactionNode, AnalyzerData data) { data.env = SymbolEnv.createTransactionEnv(transactionNode, data.env); - - if (transactionNode.onFailClause != null) { - this.analyzeNode(transactionNode.onFailClause, data); + boolean onFailExists = transactionNode.onFailClause != null; + if (onFailExists) { + data.commonAnalyzerData.errorTypes.push(new LinkedHashSet<>()); } analyzeStmt(transactionNode.transactionBody, data); + updateBreakMode(onFailExists, transactionNode.transactionBody, transactionNode.onFailClause, data); } @Override @@ -4181,11 +4234,12 @@ public void visit(BLangRetry retryNode, AnalyzerData data) { retryNode.retrySpec.accept(this, data); } data.env = SymbolEnv.createRetryEnv(retryNode, data.env); - analyzeStmt(retryNode.retryBody, data); - - if (retryNode.onFailClause != null) { - this.analyzeNode(retryNode.onFailClause, data); + boolean onFailExists = retryNode.onFailClause != null; + if (onFailExists) { + data.commonAnalyzerData.errorTypes.push(new LinkedHashSet<>()); } + analyzeStmt(retryNode.retryBody, data); + updateBreakMode(onFailExists, retryNode.retryBody, retryNode.onFailClause, data); } @Override @@ -4397,7 +4451,8 @@ private void checkAnnotConstantExpression(BLangExpression expression) { } private void handleForeachDefinitionVariables(VariableDefinitionNode variableDefinitionNode, BType varType, - boolean isDeclaredWithVar, boolean isOnFailDef, SymbolEnv blockEnv) { + boolean isDeclaredWithVar, boolean isVarTypeHardcoded, + SymbolEnv blockEnv) { BLangVariable variableNode = (BLangVariable) variableDefinitionNode.getVariable(); // Check whether the foreach node's variables are declared with var. if (isDeclaredWithVar) { @@ -4406,13 +4461,15 @@ private void handleForeachDefinitionVariables(VariableDefinitionNode variableDef return; } // If the type node is available, we get the type from it. + // Then, if the `varType` was hardcoded as `symtable.errorType`, we swap them and check whether `typeNodeType` + // is assignable to `symtable.errorType` BType typeNodeType = symResolver.resolveTypeNode(variableNode.typeNode, blockEnv); - if (isOnFailDef) { + if (isVarTypeHardcoded) { BType sourceType = varType; varType = typeNodeType; typeNodeType = sourceType; } - // Then we need to check whether the RHS type is assignable to LHS type. + // Checking whether the RHS type is assignable to LHS type. if (types.isAssignable(varType, typeNodeType)) { // If assignable, we set types to the variables. handleDeclaredVarInForeach(variableNode, varType, blockEnv); diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/TypeChecker.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/TypeChecker.java index 59704de86c20..0137417d1cf8 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/TypeChecker.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/TypeChecker.java @@ -6109,6 +6109,10 @@ protected void visitCheckAndCheckPanicExpr(BLangCheckedExpr checkedExpr, Analyze errorTypes.add(exprType); } + if (!data.commonAnalyzerData.errorTypes.empty()) { + data.commonAnalyzerData.errorTypes.peek().add(types.getErrorTypes(checkedExpr.expr.getBType())); + } + // This list will be used in the desugar phase checkedExpr.equivalentErrorTypeList = errorTypes; if (errorTypes.isEmpty()) { diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/Types.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/Types.java index 252d342ee605..2b879767da06 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/Types.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/Types.java @@ -253,6 +253,40 @@ public boolean typeIncompatible(Location pos, BType actualType, BType expType) { return checkType(pos, actualType, expType, DiagnosticErrorCode.INCOMPATIBLE_TYPES) == symTable.semanticError; } + public BType getErrorTypes(BType bType) { + if (bType == null) { + return symTable.semanticError; + } + + BType errorType = symTable.semanticError; + + int tag = bType.tag; + if (tag == TypeTags.TYPEREFDESC) { + return getErrorTypes(Types.getReferredType(bType)); + } + if (tag == TypeTags.ERROR) { + errorType = bType; + } else if (tag == TypeTags.READONLY) { + errorType = symTable.errorType; + } else if (tag == TypeTags.UNION) { + LinkedHashSet errTypes = new LinkedHashSet<>(); + Set memTypes = ((BUnionType) bType).getMemberTypes(); + for (BType memType : memTypes) { + BType memErrType = getErrorTypes(memType); + + if (memErrType != symTable.semanticError) { + errTypes.add(memErrType); + } + } + + if (!errTypes.isEmpty()) { + errorType = errTypes.size() == 1 ? errTypes.iterator().next() : BUnionType.create(null, errTypes); + } + } + + return errorType; + } + public BType checkType(Location pos, BType actualType, BType expType, @@ -7137,6 +7171,8 @@ public static class CommonAnalyzerData { boolean breakToParallelQueryEnv = false; int letCount = 0; boolean nonErrorLoggingCheck = false; + + Stack> errorTypes = new Stack<>(); } /** diff --git a/langlib/langlib-test/src/test/java/org/ballerinalang/langlib/test/statements/foreach/ForeachNegativeTests.java b/langlib/langlib-test/src/test/java/org/ballerinalang/langlib/test/statements/foreach/ForeachNegativeTests.java index 27687a5ac812..038ecd41f297 100644 --- a/langlib/langlib-test/src/test/java/org/ballerinalang/langlib/test/statements/foreach/ForeachNegativeTests.java +++ b/langlib/langlib-test/src/test/java/org/ballerinalang/langlib/test/statements/foreach/ForeachNegativeTests.java @@ -104,6 +104,8 @@ public void testForeachSemanticsNegative() { "mismatch with member type count", 342, 13); BAssertUtil.validateError(compile, index++, "invalid list binding pattern; member variable count " + "mismatch with member type count", 346, 18); + BAssertUtil.validateError(compile, index++, "invalid error variable; expecting an error type " + + "but found '(SampleComplexError|SampleError)' in type definition", 374, 15); Assert.assertEquals(compile.getErrorCount(), index); } diff --git a/langlib/langlib-test/src/test/java/org/ballerinalang/langlib/test/statements/foreach/ForeachOnFailTests.java b/langlib/langlib-test/src/test/java/org/ballerinalang/langlib/test/statements/foreach/ForeachOnFailTests.java index 375d29f8cc34..348415426e06 100644 --- a/langlib/langlib-test/src/test/java/org/ballerinalang/langlib/test/statements/foreach/ForeachOnFailTests.java +++ b/langlib/langlib-test/src/test/java/org/ballerinalang/langlib/test/statements/foreach/ForeachOnFailTests.java @@ -25,6 +25,7 @@ import org.testng.Assert; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; +import org.testng.annotations.DataProvider; import org.testng.annotations.Test; /** @@ -85,4 +86,36 @@ public void testNestedWhileStmtWithFail() { Assert.assertTrue(result instanceof BString); Assert.assertEquals(result.toString(), expected); } + + @Test(dataProvider = "onFailClauseWithErrorBPTestDataProvider") + public void testOnFailWithErrorBP(String funcName) { + BRunUtil.invoke(program, funcName); + } + + @DataProvider(name = "onFailClauseWithErrorBPTestDataProvider") + public Object[] onFailClauseWithErrorBPTestDataProvider() { + return new Object[]{ + "testSimpleOnFailWithErrorBP", + "testSimpleOnFailWithErrorBPWithVar", + "testOnFailWithErrorBPHavingUserDefinedTypeWithError", + "testOnFailWithErrorBPHavingUserDefinedTypeWithVar", + "testOnFailWithErrorBPHavingUserDefinedType", + "testOnFailWithErrorBPHavingUserDefinedTypeWithErrDetail1", + "testOnFailWithErrorBPHavingUserDefinedTypeWithErrDetail2", + "testOnFailWithErrorBPHavingUserDefinedTypeWithErrDetail3", + "testOnFailWithErrorBPHavingUserDefinedTypeWithErrDetail4", + "testOnFailWithErrorBPHavingAnonDetailRecord", + "testOnFailWithErrorBPHavingAnonDetailRecordWithVar", + "testOnFailWithErrorBPHavingAnonDetailRecordWithUnionType", + "testOnFailWithErrorBPWithErrorArgsHavingBP1", + "testOnFailWithErrorBPWithErrorArgsHavingBP2", + "testOnFailWithErrorBPWithErrorArgsHavingBP3", + "testOnFailWithErrorBPWithErrorArgsHavingBP4", + "testOnFailWithErrorBPWithErrorArgsHavingBP5", + "testNestedOnFailWithErrorBP", + "testNestedOnFailWithErrorBPWithErrorArgsHavingBP", + "testMultiLevelOnFailWithErrorBP", + "testMultiLevelOnFailWithoutErrorInOneLevel" + }; + } } diff --git a/langlib/langlib-test/src/test/resources/test-src/statements/foreach/foreach-on-fail.bal b/langlib/langlib-test/src/test/resources/test-src/statements/foreach/foreach-on-fail.bal index 604aa95c37f3..4dd0f1ffc8da 100644 --- a/langlib/langlib-test/src/test/resources/test-src/statements/foreach/foreach-on-fail.bal +++ b/langlib/langlib-test/src/test/resources/test-src/statements/foreach/foreach-on-fail.bal @@ -93,3 +93,412 @@ function testNestedForeachLoopBreak() returns string { } return result; } + +type SampleErrorData record {| + int code; + string reason; +|}; + +type SampleError error; + +string testMessage = ""; +int testErrorCode = 0; +string testErrorReason = ""; + +function testSimpleOnFailWithErrorBP() { + foreach var i in data { + fail error("error!"); + } on fail error error(msg) { + testMessage = msg; + } + assertEquality(testMessage, "error!"); +} + +function testSimpleOnFailWithErrorBPWithVar() { + foreach var i in data { + fail error("error!"); + } on fail var error(msg) { + testMessage = msg; + } + assertEquality(testMessage, "error!"); +} + +function testOnFailWithErrorBPHavingUserDefinedTypeWithError() { + foreach var i in data { + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } on fail error error(msg, code = errCode, reason = errReason) { + testErrorCode = errCode; + testErrorReason = errReason; + testMessage = msg; + } + assertEquality(testMessage, "error!"); + assertEquality(testErrorCode, 20); + assertEquality(testErrorReason, "deadlock condition"); + assertEquality(testErrorCode is int, true); + assertEquality(testErrorReason is string, true); +} + +function testOnFailWithErrorBPHavingUserDefinedTypeWithVar() { + foreach var i in data { + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } on fail var error(msg, code = errCode, reason = errReason) { + testErrorCode = errCode; + testErrorReason = errReason; + testMessage = msg; + } + assertEquality(testMessage, "error!"); + assertEquality(testErrorCode, 20); + assertEquality(testErrorReason, "deadlock condition"); + assertEquality(testErrorCode is int, true); + assertEquality(testErrorReason is string, true); +} + +function testOnFailWithErrorBPHavingUserDefinedType() { + foreach var i in data { + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } on fail SampleError error(msg, code = errCode, reason = errReason) { + testErrorCode = errCode; + testErrorReason = errReason; + testMessage = msg; + } + assertEquality(testMessage, "error!"); + assertEquality(testErrorCode, 20); + assertEquality(testErrorReason, "deadlock condition"); + assertEquality(testErrorCode is int, true); + assertEquality(testErrorReason is string, true); +} + +function testOnFailWithErrorBPHavingUserDefinedTypeWithErrDetail1() { + foreach var i in data { + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } on fail error error(msg, code = errCode, reason = errReason) { + testErrorCode = errCode; + testErrorReason = errReason; + testMessage = msg; + } + assertEquality(testMessage, "error!"); + assertEquality(testErrorCode, 20); + assertEquality(testErrorReason, "deadlock condition"); + assertEquality(testErrorCode is int, true); + assertEquality(testErrorReason is string, true); +} + +function testOnFailWithErrorBPHavingUserDefinedTypeWithErrDetail2() { + foreach var i in data { + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } on fail error error(code = errCode) { + testErrorCode = errCode; + } + assertEquality(testErrorCode, 20); + assertEquality(testErrorCode is int, true); +} + +function testOnFailWithErrorBPHavingUserDefinedTypeWithErrDetail3() { + foreach var i in data { + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } on fail error error(code = errCode, reason = errReason) { + testErrorCode = errCode; + testErrorReason = errReason; + } + assertEquality(testErrorCode, 20); + assertEquality(testErrorReason, "deadlock condition"); + assertEquality(testErrorCode is int, true); + assertEquality(testErrorReason is string, true); +} + +function testOnFailWithErrorBPHavingUserDefinedTypeWithErrDetail4() { + foreach var i in data { + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } on fail error error(code = errCode) { + testErrorCode = errCode; + } + assertEquality(testErrorCode, 20); + assertEquality(testErrorCode is int, true); +} + +function testOnFailWithErrorBPHavingAnonDetailRecord() { + foreach var i in data { + error errVar = error("error", code = 34); + fail errVar; + } on fail error error(code = errCode) { + testErrorCode = errCode; + } + assertEquality(testErrorCode, 34); + assertEquality(testErrorCode is int, true); +} + +function testOnFailWithErrorBPHavingAnonDetailRecordWithVar() { + foreach var i in data { + error errVar = error("error", code = 34); + fail errVar; + } on fail var error(msg, code = errCode) { + testErrorCode = errCode; + testErrorReason = msg; + } + assertEquality(testErrorCode, 34); + assertEquality(testErrorCode is int, true); + assertEquality(testErrorReason is string, true); + assertEquality(testErrorReason, "error"); +} + +function testOnFailWithErrorBPHavingAnonDetailRecordWithUnionType() { + foreach var i in data { + error errVar = error("error", code = 34); + fail errVar; + } on fail error error(code = errCode) { + testErrorCode = errCode; + } + assertEquality(testErrorCode, 34); + assertEquality(testErrorCode is int, true); +} + +type SampleComplexErrorData record {| + error cause; + int code; + int[2] pos; + record {string moreInfo;} infoDetails; +|}; + +type SampleComplexError error; + +int testErrorPosRow = 0; +int testErrorPosCol = 0; +string testErrorMoreInfo = ""; + + +function testOnFailWithErrorBPWithErrorArgsHavingBP1() { + string causeMsg; + foreach var i in data { + fail error SampleComplexError("Transaction Failure", cause = error("Database Error"), code = 20, pos = [30, 45], infoDetails = {moreInfo: "deadlock condition"}); + } on fail SampleComplexError error(_, cause = errCause, code = errCode, pos = errorPos, infoDetails = errInfo) { + testErrorCode = errCode; + testErrorPosRow = errorPos[0]; + testErrorPosCol = errorPos[1]; + testErrorMoreInfo = errInfo.moreInfo; + causeMsg = errCause.message(); + } + assertEquality(testErrorPosRow, 30); + assertEquality(testErrorPosRow is int, true); + assertEquality(testErrorPosCol, 45); + assertEquality(testErrorPosCol is int, true); + assertEquality(testErrorMoreInfo, "deadlock condition"); + assertEquality(testErrorMoreInfo is string, true); + assertEquality(testErrorCode, 20); + assertEquality(testErrorCode is int, true); + assertEquality(causeMsg, "Database Error"); + assertEquality(causeMsg is string, true); +} + +function testOnFailWithErrorBPWithErrorArgsHavingBP2() { + foreach var i in data { + fail error SampleComplexError("Transaction Failure", cause = error("Database Error"), code = 20, pos = [30, 45], infoDetails = {moreInfo: "deadlock condition"}); + } on fail SampleComplexError error(message, cause = error(msg), code = errCode, pos = errorPos, infoDetails = errInfo) { + testErrorCode = errCode; + testErrorPosRow = errorPos[0]; + testErrorPosCol = errorPos[1]; + testErrorMoreInfo = errInfo.moreInfo; + testMessage = msg; + } + assertEquality(testErrorPosRow, 30); + assertEquality(testErrorPosRow is int, true); + assertEquality(testErrorPosCol, 45); + assertEquality(testErrorPosCol is int, true); + assertEquality(testErrorMoreInfo, "deadlock condition"); + assertEquality(testErrorMoreInfo is string, true); + assertEquality(testErrorCode, 20); + assertEquality(testErrorCode is int, true); + assertEquality(testMessage, "Database Error"); + assertEquality(testMessage is string, true); +} + +function testOnFailWithErrorBPWithErrorArgsHavingBP3() { + foreach var i in data { + fail error SampleComplexError("Transaction Failure", cause = error("Database Error"), code = 20, pos = [30, 45], infoDetails = {moreInfo: "deadlock condition"}); + } on fail SampleComplexError error(message, cause = error(msg), code = errCode, pos = [row, col], infoDetails = errInfo) { + testErrorCode = errCode; + testErrorPosRow = row; + testErrorPosCol = col; + testErrorMoreInfo = errInfo.moreInfo; + testMessage = msg; + } + assertEquality(testErrorPosRow, 30); + assertEquality(testErrorPosRow is int, true); + assertEquality(testErrorPosCol, 45); + assertEquality(testErrorPosCol is int, true); + assertEquality(testErrorMoreInfo, "deadlock condition"); + assertEquality(testErrorMoreInfo is string, true); + assertEquality(testErrorCode, 20); + assertEquality(testErrorCode is int, true); + assertEquality(testMessage, "Database Error"); + assertEquality(testMessage is string, true); +} + +function testOnFailWithErrorBPWithErrorArgsHavingBP4() { + foreach var i in data { + fail error SampleComplexError("Transaction Failure", cause = error("Database Error"), code = 20, pos = [30, 45], infoDetails = {moreInfo: "deadlock condition"}); + } on fail SampleComplexError error(_, cause = error(msg), code = errCode, pos = [row, col], infoDetails = {moreInfo: errInfo}) { + testErrorCode = errCode; + testErrorPosRow = row; + testErrorPosCol = col; + testErrorMoreInfo = errInfo; + testMessage = msg; + } + assertEquality(testErrorPosRow, 30); + assertEquality(testErrorPosRow is int, true); + assertEquality(testErrorPosCol, 45); + assertEquality(testErrorPosCol is int, true); + assertEquality(testErrorMoreInfo, "deadlock condition"); + assertEquality(testErrorMoreInfo is string, true); + assertEquality(testErrorCode, 20); + assertEquality(testErrorCode is int, true); + assertEquality(testMessage, "Database Error"); + assertEquality(testMessage is string, true); +} + +function testOnFailWithErrorBPWithErrorArgsHavingBP5() { + foreach var i in data { + fail error SampleComplexError("Transaction Failure", cause = error("Database Error"), code = 20, pos = [30, 45], infoDetails = {moreInfo: "deadlock condition"}); + } on fail var error(_, cause = error(msg), code = errCode, pos = [row, col], infoDetails = {moreInfo: errInfo}) { + testErrorCode = errCode; + testErrorPosRow = row; + testErrorPosCol = col; + testErrorMoreInfo = errInfo; + testMessage = msg; + } + assertEquality(testErrorPosRow, 30); + assertEquality(testErrorPosRow is int, true); + assertEquality(testErrorPosCol, 45); + assertEquality(testErrorPosCol is int, true); + assertEquality(testErrorMoreInfo, "deadlock condition"); + assertEquality(testErrorMoreInfo is string, true); + assertEquality(testErrorCode, 20); + assertEquality(testErrorCode is int, true); + assertEquality(testMessage, "Database Error"); + assertEquality(testMessage is string, true); +} + +int testErrorCodeNested = 0; +string testMessageNested = ""; + +function testNestedOnFailWithErrorBP() { + string testErrorReasonNested = ""; + foreach var i in data { + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } on fail var error(msg1, code = errCode1, reason = errReason1) { + if errCode1 == 20 { + foreach var j in data { + fail error SampleError("nested error!", code = 30, reason = "database error"); + } on fail var error(msg2, code = errCode2, reason = errReason2) { + testErrorCode = errCode1; + testErrorCodeNested = errCode2; + testErrorReason = errReason1; + testErrorReasonNested = errReason2; + testMessage = msg1; + testMessageNested = msg2; + } + } + } + + assertEquality(testErrorCode, 20); + assertEquality(testErrorCodeNested, 30); + assertEquality(testErrorReason, "deadlock condition"); + assertEquality(testErrorReasonNested, "database error"); + assertEquality(testMessage, "error!"); + assertEquality(testMessageNested, "nested error!"); +} + +function testNestedOnFailWithErrorBPWithErrorArgsHavingBP() { + foreach var i in data { + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } on fail var error(msg1, code = errCode1, reason = errReason1) { + if errCode1 == 20 { + foreach var j in data { + fail error SampleComplexError("nested error!", cause = error("Database Error"), code = 30, pos = [35, 45], infoDetails = {moreInfo: "deadlock condition"}); + } on fail SampleComplexError error(_, cause = error(msg2), code = errCode2, pos = [row, col], infoDetails = {moreInfo: errInfo}) { + testErrorCode = errCode1; + testErrorCodeNested = errCode2; + testMessage = msg1; + testMessageNested = msg2; + testErrorPosRow = row; + testErrorPosCol = col; + testErrorMoreInfo = errInfo; + } + } + } + + assertEquality(testErrorCode, 20); + assertEquality(testErrorCodeNested, 30); + assertEquality(testErrorMoreInfo, "deadlock condition"); + assertEquality(testMessage, "error!"); + assertEquality(testMessageNested, "Database Error"); + assertEquality(testErrorPosRow, 35); + assertEquality(testErrorPosCol, 45); +} + +function testMultiLevelOnFailWithErrorBP() { + string str = ""; + int[] level1dData = [2]; + int[] nestedData = [1]; + + foreach var i in level1dData { + foreach var j in nestedData { + str += " -> Iteration " + i.toString() + ", "; + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } on fail var error(msg1, code = errCode1, reason = errReason1) { + str += " -> On Fail #" + i.toString(); + testMessage = msg1; + testErrorCode = errCode1; + testErrorReason = errReason1; + } + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } on fail SampleError error(msg2, code = errCode2, reason = errReason2) { + str += " -> On Fail Final"; + } + + assertEquality(" -> Iteration 2, -> On Fail #2 -> On Fail Final", str); + assertEquality(testErrorCode, 20); + assertEquality(testErrorReason, "deadlock condition"); + assertEquality(testMessage, "error!"); +} + +function testMultiLevelOnFailWithoutErrorInOneLevel() { + string str = ""; + int[] nestedData = [1]; + int[] level1dData = [2]; + + foreach var i in level1dData { + foreach var j in nestedData { + str += " -> Iteration " + i.toString() + ", "; + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } on fail var error(msg1, code = errCode1, reason = errReason1) { + str += " -> On Fail #" + i.toString(); + testMessage = msg1; + testErrorCode = errCode1; + testErrorReason = errReason1; + } + } on fail SampleError error(msg2, code = errCode2, reason = errReason2) { + str += " -> On Fail Final"; + } + + assertEquality(" -> Iteration 2, -> On Fail #2", str); + assertEquality(testErrorCode, 20); + assertEquality(testErrorReason, "deadlock condition"); + assertEquality(testMessage, "error!"); +} + +type AssertionError error; + +function assertEquality(any|error expected, any|error actual) { + if expected is anydata && actual is anydata && expected == actual { + return; + } + + if expected === actual { + return; + } + + string expectedValAsString = expected is error ? expected.toString() : expected.toString(); + string actualValAsString = actual is error ? actual.toString() : actual.toString(); + panic error AssertionError("AssertionError", + message = "expected '" + expectedValAsString + "', found '" + actualValAsString + "'"); +} diff --git a/langlib/langlib-test/src/test/resources/test-src/statements/foreach/foreach-semantics-negative.bal b/langlib/langlib-test/src/test/resources/test-src/statements/foreach/foreach-semantics-negative.bal index ef89569e1a7a..13e41969f3a2 100644 --- a/langlib/langlib-test/src/test/resources/test-src/statements/foreach/foreach-semantics-negative.bal +++ b/langlib/langlib-test/src/test/resources/test-src/statements/foreach/foreach-semantics-negative.bal @@ -346,3 +346,31 @@ function testInvalidTupleVarRefWithMismatchingTypesInForeach() { foreach var [[c1, c2, ...c3], c4] in c { } } + +type SampleErrorData record {| + int code; + string reason; +|}; + +type SampleError error; + +type SampleComplexErrorData record {| + int code; + int[2] pos; + record {string moreInfo;} infoDetails; +|}; + +type SampleComplexError error; + +function testOnFailWithMultipleErrors() { + boolean isPositiveState = false; + int[] nestedData = [1]; + + foreach var i in nestedData { + if isPositiveState { + fail error SampleComplexError("Transaction Failure", code = 20, pos = [30, 45], infoDetails = {moreInfo: "deadlock condition"}); + } + fail error SampleError("Transaction Failure", code = 50, reason = "deadlock condition"); + } on fail var error(msg) { + } +} diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/lock/LocksWithOnFailTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/lock/LocksWithOnFailTest.java index 29e2b04693cf..76247449b2df 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/lock/LocksWithOnFailTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/lock/LocksWithOnFailTest.java @@ -20,11 +20,14 @@ import io.ballerina.runtime.api.values.BArray; import io.ballerina.runtime.api.values.BString; +import org.ballerinalang.test.BAssertUtil; import org.ballerinalang.test.BCompileUtil; import org.ballerinalang.test.BRunUtil; import org.ballerinalang.test.CompileResult; +import org.testng.Assert; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; +import org.testng.annotations.DataProvider; import org.testng.annotations.Test; import static org.testng.Assert.assertEquals; @@ -33,16 +36,18 @@ /** * Tests for Ballerina locks with on fail clause. - * + * * @since 0.961.0 */ public class LocksWithOnFailTest { - private CompileResult compileResult; + private CompileResult compileResult, compileResultNegative; @BeforeClass public void setup() { + compileResult = BCompileUtil.compile("test-src/lock/lock-on-fail.bal"); + compileResultNegative = BCompileUtil.compile("test-src/lock/lock-on-fail-negative.bal"); } @Test(description = "Tests lock within a lock") @@ -71,8 +76,47 @@ public void testOnFailLockWithinLockWithoutVariable() { BRunUtil.invoke(compileResult, "onFailLockWithinLockWithoutVariable"); } + @Test(dataProvider = "onFailClauseWithErrorBPTestDataProvider") + public void testOnFailWithErrorBP(String funcName) { + BRunUtil.invoke(compileResult, funcName); + } + + @DataProvider(name = "onFailClauseWithErrorBPTestDataProvider") + public Object[] onFailClauseWithErrorBPTestDataProvider() { + return new Object[]{ + "testSimpleOnFailWithErrorBP", + "testSimpleOnFailWithErrorBPWithVar", + "testOnFailWithErrorBPHavingUserDefinedTypeWithError", + "testOnFailWithErrorBPHavingUserDefinedTypeWithVar", + "testOnFailWithErrorBPHavingUserDefinedType", + "testOnFailWithErrorBPHavingUserDefinedTypeWithErrDetail1", + "testOnFailWithErrorBPHavingUserDefinedTypeWithErrDetail2", + "testOnFailWithErrorBPHavingUserDefinedTypeWithErrDetail3", + "testOnFailWithErrorBPHavingUserDefinedTypeWithErrDetail4", + "testOnFailWithErrorBPHavingAnonDetailRecord", + "testOnFailWithErrorBPHavingAnonDetailRecordWithVar", + "testOnFailWithErrorBPHavingAnonDetailRecordWithUnionType", + "testOnFailWithErrorBPWithErrorArgsHavingBP1", + "testOnFailWithErrorBPWithErrorArgsHavingBP2", + "testOnFailWithErrorBPWithErrorArgsHavingBP3", + "testOnFailWithErrorBPWithErrorArgsHavingBP4", + "testOnFailWithErrorBPWithErrorArgsHavingBP5", + "testMultiLevelOnFailWithErrorBP", + "testMultiLevelOnFailWithoutErrorInOneLevel" + }; + } + + @Test(description = "Check incompatible types.") + public void testNegative() { + int i = 0; + BAssertUtil.validateError(compileResultNegative, i++, "invalid error variable; expecting an " + + "error type but found '(SampleComplexError|SampleError)' in type definition", 39, 15); + Assert.assertEquals(compileResultNegative.getErrorCount(), i); + } + @AfterClass public void tearDown() { compileResult = null; + compileResultNegative = null; } } diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/matchstmt/MatchStatementOnFailTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/matchstmt/MatchStatementOnFailTest.java index 6d7d8717e1bd..080a4d748a6c 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/matchstmt/MatchStatementOnFailTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/matchstmt/MatchStatementOnFailTest.java @@ -24,6 +24,7 @@ import org.testng.Assert; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; +import org.testng.annotations.DataProvider; import org.testng.annotations.Test; /** @@ -33,12 +34,16 @@ */ public class MatchStatementOnFailTest { - private CompileResult result, resultNegative; + private CompileResult result, resultNegative1, resultNegative2; @BeforeClass public void setup() { result = BCompileUtil.compile("test-src/statements/matchstmt/matchstmt_on_fail.bal"); - resultNegative = BCompileUtil.compile("test-src/statements/matchstmt/matchstmt_on_fail_negative.bal"); + resultNegative1 = + BCompileUtil.compile("test-src/statements/matchstmt/matchstmt_on_fail_negative.bal"); + resultNegative2 = + BCompileUtil.compile("test-src/statements/matchstmt/matchstmt_on_fail" + + "_negative_unreachable.bal"); } @Test(description = "Test basics of static pattern match statement with fail statement") @@ -71,29 +76,71 @@ public void testVarInMatchPatternWithinOnfail() { BRunUtil.invoke(result, "testVarInMatchPatternWithinOnfail", new Object[]{}); } - @Test(description = "Check not incompatible types and reachable statements.") + @Test(dataProvider = "onFailClauseWithErrorBPTestDataProvider") + public void testOnFailWithErrorBP(String funcName) { + BRunUtil.invoke(result, funcName); + } + + @DataProvider(name = "onFailClauseWithErrorBPTestDataProvider") + public Object[] onFailClauseWithErrorBPTestDataProvider() { + return new Object[]{ + "testSimpleOnFailWithErrorBP", + "testSimpleOnFailWithErrorBPWithVar", + "testOnFailWithErrorBPHavingUserDefinedTypeWithError", + "testOnFailWithErrorBPHavingUserDefinedTypeWithVar", + "testOnFailWithErrorBPHavingUserDefinedType", + "testOnFailWithErrorBPHavingUserDefinedTypeWithErrDetail1", + "testOnFailWithErrorBPHavingUserDefinedTypeWithErrDetail2", + "testOnFailWithErrorBPHavingUserDefinedTypeWithErrDetail3", + "testOnFailWithErrorBPHavingUserDefinedTypeWithErrDetail4", + "testOnFailWithErrorBPHavingAnonDetailRecord", + "testOnFailWithErrorBPHavingAnonDetailRecordWithVar", + "testOnFailWithErrorBPHavingAnonDetailRecordWithUnionType", + "testOnFailWithErrorBPWithErrorArgsHavingBP1", + "testOnFailWithErrorBPWithErrorArgsHavingBP2", + "testOnFailWithErrorBPWithErrorArgsHavingBP3", + "testOnFailWithErrorBPWithErrorArgsHavingBP4", + "testOnFailWithErrorBPWithErrorArgsHavingBP5", + "testMultiLevelOnFailWithErrorBP", + "testMultiLevelOnFailWithoutErrorInOneLevel" + }; + } + + @Test(description = "Check incompatible types.") public void testNegative1() { - int i = -1; - BAssertUtil.validateError(resultNegative, ++i, "unreachable code", 29, 14); - BAssertUtil.validateWarning(resultNegative, ++i, "unused variable 'e'", 31, 15); - BAssertUtil.validateWarning(resultNegative, ++i, "unused variable 'err'", 56, 14); - BAssertUtil.validateError(resultNegative, ++i, "incompatible error definition type: " + + int i = 0; + BAssertUtil.validateError(resultNegative1, i++, "incompatible error definition type: " + + "'ErrorTypeA' will not be matched to 'ErrorTypeB'", 30, 15); + BAssertUtil.validateError(resultNegative1, i++, "incompatible types: " + + "expected 'ErrorTypeA', found 'ErrorTypeB'", 30, 15); + BAssertUtil.validateError(resultNegative1, i++, "incompatible error definition type: " + "'ErrorTypeA' will not be matched to 'ErrorTypeB'", 59, 15); - BAssertUtil.validateWarning(resultNegative, ++i, "unused variable 'e'", 59, 15); - BAssertUtil.validateWarning(resultNegative, ++i, "unused variable 'err'", 85, 14); - BAssertUtil.validateError(resultNegative, ++i, "incompatible error definition type: " + - "'ErrorTypeA' will not be matched to 'ErrorTypeB'", 88, 15); - BAssertUtil.validateWarning(resultNegative, ++i, "unused variable 'e'", 88, 15); - BAssertUtil.validateError(resultNegative, ++i, "unreachable code", 90, 9); - BAssertUtil.validateError(resultNegative, ++i, "incompatible error definition type: " + - "'ErrorTypeA' will not be matched to 'ErrorTypeB'", 124, 15); - BAssertUtil.validateWarning(resultNegative, ++i, "unused variable 'e'", 124, 15); - Assert.assertEquals(resultNegative.getDiagnostics().length, i + 1); + BAssertUtil.validateError(resultNegative1, i++, "incompatible types: " + + "expected 'ErrorTypeA', found 'ErrorTypeB'", 59, 15); + BAssertUtil.validateError(resultNegative1, i++, "incompatible error definition type: " + + "'ErrorTypeA' will not be matched to 'ErrorTypeB'", 94, 15); + BAssertUtil.validateError(resultNegative1, i++, "incompatible types: " + + "expected '(ErrorTypeA|ErrorTypeB)', found 'ErrorTypeB'", 94, 15); + BAssertUtil.validateError(resultNegative1, i++, "invalid error variable; expecting an error " + + "type but found '(SampleComplexError|SampleError)' in type definition", 125, 15); + Assert.assertEquals(resultNegative1.getErrorCount(), i); + } + + @Test(description = "Check reachable statements.") + public void testNegative2() { + int i = -1; + BAssertUtil.validateError(resultNegative2, ++i, "unreachable code", 29, 14); + BAssertUtil.validateWarning(resultNegative2, ++i, "unused variable 'e'", 31, 15); + BAssertUtil.validateWarning(resultNegative2, ++i, "unused variable 'err'", 57, 14); + BAssertUtil.validateWarning(resultNegative2, ++i, "unused variable 'e'", 60, 15); + BAssertUtil.validateError(resultNegative2, ++i, "unreachable code", 62, 9); + Assert.assertEquals(resultNegative2.getDiagnostics().length, i + 1); } @AfterClass public void tearDown() { result = null; - resultNegative = null; + resultNegative1 = null; + resultNegative2 = null; } } diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/onfail/OnFailClauseTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/onfail/OnFailClauseTest.java index c5a389b1b910..dfed4e304043 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/onfail/OnFailClauseTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/onfail/OnFailClauseTest.java @@ -51,8 +51,60 @@ public void testOnFailClause() { public void testOnFailClauseNegativeCaseV1() { CompileResult negativeResult = BCompileUtil.compile( "test-src/statements/onfail/on-fail-clause-negative.bal"); - Assert.assertEquals(negativeResult.getErrorCount(), 1); - BAssertUtil.validateError(negativeResult, 0, "undefined symbol 'i'", 22, 55); + int i = 0; + BAssertUtil.validateError(negativeResult, i++, "undefined symbol 'i'", 22, 55); + BAssertUtil.validateError(negativeResult, i++, "incompatible error definition type: " + + "'SampleError' will not be matched to 'error'", 49, 15); + BAssertUtil.validateError(negativeResult, i++, "incompatible types: expected 'SampleError', " + + "found 'error'", 49, 15); + BAssertUtil.validateError(negativeResult, i++, "incompatible error definition type: " + + "'SampleError' will not be matched to 'SampleComplexError'", 56, 15); + BAssertUtil.validateError(negativeResult, i++, "incompatible types: expected 'SampleError', " + + "found 'SampleComplexError'", 56, 15); + BAssertUtil.validateError(negativeResult, i++, "incompatible error definition type: " + + "'SampleError' will not be matched to 'int'", 63, 15); + BAssertUtil.validateError(negativeResult, i++, "incompatible types: expected 'SampleError', " + + "found 'int'", 63, 15); + BAssertUtil.validateError(negativeResult, i++, "invalid error variable; expecting an error " + + "type but found 'int' in type definition", 63, 15); + BAssertUtil.validateError(negativeResult, i++, "invalid error variable; expecting an error " + + "type but found 'int' in type definition", 63, 15); + BAssertUtil.validateError(negativeResult, i++, "incompatible error definition type: " + + "'error' will not be matched to " + + "'error'", 71, 15); + BAssertUtil.validateError(negativeResult, i++, "incompatible types: expected 'error', found 'error'", 71, 15); + BAssertUtil.validateError(negativeResult, i++, "incompatible error definition type: 'error' " + + "will not be matched to 'anydata'", 78, 15); + BAssertUtil.validateError(negativeResult, i++, "incompatible types: expected 'error', " + + "found 'anydata'", 78, 15); + BAssertUtil.validateError(negativeResult, i++, "invalid error variable; expecting an error " + + "type but found 'anydata' in type definition", 78, 15); + BAssertUtil.validateError(negativeResult, i++, "invalid error variable; expecting an error " + + "type but found 'anydata' in type definition", 78, 15); + BAssertUtil.validateError(negativeResult, i++, "incompatible error definition type: 'error' will" + + " not be matched to '[error]'", 85, 15); + BAssertUtil.validateError(negativeResult, i++, "incompatible types: expected 'error', " + + "found '[error]'", 85, 15); + BAssertUtil.validateError(negativeResult, i++, "invalid binding pattern in 'on fail' clause: " + + "only a capture binding pattern or an error binding pattern is allowed", 85, 15); + BAssertUtil.validateError(negativeResult, i++, "invalid error variable; expecting an error " + + "type but found '[error]' in type definition", 85, 15); + BAssertUtil.validateError(negativeResult, i++, "invalid binding pattern in 'on fail' clause: " + + "only a capture binding pattern or an error binding pattern is allowed", 92, 15); + BAssertUtil.validateError(negativeResult, i++, "invalid list binding pattern: attempted " + + "to infer a list type, but found 'error'", 92, 15); + BAssertUtil.validateError(negativeResult, i++, "a wildcard binding pattern can be used only " + + "with a value that belong to type 'any'", 99, 15); + BAssertUtil.validateError(negativeResult, i++, "invalid binding pattern in 'on fail' clause: " + + "only a capture binding pattern or an error binding pattern is allowed", 106, 15); + BAssertUtil.validateError(negativeResult, i++, "invalid record binding pattern " + + "with type 'error'", 106, 15); + BAssertUtil.validateError(negativeResult, i++, "unknown error detail arg 'cause' passed to " + + "closed error detail type 'SampleComplexErrorData'", 114, 66); + BAssertUtil.validateError(negativeResult, i++, "invalid error variable; expecting an error " + + "type but found '(SampleComplexError|SampleError)' in type definition", 117, 15); + Assert.assertEquals(negativeResult.getErrorCount(), i); } @Test(description = "Test on-fail clause negative cases - v2") diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/retrystmt/RetryStmtWithOnFailTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/retrystmt/RetryStmtWithOnFailTest.java index a48f0b796c95..80af1463707d 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/retrystmt/RetryStmtWithOnFailTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/retrystmt/RetryStmtWithOnFailTest.java @@ -24,6 +24,7 @@ import org.testng.Assert; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; +import org.testng.annotations.DataProvider; import org.testng.annotations.Test; /** @@ -31,12 +32,14 @@ */ public class RetryStmtWithOnFailTest { - private CompileResult programFile, negativeFile; + private CompileResult programFile, negativeFile1, negativeFile2; @BeforeClass public void setup() { programFile = BCompileUtil.compile("test-src/statements/retrystmt/retry_stmt_with_on_fail.bal"); - negativeFile = BCompileUtil.compile("test-src/statements/retrystmt/retry_on_fail_negative.bal"); + negativeFile1 = BCompileUtil.compile("test-src/statements/retrystmt/retry_on_fail_negative.bal"); + negativeFile2 = BCompileUtil.compile("test-src/statements/retrystmt/retry_on_fail_negative_unreachable.bal"); + } @Test @@ -45,28 +48,69 @@ public void testRetryStatement() { BRunUtil.invoke(programFile, "testRetryStatement", params); } - @Test(description = "Check not incompatible types and reachable statements.") + @Test(dataProvider = "onFailClauseWithErrorBPTestDataProvider") + public void testOnFailWithErrorBP(String funcName) { + BRunUtil.invoke(programFile, funcName); + } + + @DataProvider(name = "onFailClauseWithErrorBPTestDataProvider") + public Object[] onFailClauseWithErrorBPTestDataProvider() { + return new Object[]{ + "testSimpleOnFailWithErrorBP", + "testSimpleOnFailWithErrorBPWithVar", + "testOnFailWithErrorBPHavingUserDefinedTypeWithError", + "testOnFailWithErrorBPHavingUserDefinedTypeWithVar", + "testOnFailWithErrorBPHavingUserDefinedType", + "testOnFailWithErrorBPHavingUserDefinedTypeWithErrDetail1", + "testOnFailWithErrorBPHavingUserDefinedTypeWithErrDetail2", + "testOnFailWithErrorBPHavingUserDefinedTypeWithErrDetail3", + "testOnFailWithErrorBPHavingUserDefinedTypeWithErrDetail4", + "testOnFailWithErrorBPHavingAnonDetailRecord", + "testOnFailWithErrorBPHavingAnonDetailRecordWithVar", + "testOnFailWithErrorBPHavingAnonDetailRecordWithUnionType", + "testOnFailWithErrorBPWithErrorArgsHavingBP1", + "testOnFailWithErrorBPWithErrorArgsHavingBP2", + "testOnFailWithErrorBPWithErrorArgsHavingBP3", + "testOnFailWithErrorBPWithErrorArgsHavingBP4", + "testOnFailWithErrorBPWithErrorArgsHavingBP5", + "testMultiLevelOnFailWithErrorBP", + "testMultiLevelOnFailWithoutErrorInOneLevel" + }; + } + + @Test(description = "Check not incompatible types.") public void testNegative1() { int index = 0; - BAssertUtil.validateError(negativeFile, index++, "unreachable code", 20, 12); - BAssertUtil.validateWarning(negativeFile, index++, "unused variable 'e'", 21, 16); - BAssertUtil.validateError(negativeFile, index++, "incompatible error definition type: " + - "'ErrorTypeA' will not be matched to 'ErrorTypeB'", 32, 14); - BAssertUtil.validateWarning(negativeFile, index++, "unused variable 'e'", 32, 14); - BAssertUtil.validateWarning(negativeFile, index++, "unused variable 'e'", 45, 12); - BAssertUtil.validateWarning(negativeFile, index++, "unused variable 'e'", 59, 12); - BAssertUtil.validateError(negativeFile, index++, "unreachable code", 62, 7); - BAssertUtil.validateWarning(negativeFile, index++, "unused variable 'e1'", 78, 12); - BAssertUtil.validateWarning(negativeFile, index++, "unused variable 'resA'", 97, 6); - BAssertUtil.validateWarning(negativeFile, index++, "unused variable 'resB'", 98, 6); - BAssertUtil.validateError(negativeFile, index++, "incompatible error definition type: " + - "'ErrorTypeB' will not be matched to 'ErrorTypeA'", 100, 12); - Assert.assertEquals(negativeFile.getDiagnostics().length, index); + BAssertUtil.validateError(negativeFile1, index++, "incompatible error definition type: " + + "'ErrorTypeA' will not be matched to 'ErrorTypeB'", 14, 14); + BAssertUtil.validateError(negativeFile1, index++, "incompatible types: " + + "expected 'ErrorTypeA', found 'ErrorTypeB'", 14, 14); + BAssertUtil.validateError(negativeFile1, index++, "incompatible error definition type: " + + "'ErrorTypeB' will not be matched to 'ErrorTypeA'", 36, 12); + BAssertUtil.validateError(negativeFile1, index++, "incompatible types: " + + "expected '(ErrorTypeA|ErrorTypeB)', found 'ErrorTypeA'", 36, 12); + BAssertUtil.validateError(negativeFile1, index++, "invalid error variable; " + + "expecting an error type but found '(SampleComplexError|SampleError)' in type definition", 66, 15); + Assert.assertEquals(negativeFile1.getDiagnostics().length, index); + } + + @Test(description = "Check unreachable statements.") + public void testNegative2() { + int index = 0; + BAssertUtil.validateError(negativeFile2, index++, "unreachable code", 20, 12); + BAssertUtil.validateWarning(negativeFile2, index++, "unused variable 'e'", 21, 16); + BAssertUtil.validateWarning(negativeFile2, index++, "unused variable 'e'", 33, 12); + BAssertUtil.validateError(negativeFile2, index++, "unreachable code", 36, 7); + BAssertUtil.validateWarning(negativeFile2, index++, "unused variable 'e'", 48, 12); + BAssertUtil.validateWarning(negativeFile2, index++, "unused variable 'e1'", 66, 12); + BAssertUtil.validateWarning(negativeFile2, index++, "unused variable 'resB'", 81, 6); + Assert.assertEquals(negativeFile2.getDiagnostics().length, index); } @AfterClass public void tearDown() { programFile = null; - negativeFile = null; + negativeFile1 = null; + negativeFile2 = null; } } diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/whilestatement/WhileStmtTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/whilestatement/WhileStmtTest.java index 85482694d268..4d158ecdb502 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/whilestatement/WhileStmtTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/whilestatement/WhileStmtTest.java @@ -25,6 +25,7 @@ import org.ballerinalang.test.CompileResult; import org.testng.Assert; import org.testng.annotations.BeforeClass; +import org.testng.annotations.DataProvider; import org.testng.annotations.Test; /** @@ -38,6 +39,7 @@ public class WhileStmtTest { private CompileResult negativeCompileResult; private CompileResult onfailCompileResult; private CompileResult onfailNegativeCompileResult; + private CompileResult onfailNegativeUnreachableCompileResult; @BeforeClass public void setup() { @@ -46,6 +48,8 @@ public void setup() { onfailCompileResult = BCompileUtil.compile("test-src/statements/whilestatement/while-stmt-on-fail.bal"); onfailNegativeCompileResult = BCompileUtil.compile( "test-src/statements/whilestatement/while-stmt-on-fail-negative.bal"); + onfailNegativeUnreachableCompileResult = BCompileUtil.compile( + "test-src/statements/whilestatement/while-stmt-on-fail-negative-reachability.bal"); } @Test(description = "Test while loop with a condition which evaluates to true") @@ -242,25 +246,46 @@ public void testNestedWhileStmtLoopTerminationWithFail() { Assert.assertEquals(actual, expected); } - @Test(description = "Check not incompatible types and reachable statements.") + @Test(description = "Check incompatible types.") public void testNegative1() { int index = 0; - BAssertUtil.validateError(onfailNegativeCompileResult, index++, "unreachable code", 17, 6); - BAssertUtil.validateWarning(onfailNegativeCompileResult, index++, "unused variable 'e'", 19, 12); BAssertUtil.validateError(onfailNegativeCompileResult, index++, "incompatible error definition type: " + - "'ErrorTypeA' will not be matched to 'ErrorTypeB'", 34, 12); - BAssertUtil.validateWarning(onfailNegativeCompileResult, index++, "unused variable 'e'", 34, 12); - BAssertUtil.validateWarning(onfailNegativeCompileResult, index++, "unused variable 'e'", 49, 12); - BAssertUtil.validateWarning(onfailNegativeCompileResult, index++, "unused variable 'e'", 65, 12); - BAssertUtil.validateError(onfailNegativeCompileResult, index++, "unreachable code", 68, 7); - BAssertUtil.validateError(onfailNegativeCompileResult, index++, "this function must return a result", 83, 1); + "'ErrorTypeA' will not be matched to 'ErrorTypeB'", 17, 12); + BAssertUtil.validateError(onfailNegativeCompileResult, index++, + "incompatible types: expected 'ErrorTypeA', found 'ErrorTypeB'", 17, 12); BAssertUtil.validateError(onfailNegativeCompileResult, index++, "incompatible error definition type: " + - "'ErrorTypeB' will not be matched to 'ErrorTypeA'", 102, 12); - BAssertUtil.validateError(onfailNegativeCompileResult, index++, "unreachable code", 116, 9); - BAssertUtil.validateError(onfailNegativeCompileResult, index++, "unreachable code", 118, 5); + "'ErrorTypeB' will not be matched to 'ErrorTypeA'", 41, 12); + BAssertUtil.validateError(onfailNegativeCompileResult, index++, + "incompatible types: expected '(ErrorTypeA|ErrorTypeB)', found 'ErrorTypeA'", 41, 12); + BAssertUtil.validateError(onfailNegativeCompileResult, index++, "invalid error variable; " + + "expecting an error type but found '(SampleComplexError|SampleError)' in type definition", 72, 15); Assert.assertEquals(onfailNegativeCompileResult.getDiagnostics().length, index); } + @Test(description = "Check unreachable statements.") + public void testNegative2() { + int index = 0; + BAssertUtil.validateError(onfailNegativeUnreachableCompileResult, index++, + "unreachable code", 17, 6); + BAssertUtil.validateWarning(onfailNegativeUnreachableCompileResult, index++, + "unused variable 'e'", 19, 12); + BAssertUtil.validateWarning(onfailNegativeUnreachableCompileResult, index++, + "unused variable 'e'", 34, 12); + BAssertUtil.validateWarning(onfailNegativeUnreachableCompileResult, index++, + "unused variable 'e'", 49, 12); + BAssertUtil.validateWarning(onfailNegativeUnreachableCompileResult, index++, + "unused variable 'e'", 65, 12); + BAssertUtil.validateError(onfailNegativeUnreachableCompileResult, index++, + "unreachable code", 68, 7); + BAssertUtil.validateError(onfailNegativeUnreachableCompileResult, index++, + "this function must return a result", 83, 1); + BAssertUtil.validateError(onfailNegativeUnreachableCompileResult, index++, + "unreachable code", 111, 9); + BAssertUtil.validateError(onfailNegativeUnreachableCompileResult, index++, + "unreachable code", 113, 5); + Assert.assertEquals(onfailNegativeUnreachableCompileResult.getDiagnostics().length, index); + } + @Test(description = "Test type narrowing for while statement") public void testWhileStmtTypeNarrowing() { CompileResult compileResult = @@ -297,6 +322,38 @@ public void testWhileStmtTypeNarrowing() { Assert.assertEquals(compileResult.getDiagnostics().length, index); } + @Test(dataProvider = "onFailClauseWithErrorBPTestDataProvider") + public void testOnFailWithErrorBP(String funcName) { + BRunUtil.invoke(onfailCompileResult, funcName); + } + + @DataProvider(name = "onFailClauseWithErrorBPTestDataProvider") + public Object[] onFailClauseWithErrorBPTestDataProvider() { + return new Object[]{ + "testSimpleOnFailWithErrorBP", + "testSimpleOnFailWithErrorBPWithVar", + "testOnFailWithErrorBPHavingUserDefinedTypeWithError", + "testOnFailWithErrorBPHavingUserDefinedTypeWithVar", + "testOnFailWithErrorBPHavingUserDefinedType", + "testOnFailWithErrorBPHavingUserDefinedTypeWithErrDetail1", + "testOnFailWithErrorBPHavingUserDefinedTypeWithErrDetail2", + "testOnFailWithErrorBPHavingUserDefinedTypeWithErrDetail3", + "testOnFailWithErrorBPHavingUserDefinedTypeWithErrDetail4", + "testOnFailWithErrorBPHavingAnonDetailRecord", + "testOnFailWithErrorBPHavingAnonDetailRecordWithVar", + "testOnFailWithErrorBPHavingAnonDetailRecordWithUnionType", + "testOnFailWithErrorBPWithErrorArgsHavingBP1", + "testOnFailWithErrorBPWithErrorArgsHavingBP2", + "testOnFailWithErrorBPWithErrorArgsHavingBP3", + "testOnFailWithErrorBPWithErrorArgsHavingBP4", + "testOnFailWithErrorBPWithErrorArgsHavingBP5", + "testNestedOnFailWithErrorBP", + "testNestedOnFailWithErrorBPWithErrorArgsHavingBP", + "testMultiLevelOnFailWithErrorBP", + "testMultiLevelOnFailWithoutErrorInOneLevel" + }; + } + @Test(description = "Test type narrowing for while statement with no errors") public void testWhileStmtTypeNarrowPositive() { CompileResult compileResult = diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/lock/lock-on-fail-negative.bal b/tests/jballerina-unit-test/src/test/resources/test-src/lock/lock-on-fail-negative.bal new file mode 100644 index 000000000000..ab589b6939f9 --- /dev/null +++ b/tests/jballerina-unit-test/src/test/resources/test-src/lock/lock-on-fail-negative.bal @@ -0,0 +1,41 @@ +// Copyright (c) 2023 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. +// +// WSO2 Inc. licenses this file to you under the Apache License, +// Version 2.0 (the "License"); you may not use this file except +// in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +type SampleErrorData record {| + int code; + string reason; +|}; + +type SampleError error; + +type SampleComplexErrorData record {| + int code; + int[2] pos; + record {string moreInfo;} infoDetails; +|}; + +type SampleComplexError error; + +function testOnFailWithMultipleErrors() { + boolean isPositiveState = false; + lock { + if isPositiveState { + fail error SampleComplexError("Transaction Failure", code = 20, pos = [30, 45], infoDetails = {moreInfo: "deadlock condition"}); + } + fail error SampleError("Transaction Failure", code = 50, reason = "deadlock condition"); + } on fail var error(msg) { + } +} diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/lock/lock-on-fail.bal b/tests/jballerina-unit-test/src/test/resources/test-src/lock/lock-on-fail.bal index c894d20f005c..6aee2677d874 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/lock/lock-on-fail.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/lock/lock-on-fail.bal @@ -89,6 +89,357 @@ function getError() returns int|error { return err; } +type SampleErrorData record {| + int code; + string reason; +|}; + +type SampleError error; + +string testMessage = ""; +int testErrorCode = 0; +string testErrorReason = ""; + +function testSimpleOnFailWithErrorBP() { + lock { + lockWithinLockInt1 = 99; + fail error("error!"); + } on fail error error(msg) { + testMessage = msg; + } + assertEquality(testMessage, "error!"); +} + +function testSimpleOnFailWithErrorBPWithVar() { + lock { + lockWithinLockInt1 = 99; + fail error("error!"); + } on fail var error(msg) { + testMessage = msg; + } + assertEquality(testMessage, "error!"); +} + +function testOnFailWithErrorBPHavingUserDefinedTypeWithError() { + lock { + lockWithinLockInt1 = 99; + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } on fail error error(msg, code = errCode, reason = errReason) { + testErrorCode = errCode; + testErrorReason = errReason; + testMessage = msg; + } + assertEquality(testMessage, "error!"); + assertEquality(testErrorCode, 20); + assertEquality(testErrorReason, "deadlock condition"); + assertEquality(testErrorCode is int, true); + assertEquality(testErrorReason is string, true); +} + +function testOnFailWithErrorBPHavingUserDefinedTypeWithVar() { + lock { + lockWithinLockInt1 = 99; + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } on fail var error(msg, code = errCode, reason = errReason) { + testErrorCode = errCode; + testErrorReason = errReason; + testMessage = msg; + } + assertEquality(testMessage, "error!"); + assertEquality(testErrorCode, 20); + assertEquality(testErrorReason, "deadlock condition"); + assertEquality(testErrorCode is int, true); + assertEquality(testErrorReason is string, true); +} + +function testOnFailWithErrorBPHavingUserDefinedType() { + lock { + lockWithinLockInt1 = 99; + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } on fail SampleError error(msg, code = errCode, reason = errReason) { + testErrorCode = errCode; + testErrorReason = errReason; + testMessage = msg; + } + assertEquality(testMessage, "error!"); + assertEquality(testErrorCode, 20); + assertEquality(testErrorReason, "deadlock condition"); + assertEquality(testErrorCode is int, true); + assertEquality(testErrorReason is string, true); +} + +function testOnFailWithErrorBPHavingUserDefinedTypeWithErrDetail1() { + lock { + lockWithinLockInt1 = 99; + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } on fail error error(msg, code = errCode, reason = errReason) { + testErrorCode = errCode; + testErrorReason = errReason; + testMessage = msg; + } + assertEquality(testMessage, "error!"); + assertEquality(testErrorCode, 20); + assertEquality(testErrorReason, "deadlock condition"); + assertEquality(testErrorCode is int, true); + assertEquality(testErrorReason is string, true); +} + +function testOnFailWithErrorBPHavingUserDefinedTypeWithErrDetail2() { + lock { + lockWithinLockInt1 = 99; + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } on fail error error(code = errCode) { + testErrorCode = errCode; + } + assertEquality(testErrorCode, 20); + assertEquality(testErrorCode is int, true); +} + +function testOnFailWithErrorBPHavingUserDefinedTypeWithErrDetail3() { + lock { + lockWithinLockInt1 = 99; + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } on fail error error(code = errCode, reason = errReason) { + testErrorCode = errCode; + testErrorReason = errReason; + } + assertEquality(testErrorCode, 20); + assertEquality(testErrorReason, "deadlock condition"); + assertEquality(testErrorCode is int, true); + assertEquality(testErrorReason is string, true); +} + +function testOnFailWithErrorBPHavingUserDefinedTypeWithErrDetail4() { + lock { + lockWithinLockInt1 = 99; + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } on fail error error(code = errCode) { + testErrorCode = errCode; + } + assertEquality(testErrorCode, 20); + assertEquality(testErrorCode is int, true); +} + +function testOnFailWithErrorBPHavingAnonDetailRecord() { + lock { + lockWithinLockInt1 = 99; + error errVar = error("error", code = 34); + fail errVar; + } on fail error error(code = errCode) { + testErrorCode = errCode; + } + assertEquality(testErrorCode, 34); + assertEquality(testErrorCode is int, true); +} + +function testOnFailWithErrorBPHavingAnonDetailRecordWithVar() { + lock { + lockWithinLockInt1 = 99; + error errVar = error("error", code = 34); + fail errVar; + } on fail var error(msg, code = errCode) { + testErrorCode = errCode; + testErrorReason = msg; + } + assertEquality(testErrorCode, 34); + assertEquality(testErrorCode is int, true); + assertEquality(testErrorReason is string, true); + assertEquality(testErrorReason, "error"); +} + +function testOnFailWithErrorBPHavingAnonDetailRecordWithUnionType() { + lock { + lockWithinLockInt1 = 99; + error errVar = error("error", code = 34); + fail errVar; + } on fail error error(code = errCode) { + testErrorCode = errCode; + } + assertEquality(testErrorCode, 34); + assertEquality(testErrorCode is int, true); +} + +type SampleComplexErrorData record {| + error cause; + int code; + int[2] pos; + record {string moreInfo;} infoDetails; +|}; + +type SampleComplexError error; + +int testErrorPosRow = 0; +int testErrorPosCol = 0; +string testErrorMoreInfo = ""; + + +function testOnFailWithErrorBPWithErrorArgsHavingBP1() { + string causeMsg; + lock { + lockWithinLockInt1 = 99; + fail error SampleComplexError("Transaction Failure", cause = error("Database Error"), code = 20, pos = [30, 45], infoDetails = {moreInfo: "deadlock condition"}); + } on fail SampleComplexError error(_, cause = errCause, code = errCode, pos = errorPos, infoDetails = errInfo) { + testErrorCode = errCode; + testErrorPosRow = errorPos[0]; + testErrorPosCol = errorPos[1]; + testErrorMoreInfo = errInfo.moreInfo; + causeMsg = errCause.message(); + } + assertEquality(testErrorPosRow, 30); + assertEquality(testErrorPosRow is int, true); + assertEquality(testErrorPosCol, 45); + assertEquality(testErrorPosCol is int, true); + assertEquality(testErrorMoreInfo, "deadlock condition"); + assertEquality(testErrorMoreInfo is string, true); + assertEquality(testErrorCode, 20); + assertEquality(testErrorCode is int, true); + assertEquality(causeMsg, "Database Error"); + assertEquality(causeMsg is string, true); +} + +function testOnFailWithErrorBPWithErrorArgsHavingBP2() { + lock { + lockWithinLockInt1 = 99; + fail error SampleComplexError("Transaction Failure", cause = error("Database Error"), code = 20, pos = [30, 45], infoDetails = {moreInfo: "deadlock condition"}); + } on fail SampleComplexError error(message, cause = error(msg), code = errCode, pos = errorPos, infoDetails = errInfo) { + testErrorCode = errCode; + testErrorPosRow = errorPos[0]; + testErrorPosCol = errorPos[1]; + testErrorMoreInfo = errInfo.moreInfo; + testMessage = msg; + } + assertEquality(testErrorPosRow, 30); + assertEquality(testErrorPosRow is int, true); + assertEquality(testErrorPosCol, 45); + assertEquality(testErrorPosCol is int, true); + assertEquality(testErrorMoreInfo, "deadlock condition"); + assertEquality(testErrorMoreInfo is string, true); + assertEquality(testErrorCode, 20); + assertEquality(testErrorCode is int, true); + assertEquality(testMessage, "Database Error"); + assertEquality(testMessage is string, true); +} + +function testOnFailWithErrorBPWithErrorArgsHavingBP3() { + lock { + lockWithinLockInt1 = 99; + fail error SampleComplexError("Transaction Failure", cause = error("Database Error"), code = 20, pos = [30, 45], infoDetails = {moreInfo: "deadlock condition"}); + } on fail SampleComplexError error(message, cause = error(msg), code = errCode, pos = [row, col], infoDetails = errInfo) { + testErrorCode = errCode; + testErrorPosRow = row; + testErrorPosCol = col; + testErrorMoreInfo = errInfo.moreInfo; + testMessage = msg; + } + assertEquality(testErrorPosRow, 30); + assertEquality(testErrorPosRow is int, true); + assertEquality(testErrorPosCol, 45); + assertEquality(testErrorPosCol is int, true); + assertEquality(testErrorMoreInfo, "deadlock condition"); + assertEquality(testErrorMoreInfo is string, true); + assertEquality(testErrorCode, 20); + assertEquality(testErrorCode is int, true); + assertEquality(testMessage, "Database Error"); + assertEquality(testMessage is string, true); +} + +function testOnFailWithErrorBPWithErrorArgsHavingBP4() { + lock { + lockWithinLockInt1 = 99; + fail error SampleComplexError("Transaction Failure", cause = error("Database Error"), code = 20, pos = [30, 45], infoDetails = {moreInfo: "deadlock condition"}); + } on fail SampleComplexError error(_, cause = error(msg), code = errCode, pos = [row, col], infoDetails = {moreInfo: errInfo}) { + testErrorCode = errCode; + testErrorPosRow = row; + testErrorPosCol = col; + testErrorMoreInfo = errInfo; + testMessage = msg; + } + assertEquality(testErrorPosRow, 30); + assertEquality(testErrorPosRow is int, true); + assertEquality(testErrorPosCol, 45); + assertEquality(testErrorPosCol is int, true); + assertEquality(testErrorMoreInfo, "deadlock condition"); + assertEquality(testErrorMoreInfo is string, true); + assertEquality(testErrorCode, 20); + assertEquality(testErrorCode is int, true); + assertEquality(testMessage, "Database Error"); + assertEquality(testMessage is string, true); +} + +function testOnFailWithErrorBPWithErrorArgsHavingBP5() { + lock { + lockWithinLockInt1 = 99; + fail error SampleComplexError("Transaction Failure", cause = error("Database Error"), code = 20, pos = [30, 45], infoDetails = {moreInfo: "deadlock condition"}); + } on fail var error(_, cause = error(msg), code = errCode, pos = [row, col], infoDetails = {moreInfo: errInfo}) { + testErrorCode = errCode; + testErrorPosRow = row; + testErrorPosCol = col; + testErrorMoreInfo = errInfo; + testMessage = msg; + } + assertEquality(testErrorPosRow, 30); + assertEquality(testErrorPosRow is int, true); + assertEquality(testErrorPosCol, 45); + assertEquality(testErrorPosCol is int, true); + assertEquality(testErrorMoreInfo, "deadlock condition"); + assertEquality(testErrorMoreInfo is string, true); + assertEquality(testErrorCode, 20); + assertEquality(testErrorCode is int, true); + assertEquality(testMessage, "Database Error"); + assertEquality(testMessage is string, true); +} + +function testMultiLevelOnFailWithErrorBP() { + int i = 2; + string str = ""; + + lock { + lock { + str += " -> Iteration " + i.toString() + ", "; + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } on fail var error(msg1, code = errCode1, reason = errReason1) { + str += " -> On Fail #" + i.toString(); + testMessage = msg1; + testErrorCode = errCode1; + testErrorReason = errReason1; + } + i = i + 1; + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } on fail SampleError error(msg2, code = errCode2, reason = errReason2) { + str += " -> On Fail Final"; + } + + assertEquality(" -> Iteration 2, -> On Fail #2 -> On Fail Final", str); + assertEquality(testErrorCode, 20); + assertEquality(testErrorReason, "deadlock condition"); + assertEquality(testMessage, "error!"); +} + +function testMultiLevelOnFailWithoutErrorInOneLevel() { + int i = 2; + string str = ""; + + lock { + lock { + str += " -> Iteration " + i.toString() + ", "; + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } on fail var error(msg1, code = errCode1, reason = errReason1) { + str += " -> On Fail #" + i.toString(); + testMessage = msg1; + testErrorCode = errCode1; + testErrorReason = errReason1; + } + i = i + 1; + } on fail SampleError error(msg2, code = errCode2, reason = errReason2) { + str += " -> On Fail Final"; + } + + assertEquality(" -> Iteration 2, -> On Fail #2", str); + assertEquality(testErrorCode, 20); + assertEquality(testErrorReason, "deadlock condition"); + assertEquality(testMessage, "error!"); +} + function assertEquality(anydata expected, anydata actual) { if expected == actual { return; diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/statements/matchstmt/matchstmt_on_fail.bal b/tests/jballerina-unit-test/src/test/resources/test-src/statements/matchstmt/matchstmt_on_fail.bal index 1d2410d83ede..9efddb0c737f 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/statements/matchstmt/matchstmt_on_fail.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/statements/matchstmt/matchstmt_on_fail.bal @@ -361,6 +361,437 @@ function getErrorDetailNestedMatch([int, string] dataEntry) returns string { return str; } +type SampleErrorData record {| + int code; + string reason; +|}; + +type SampleError error; + +string testMessage = ""; +int testErrorCode = 0; +string testErrorReason = ""; +string matchString = "fail"; +string matchRes = ""; + +function testSimpleOnFailWithErrorBP() { + match matchString { + 12 => { + matchRes = "12"; + } + "fail" => { + fail error("error!"); + } + } on fail error error(msg) { + testMessage = msg; + } + assertEquals(testMessage, "error!"); +} + +function testSimpleOnFailWithErrorBPWithVar() { + match matchString { + 12 => { + matchRes = "12"; + } + "fail" => { + fail error("error!"); + } + } on fail var error(msg) { + testMessage = msg; + } + assertEquals(testMessage, "error!"); +} + +function testOnFailWithErrorBPHavingUserDefinedTypeWithError() { + match matchString { + 12 => { + matchRes = "12"; + } + "fail" => { + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } + } on fail error error(msg, code = errCode, reason = errReason) { + testErrorCode = errCode; + testErrorReason = errReason; + testMessage = msg; + } + assertEquals(testMessage, "error!"); + assertEquals(testErrorCode, 20); + assertEquals(testErrorReason, "deadlock condition"); + assertEquals(testErrorCode is int, true); + assertEquals(testErrorReason is string, true); +} + +function testOnFailWithErrorBPHavingUserDefinedTypeWithVar() { + match matchString { + 12 => { + matchRes = "12"; + } + "fail" => { + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } + } on fail var error(msg, code = errCode, reason = errReason) { + testErrorCode = errCode; + testErrorReason = errReason; + testMessage = msg; + } + assertEquals(testMessage, "error!"); + assertEquals(testErrorCode, 20); + assertEquals(testErrorReason, "deadlock condition"); + assertEquals(testErrorCode is int, true); + assertEquals(testErrorReason is string, true); +} + +function testOnFailWithErrorBPHavingUserDefinedType() { + match matchString { + 12 => { + matchRes = "12"; + } + "fail" => { + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } + } on fail SampleError error(msg, code = errCode, reason = errReason) { + testErrorCode = errCode; + testErrorReason = errReason; + testMessage = msg; + } + assertEquals(testMessage, "error!"); + assertEquals(testErrorCode, 20); + assertEquals(testErrorReason, "deadlock condition"); + assertEquals(testErrorCode is int, true); + assertEquals(testErrorReason is string, true); +} + +function testOnFailWithErrorBPHavingUserDefinedTypeWithErrDetail1() { + match matchString { + 12 => { + matchRes = "12"; + } + "fail" => { + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } + } on fail error error(msg, code = errCode, reason = errReason) { + testErrorCode = errCode; + testErrorReason = errReason; + testMessage = msg; + } + assertEquals(testMessage, "error!"); + assertEquals(testErrorCode, 20); + assertEquals(testErrorReason, "deadlock condition"); + assertEquals(testErrorCode is int, true); + assertEquals(testErrorReason is string, true); +} + +function testOnFailWithErrorBPHavingUserDefinedTypeWithErrDetail2() { + match matchString { + 12 => { + matchRes = "12"; + } + "fail" => { + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } + } on fail error error(code = errCode) { + testErrorCode = errCode; + } + assertEquals(testErrorCode, 20); + assertEquals(testErrorCode is int, true); +} + +function testOnFailWithErrorBPHavingUserDefinedTypeWithErrDetail3() { + match matchString { + 12 => { + matchRes = "12"; + } + "fail" => { + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } + } on fail error error(code = errCode, reason = errReason) { + testErrorCode = errCode; + testErrorReason = errReason; + } + assertEquals(testErrorCode, 20); + assertEquals(testErrorReason, "deadlock condition"); + assertEquals(testErrorCode is int, true); + assertEquals(testErrorReason is string, true); +} + +function testOnFailWithErrorBPHavingUserDefinedTypeWithErrDetail4() { + match matchString { + 12 => { + matchRes = "12"; + } + "fail" => { + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } + } on fail error error(code = errCode) { + testErrorCode = errCode; + } + assertEquals(testErrorCode, 20); + assertEquals(testErrorCode is int, true); +} + +function testOnFailWithErrorBPHavingAnonDetailRecord() { + match matchString { + 12 => { + matchRes = "12"; + } + "fail" => { + error errVar = error("error", code = 34); + fail errVar; + } + } on fail error error(code = errCode) { + testErrorCode = errCode; + } + assertEquals(testErrorCode, 34); + assertEquals(testErrorCode is int, true); +} + +function testOnFailWithErrorBPHavingAnonDetailRecordWithVar() { + match matchString { + 12 => { + matchRes = "12"; + } + "fail" => { + error errVar = error("error", code = 34); + fail errVar; + } + } on fail var error(msg, code = errCode) { + testErrorCode = errCode; + testErrorReason = msg; + } + assertEquals(testErrorCode, 34); + assertEquals(testErrorCode is int, true); + assertEquals(testErrorReason is string, true); + assertEquals(testErrorReason, "error"); +} + +function testOnFailWithErrorBPHavingAnonDetailRecordWithUnionType() { + match matchString { + 12 => { + matchRes = "12"; + } + "fail" => { + error errVar = error("error", code = 34); + fail errVar; + } + } on fail error error(code = errCode) { + testErrorCode = errCode; + } + assertEquals(testErrorCode, 34); + assertEquals(testErrorCode is int, true); +} + +type SampleComplexErrorData record {| + error cause; + int code; + int[2] pos; + record {string moreInfo;} infoDetails; +|}; + +type SampleComplexError error; + +int testErrorPosRow = 0; +int testErrorPosCol = 0; +string testErrorMoreInfo = ""; + + +function testOnFailWithErrorBPWithErrorArgsHavingBP1() { + string causeMsg; + match matchString { + 12 => { + matchRes = "12"; + } + "fail" => { + fail error SampleComplexError("Transaction Failure", cause = error("Database Error"), code = 20, pos = [30, 45], infoDetails = {moreInfo: "deadlock condition"}); + } + } on fail SampleComplexError error(_, cause = errCause, code = errCode, pos = errorPos, infoDetails = errInfo) { + testErrorCode = errCode; + testErrorPosRow = errorPos[0]; + testErrorPosCol = errorPos[1]; + testErrorMoreInfo = errInfo.moreInfo; + causeMsg = errCause.message(); + } + assertEquals(testErrorPosRow, 30); + assertEquals(testErrorPosRow is int, true); + assertEquals(testErrorPosCol, 45); + assertEquals(testErrorPosCol is int, true); + assertEquals(testErrorMoreInfo, "deadlock condition"); + assertEquals(testErrorMoreInfo is string, true); + assertEquals(testErrorCode, 20); + assertEquals(testErrorCode is int, true); + assertEquals(causeMsg, "Database Error"); + assertEquals(causeMsg is string, true); +} + +function testOnFailWithErrorBPWithErrorArgsHavingBP2() { + match matchString { + 12 => { + matchRes = "12"; + } + "fail" => { + fail error SampleComplexError("Transaction Failure", cause = error("Database Error"), code = 20, pos = [30, 45], infoDetails = {moreInfo: "deadlock condition"}); + } + } on fail SampleComplexError error(message, cause = error(msg), code = errCode, pos = errorPos, infoDetails = errInfo) { + testErrorCode = errCode; + testErrorPosRow = errorPos[0]; + testErrorPosCol = errorPos[1]; + testErrorMoreInfo = errInfo.moreInfo; + testMessage = msg; + } + assertEquals(testErrorPosRow, 30); + assertEquals(testErrorPosRow is int, true); + assertEquals(testErrorPosCol, 45); + assertEquals(testErrorPosCol is int, true); + assertEquals(testErrorMoreInfo, "deadlock condition"); + assertEquals(testErrorMoreInfo is string, true); + assertEquals(testErrorCode, 20); + assertEquals(testErrorCode is int, true); + assertEquals(testMessage, "Database Error"); + assertEquals(testMessage is string, true); +} + +function testOnFailWithErrorBPWithErrorArgsHavingBP3() { + match matchString { + 12 => { + matchRes = "12"; + } + "fail" => { + fail error SampleComplexError("Transaction Failure", cause = error("Database Error"), code = 20, pos = [30, 45], infoDetails = {moreInfo: "deadlock condition"}); + } + } on fail SampleComplexError error(message, cause = error(msg), code = errCode, pos = [row, col], infoDetails = errInfo) { + testErrorCode = errCode; + testErrorPosRow = row; + testErrorPosCol = col; + testErrorMoreInfo = errInfo.moreInfo; + testMessage = msg; + } + assertEquals(testErrorPosRow, 30); + assertEquals(testErrorPosRow is int, true); + assertEquals(testErrorPosCol, 45); + assertEquals(testErrorPosCol is int, true); + assertEquals(testErrorMoreInfo, "deadlock condition"); + assertEquals(testErrorMoreInfo is string, true); + assertEquals(testErrorCode, 20); + assertEquals(testErrorCode is int, true); + assertEquals(testMessage, "Database Error"); + assertEquals(testMessage is string, true); +} + +function testOnFailWithErrorBPWithErrorArgsHavingBP4() { + match matchString { + 12 => { + matchRes = "12"; + } + "fail" => { + fail error SampleComplexError("Transaction Failure", cause = error("Database Error"), code = 20, pos = [30, 45], infoDetails = {moreInfo: "deadlock condition"}); + } + } on fail SampleComplexError error(_, cause = error(msg), code = errCode, pos = [row, col], infoDetails = {moreInfo: errInfo}) { + testErrorCode = errCode; + testErrorPosRow = row; + testErrorPosCol = col; + testErrorMoreInfo = errInfo; + testMessage = msg; + } + assertEquals(testErrorPosRow, 30); + assertEquals(testErrorPosRow is int, true); + assertEquals(testErrorPosCol, 45); + assertEquals(testErrorPosCol is int, true); + assertEquals(testErrorMoreInfo, "deadlock condition"); + assertEquals(testErrorMoreInfo is string, true); + assertEquals(testErrorCode, 20); + assertEquals(testErrorCode is int, true); + assertEquals(testMessage, "Database Error"); + assertEquals(testMessage is string, true); +} + +function testOnFailWithErrorBPWithErrorArgsHavingBP5() { + match matchString { + 12 => { + matchRes = "12"; + } + "fail" => { + fail error SampleComplexError("Transaction Failure", cause = error("Database Error"), code = 20, pos = [30, 45], infoDetails = {moreInfo: "deadlock condition"}); + } + } on fail var error(_, cause = error(msg), code = errCode, pos = [row, col], infoDetails = {moreInfo: errInfo}) { + testErrorCode = errCode; + testErrorPosRow = row; + testErrorPosCol = col; + testErrorMoreInfo = errInfo; + testMessage = msg; + } + assertEquals(testErrorPosRow, 30); + assertEquals(testErrorPosRow is int, true); + assertEquals(testErrorPosCol, 45); + assertEquals(testErrorPosCol is int, true); + assertEquals(testErrorMoreInfo, "deadlock condition"); + assertEquals(testErrorMoreInfo is string, true); + assertEquals(testErrorCode, 20); + assertEquals(testErrorCode is int, true); + assertEquals(testMessage, "Database Error"); + assertEquals(testMessage is string, true); +} + +function testMultiLevelOnFailWithErrorBP() { + int i = 2; + string str = ""; + + while i <= 2 { + match matchString { + 12 => { + matchRes = "12"; + } + "fail" => { + str += " -> Iteration " + i.toString() + ", "; + fail error SampleError("error!", code = 30, reason = "deadlock condition"); + } + } on fail var error(msg1, code = errCode1, reason = errReason1) { + str += " -> On Fail #" + i.toString(); + testMessage = msg1; + testErrorCode = errCode1; + testErrorReason = errReason1; + } + i = i + 1; + fail error SampleError("database error!", code = 20, reason = "database connection error"); + } on fail SampleError error(msg2, code = errCode2, reason = errReason2) { + str += " -> On Fail Final"; + } + + assertEquals(" -> Iteration 2, -> On Fail #2 -> On Fail Final", str); + assertEquals(testErrorCode, 30); + assertEquals(testErrorReason, "deadlock condition"); + assertEquals(testMessage, "error!"); +} + +function testMultiLevelOnFailWithoutErrorInOneLevel() { + int i = 2; + string str = ""; + + while i <= 2 { + match matchString { + 12 => { + matchRes = "12"; + } + "fail" => { + str += " -> Iteration " + i.toString() + ", "; + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } + } on fail var error(msg1, code = errCode1, reason = errReason1) { + str += " -> On Fail #" + i.toString(); + testMessage = msg1; + testErrorCode = errCode1; + testErrorReason = errReason1; + } + i = i + 1; + } on fail SampleError error(msg2, code = errCode2, reason = errReason2) { + str += " -> On Fail Final"; + } + + assertEquals(" -> Iteration 2, -> On Fail #2", str); + assertEquals(testErrorCode, 20); + assertEquals(testErrorReason, "deadlock condition"); + assertEquals(testMessage, "error!"); +} + function assertEquals(anydata expected, anydata actual) { if expected == actual { return; diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/statements/matchstmt/matchstmt_on_fail_negative.bal b/tests/jballerina-unit-test/src/test/resources/test-src/statements/matchstmt/matchstmt_on_fail_negative.bal index 700028927c56..c7086297cfae 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/statements/matchstmt/matchstmt_on_fail_negative.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/statements/matchstmt/matchstmt_on_fail_negative.bal @@ -6,35 +6,6 @@ type ErrorTypeB distinct error; const TYPE_B_ERROR_REASON = "TypeB_Error"; -function testUnreachableAfterFail(string | int | boolean a) returns string|error { - match a { - 12 => { - return "Value is '12'"; - } - "Hello" => { - return "Value is 'Hello'"; - } - 15 => { - return "Value is '15'"; - } - true => { - return "Value is 'true'"; - } - false => { - return "Value is 'false'"; - } - "fail" => { - error err = error("custom error", message = "error value"); - fail err; - return "After failure throw"; - } - } on fail error e { - return "Value is 'error'"; - } - - return "Value is 'Default'"; -} - function testIncompatibleErrorTypeOnFail(string | int | boolean a) returns string|error { match a { 12 => { @@ -87,7 +58,6 @@ function testUnreachableInOnFail(string | int | boolean a) returns string|error } } on fail ErrorTypeB e { return "Value is 'error'"; - str += "-> After returning string"; } return "Value is 'Default'"; @@ -127,3 +97,31 @@ function testOnFailErrorType(string | int | boolean a) returns string|error { return "Value is 'Default'"; } + +type SampleErrorData record {| + int code; + string reason; +|}; + +type SampleError error; + +type SampleComplexErrorData record {| + int code; + int[2] pos; + record {string moreInfo;} infoDetails; +|}; + +type SampleComplexError error; + +function testOnFailWithMultipleErrors() { + string matchString = "fail"; + match matchString { + 12 => { + fail error SampleComplexError("Transaction Failure", code = 20, pos = [30, 45], infoDetails = {moreInfo: "deadlock condition"}); + } + "fail" => { + fail error SampleError("Transaction Failure", code = 50, reason = "deadlock condition"); + } + } on fail var error(msg) { + } +} diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/statements/matchstmt/matchstmt_on_fail_negative_unreachable.bal b/tests/jballerina-unit-test/src/test/resources/test-src/statements/matchstmt/matchstmt_on_fail_negative_unreachable.bal new file mode 100644 index 000000000000..cadc30c4819f --- /dev/null +++ b/tests/jballerina-unit-test/src/test/resources/test-src/statements/matchstmt/matchstmt_on_fail_negative_unreachable.bal @@ -0,0 +1,66 @@ +type ErrorTypeA distinct error; + +const TYPE_A_ERROR_REASON = "TypeA_Error"; + +type ErrorTypeB distinct error; + +const TYPE_B_ERROR_REASON = "TypeB_Error"; + +function testUnreachableAfterFail(string | int | boolean a) returns string|error { + match a { + 12 => { + return "Value is '12'"; + } + "Hello" => { + return "Value is 'Hello'"; + } + 15 => { + return "Value is '15'"; + } + true => { + return "Value is 'true'"; + } + false => { + return "Value is 'false'"; + } + "fail" => { + error err = error("custom error", message = "error value"); + fail err; + return "After failure throw"; + } + } on fail error e { + return "Value is 'error'"; + } + + return "Value is 'Default'"; +} + +function testUnreachableInOnFail(string | int | boolean a) returns string|error { + string str = ""; + match a { + 12 => { + return "Value is '12'"; + } + "Hello" => { + return "Value is 'Hello'"; + } + 15 => { + return "Value is '15'"; + } + true => { + return "Value is 'true'"; + } + false => { + return "Value is 'false'"; + } + "fail" => { + error err = error("custom error", message = "error value"); + fail error ErrorTypeB(TYPE_A_ERROR_REASON, message = "Error Type A"); + } + } on fail ErrorTypeB e { + return "Value is 'error'"; + str += "-> After returning string"; + } + + return "Value is 'Default'"; +} diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/statements/onfail/on-fail-clause-negative.bal b/tests/jballerina-unit-test/src/test/resources/test-src/statements/onfail/on-fail-clause-negative.bal index 53aa6db3fa9e..51355c30d19d 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/statements/onfail/on-fail-clause-negative.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/statements/onfail/on-fail-clause-negative.bal @@ -27,3 +27,93 @@ function getError() returns error { error err = error("Custom Error"); return err; } + +type SampleErrorData record {| + int code; + string reason; +|}; + +type SampleError error; + +type SampleComplexErrorData record {| + int code; + int[2] pos; + record {string moreInfo;} infoDetails; +|}; + +type SampleComplexError error; + +function testOnFailWithErrorBPHavingMismatchedTypes1() { + do { + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } on fail error error(code = errCode) { + } +} + +function testOnFailWithErrorBPHavingMismatchedTypes2() { + do { + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } on fail SampleComplexError error(code = errCode) { + } +} + +function testOnFailWithErrorBPHavingMismatchedTypes3() { + do { + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } on fail int error(code = errCode) { + } +} + +function testOnFailWithErrorBPHavingMismatchedTypes4() { + do { + error errVar = error("error", code = "23"); + fail errVar; + } on fail error error(code = errorCode) { + } +} + +function testOnFailWithErrorBPHavingMismatchedTypes5() { + do { + fail error("error!"); + } on fail anydata error(msg) { + } +} + +function testOnFailWithErrorBPHavingInvalidListBP1() { + do { + fail error("error!"); + } on fail [error] [err] { + } +} + +function testOnFailWithErrorBPHavingInvalidListBP2() { + do { + fail error("error!"); + } on fail error [err] { + } +} + +function testOnFailWithErrorBPHavingInvalidWildcardBP() { + do { + fail error("error!"); + } on fail error _ { + } +} + +function testOnFailWithErrorBPHavingInvalidMappingBP() { + do { + fail error("error!"); + } on fail error {failError: err} { + } +} + +function testOnFailWithMultipleErrors() { + boolean isPositiveState = false; + do { + if isPositiveState { + fail error SampleComplexError("Transaction Failure", cause = error("Database Error"), code = 20, pos = [30, 45], infoDetails = {moreInfo: "deadlock condition"}); + } + fail error SampleError("Transaction Failure", code = 50, reason = "deadlock condition"); + } on fail var error(msg) { + } +} diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/statements/onfail/on-fail-clause.bal b/tests/jballerina-unit-test/src/test/resources/test-src/statements/onfail/on-fail-clause.bal index e2503b8b7f1b..c105eec2be31 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/statements/onfail/on-fail-clause.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/statements/onfail/on-fail-clause.bal @@ -588,6 +588,397 @@ function testOnFailInAnonFunctionExpr() returns error? { assertEquality((result2).detail().get("message"), "'string' value 'a2' cannot be converted to 'int'"); } +type SampleErrorData record {| + int code; + string reason; +|}; + +type SampleError error; + +string testMessage = ""; +int testErrorCode = 0; +string testErrorReason = ""; + +function testSimpleOnFailWithErrorBP() { + do { + fail error("error!"); + } on fail error error(msg) { + testMessage = msg; + } + assertEquality(testMessage, "error!"); +} + +function testSimpleOnFailWithErrorBPWithVar() { + do { + fail error("error!"); + } on fail var error(msg) { + testMessage = msg; + } + assertEquality(testMessage, "error!"); +} + +function testOnFailWithErrorBPHavingUserDefinedTypeWithError() { + do { + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } on fail error error(msg, code = errCode, reason = errReason) { + testErrorCode = errCode; + testErrorReason = errReason; + testMessage = msg; + } + assertEquality(testMessage, "error!"); + assertEquality(testErrorCode, 20); + assertEquality(testErrorReason, "deadlock condition"); + assertEquality(testErrorCode is int, true); + assertEquality(testErrorReason is string, true); +} + +function testOnFailWithErrorBPHavingUserDefinedTypeWithVar() { + do { + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } on fail var error(msg, code = errCode, reason = errReason) { + testErrorCode = errCode; + testErrorReason = errReason; + testMessage = msg; + } + assertEquality(testMessage, "error!"); + assertEquality(testErrorCode, 20); + assertEquality(testErrorReason, "deadlock condition"); + assertEquality(testErrorCode is int, true); + assertEquality(testErrorReason is string, true); +} + +function testOnFailWithErrorBPHavingUserDefinedType() { + do { + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } on fail SampleError error(msg, code = errCode, reason = errReason) { + testErrorCode = errCode; + testErrorReason = errReason; + testMessage = msg; + } + assertEquality(testMessage, "error!"); + assertEquality(testErrorCode, 20); + assertEquality(testErrorReason, "deadlock condition"); + assertEquality(testErrorCode is int, true); + assertEquality(testErrorReason is string, true); +} + +function testOnFailWithErrorBPHavingUserDefinedTypeWithErrDetail1() { + do { + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } on fail error error(msg, code = errCode, reason = errReason) { + testErrorCode = errCode; + testErrorReason = errReason; + testMessage = msg; + } + assertEquality(testMessage, "error!"); + assertEquality(testErrorCode, 20); + assertEquality(testErrorReason, "deadlock condition"); + assertEquality(testErrorCode is int, true); + assertEquality(testErrorReason is string, true); +} + +function testOnFailWithErrorBPHavingUserDefinedTypeWithErrDetail2() { + do { + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } on fail error error(code = errCode) { + testErrorCode = errCode; + } + assertEquality(testErrorCode, 20); + assertEquality(testErrorCode is int, true); +} + +function testOnFailWithErrorBPHavingUserDefinedTypeWithErrDetail3() { + do { + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } on fail error error(code = errCode, reason = errReason) { + testErrorCode = errCode; + testErrorReason = errReason; + } + assertEquality(testErrorCode, 20); + assertEquality(testErrorReason, "deadlock condition"); + assertEquality(testErrorCode is int, true); + assertEquality(testErrorReason is string, true); +} + +function testOnFailWithErrorBPHavingUserDefinedTypeWithErrDetail4() { + do { + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } on fail error error(code = errCode) { + testErrorCode = errCode; + } + assertEquality(testErrorCode, 20); + assertEquality(testErrorCode is int, true); +} + +function testOnFailWithErrorBPHavingAnonDetailRecord() { + do { + error errVar = error("error", code = 34); + fail errVar; + } on fail error error(code = errCode) { + testErrorCode = errCode; + } + assertEquality(testErrorCode, 34); + assertEquality(testErrorCode is int, true); +} + +function testOnFailWithErrorBPHavingAnonDetailRecordWithVar() { + do { + error errVar = error("error", code = 34); + fail errVar; + } on fail var error(msg, code = errCode) { + testErrorCode = errCode; + testErrorReason = msg; + } + assertEquality(testErrorCode, 34); + assertEquality(testErrorCode is int, true); + assertEquality(testErrorReason is string, true); + assertEquality(testErrorReason, "error"); +} + +function testOnFailWithErrorBPHavingAnonDetailRecordWithUnionType() { + do { + error errVar = error("error", code = 34); + fail errVar; + } on fail error error(code = errCode) { + testErrorCode = errCode; + } + assertEquality(testErrorCode, 34); + assertEquality(testErrorCode is int, true); +} + +type SampleComplexErrorData record {| + error cause; + int code; + int[2] pos; + record {string moreInfo;} infoDetails; +|}; + +type SampleComplexError error; + +int testErrorPosRow = 0; +int testErrorPosCol = 0; +string testErrorMoreInfo = ""; + + +function testOnFailWithErrorBPWithErrorArgsHavingBP1() { + string causeMsg; + do { + fail error SampleComplexError("Transaction Failure", cause = error("Database Error"), code = 20, pos = [30, 45], infoDetails = {moreInfo: "deadlock condition"}); + } on fail SampleComplexError error(_, cause = errCause, code = errCode, pos = errorPos, infoDetails = errInfo) { + testErrorCode = errCode; + testErrorPosRow = errorPos[0]; + testErrorPosCol = errorPos[1]; + testErrorMoreInfo = errInfo.moreInfo; + causeMsg = errCause.message(); + } + assertEquality(testErrorPosRow, 30); + assertEquality(testErrorPosRow is int, true); + assertEquality(testErrorPosCol, 45); + assertEquality(testErrorPosCol is int, true); + assertEquality(testErrorMoreInfo, "deadlock condition"); + assertEquality(testErrorMoreInfo is string, true); + assertEquality(testErrorCode, 20); + assertEquality(testErrorCode is int, true); + assertEquality(causeMsg, "Database Error"); + assertEquality(causeMsg is string, true); +} + +function testOnFailWithErrorBPWithErrorArgsHavingBP2() { + do { + fail error SampleComplexError("Transaction Failure", cause = error("Database Error"), code = 20, pos = [30, 45], infoDetails = {moreInfo: "deadlock condition"}); + } on fail SampleComplexError error(message, cause = error(msg), code = errCode, pos = errorPos, infoDetails = errInfo) { + testErrorCode = errCode; + testErrorPosRow = errorPos[0]; + testErrorPosCol = errorPos[1]; + testErrorMoreInfo = errInfo.moreInfo; + testMessage = msg; + } + assertEquality(testErrorPosRow, 30); + assertEquality(testErrorPosRow is int, true); + assertEquality(testErrorPosCol, 45); + assertEquality(testErrorPosCol is int, true); + assertEquality(testErrorMoreInfo, "deadlock condition"); + assertEquality(testErrorMoreInfo is string, true); + assertEquality(testErrorCode, 20); + assertEquality(testErrorCode is int, true); + assertEquality(testMessage, "Database Error"); + assertEquality(testMessage is string, true); +} + +function testOnFailWithErrorBPWithErrorArgsHavingBP3() { + do { + fail error SampleComplexError("Transaction Failure", cause = error("Database Error"), code = 20, pos = [30, 45], infoDetails = {moreInfo: "deadlock condition"}); + } on fail SampleComplexError error(message, cause = error(msg), code = errCode, pos = [row, col], infoDetails = errInfo) { + testErrorCode = errCode; + testErrorPosRow = row; + testErrorPosCol = col; + testErrorMoreInfo = errInfo.moreInfo; + testMessage = msg; + } + assertEquality(testErrorPosRow, 30); + assertEquality(testErrorPosRow is int, true); + assertEquality(testErrorPosCol, 45); + assertEquality(testErrorPosCol is int, true); + assertEquality(testErrorMoreInfo, "deadlock condition"); + assertEquality(testErrorMoreInfo is string, true); + assertEquality(testErrorCode, 20); + assertEquality(testErrorCode is int, true); + assertEquality(testMessage, "Database Error"); + assertEquality(testMessage is string, true); +} + +function testOnFailWithErrorBPWithErrorArgsHavingBP4() { + do { + fail error SampleComplexError("Transaction Failure", cause = error("Database Error"), code = 20, pos = [30, 45], infoDetails = {moreInfo: "deadlock condition"}); + } on fail SampleComplexError error(_, cause = error(msg), code = errCode, pos = [row, col], infoDetails = {moreInfo: errInfo}) { + testErrorCode = errCode; + testErrorPosRow = row; + testErrorPosCol = col; + testErrorMoreInfo = errInfo; + testMessage = msg; + } + assertEquality(testErrorPosRow, 30); + assertEquality(testErrorPosRow is int, true); + assertEquality(testErrorPosCol, 45); + assertEquality(testErrorPosCol is int, true); + assertEquality(testErrorMoreInfo, "deadlock condition"); + assertEquality(testErrorMoreInfo is string, true); + assertEquality(testErrorCode, 20); + assertEquality(testErrorCode is int, true); + assertEquality(testMessage, "Database Error"); + assertEquality(testMessage is string, true); +} + +function testOnFailWithErrorBPWithErrorArgsHavingBP5() { + do { + fail error SampleComplexError("Transaction Failure", cause = error("Database Error"), code = 20, pos = [30, 45], infoDetails = {moreInfo: "deadlock condition"}); + } on fail var error(_, cause = error(msg), code = errCode, pos = [row, col], infoDetails = {moreInfo: errInfo}) { + testErrorCode = errCode; + testErrorPosRow = row; + testErrorPosCol = col; + testErrorMoreInfo = errInfo; + testMessage = msg; + } + assertEquality(testErrorPosRow, 30); + assertEquality(testErrorPosRow is int, true); + assertEquality(testErrorPosCol, 45); + assertEquality(testErrorPosCol is int, true); + assertEquality(testErrorMoreInfo, "deadlock condition"); + assertEquality(testErrorMoreInfo is string, true); + assertEquality(testErrorCode, 20); + assertEquality(testErrorCode is int, true); + assertEquality(testMessage, "Database Error"); + assertEquality(testMessage is string, true); +} + +int testErrorCodeNested = 0; +string testMessageNested = ""; + +function testNestedOnFailWithErrorBP() { + string testErrorReasonNested = ""; + do { + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } on fail var error(msg1, code = errCode1, reason = errReason1) { + if errCode1 == 20 { + do { + fail error SampleError("nested error!", code = 30, reason = "database error"); + } on fail var error(msg2, code = errCode2, reason = errReason2) { + testErrorCode = errCode1; + testErrorCodeNested = errCode2; + testErrorReason = errReason1; + testErrorReasonNested = errReason2; + testMessage = msg1; + testMessageNested = msg2; + } + } + } + + assertEquality(testErrorCode, 20); + assertEquality(testErrorCodeNested, 30); + assertEquality(testErrorReason, "deadlock condition"); + assertEquality(testErrorReasonNested, "database error"); + assertEquality(testMessage, "error!"); + assertEquality(testMessageNested, "nested error!"); +} + +function testNestedOnFailWithErrorBPWithErrorArgsHavingBP() { + do { + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } on fail var error(msg1, code = errCode1, reason = errReason1) { + if errCode1 == 20 { + do { + fail error SampleComplexError("nested error!", cause = error("Database Error"), code = 30, pos = [35, 45], infoDetails = {moreInfo: "deadlock condition"}); + } on fail SampleComplexError error(_, cause = error(msg2), code = errCode2, pos = [row, col], infoDetails = {moreInfo: errInfo}) { + testErrorCode = errCode1; + testErrorCodeNested = errCode2; + testMessage = msg1; + testMessageNested = msg2; + testErrorPosRow = row; + testErrorPosCol = col; + testErrorMoreInfo = errInfo; + } + } + } + + assertEquality(testErrorCode, 20); + assertEquality(testErrorCodeNested, 30); + assertEquality(testErrorMoreInfo, "deadlock condition"); + assertEquality(testMessage, "error!"); + assertEquality(testMessageNested, "Database Error"); + assertEquality(testErrorPosRow, 35); + assertEquality(testErrorPosCol, 45); +} + +function testMultiLevelOnFailWithErrorBP() { + int i = 2; + string str = ""; + + while i <= 2 { + do { + str += " -> Iteration " + i.toString() + ", "; + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } on fail var error(msg1, code = errCode1, reason = errReason1) { + str += " -> On Fail #" + i.toString(); + testMessage = msg1; + testErrorCode = errCode1; + testErrorReason = errReason1; + } + i = i + 1; + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } on fail SampleError error(msg2, code = errCode2, reason = errReason2) { + str += " -> On Fail Final"; + } + + assertEquality(" -> Iteration 2, -> On Fail #2 -> On Fail Final", str); + assertEquality(testErrorCode, 20); + assertEquality(testErrorReason, "deadlock condition"); + assertEquality(testMessage, "error!"); +} + +function testMultiLevelOnFailWithoutErrorInOneLevel() { + int i = 2; + string str = ""; + + while i <= 2 { + do { + str += " -> Iteration " + i.toString() + ", "; + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } on fail var error(msg1, code = errCode1, reason = errReason1) { + str += " -> On Fail #" + i.toString(); + testMessage = msg1; + testErrorCode = errCode1; + testErrorReason = errReason1; + } + i = i + 1; + } on fail SampleError error(msg2, code = errCode2, reason = errReason2) { + str += " -> On Fail Final"; + } + + assertEquality(" -> Iteration 2, -> On Fail #2", str); + assertEquality(testErrorCode, 20); + assertEquality(testErrorReason, "deadlock condition"); + assertEquality(testMessage, "error!"); +} //------------------------------------------------------------------------------- type AssertionError error; diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/statements/retrystmt/retry_on_fail_negative.bal b/tests/jballerina-unit-test/src/test/resources/test-src/statements/retrystmt/retry_on_fail_negative.bal index 5266413d7b62..abc2f5020e79 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/statements/retrystmt/retry_on_fail_negative.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/statements/retrystmt/retry_on_fail_negative.bal @@ -6,24 +6,6 @@ type ErrorTypeB distinct error; const TYPE_B_ERROR_REASON = "TypeB_Error"; -function trxError() returns error { - return error("TransactionError"); -} - -function testUnreachableAfterFail () returns string|error { - string str = ""; - int count = 0; - retry (3) { - count = count+1; - str += (" attempt " + count.toString() + ":error,"); - fail trxError(); - str += (" attempt "+ count.toString() + ":result returned end."); - } on fail error e { - return error("Custom Error"); - } - return str; -} - function testIncompatibleErrorTypeOnFail () returns string { string str = ""; retry(3) { @@ -36,52 +18,6 @@ function testIncompatibleErrorTypeOnFail () returns string { return str; } -function testIgnoreReturnInOnFail () returns string { - string str = ""; - retry(3) { - str += "Before failure throw"; - fail error ErrorTypeA(TYPE_A_ERROR_REASON, message = "Error Type A"); - } - on fail ErrorTypeA e { - str += "-> Error caught ! "; - return str; - } - str += "-> Execution continues..."; - return str; -} - -function testUnreachableInOnFail () returns string { - string str = ""; - retry(3) { - str += "Before failure throw"; - fail error ErrorTypeA(TYPE_A_ERROR_REASON, message = "Error Type A"); - } - on fail ErrorTypeA e { - str += "-> Error caught ! "; - return str; - str += "-> After returning string"; - } - str += "-> Execution continues..."; - return str; -} - -function testNestedRetryWithLessOnFails () returns string { - string str = ""; - retry(3) { - str += "-> Before error 1 is thrown"; - retry(2) { - str += " -> Before error 2 is thrown"; - fail error ErrorTypeA(TYPE_A_ERROR_REASON, message = "Error Type A"); - } - fail error ErrorTypeA(TYPE_A_ERROR_REASON, message = "Error Type A"); - } - on fail error e1 { - str += " -> Error caught !"; - } - str += "-> Execution continues..."; - return str; -} - function testOnFailWithUnion () returns string { string str = ""; var getTypeAError = function () returns int|ErrorTypeA{ @@ -104,3 +40,29 @@ function testOnFailWithUnion () returns string { str += "-> Execution continues..."; return str; } + +type SampleErrorData record {| + int code; + string reason; +|}; + +type SampleError error; + +type SampleComplexErrorData record {| + int code; + int[2] pos; + record {string moreInfo;} infoDetails; +|}; + +type SampleComplexError error; + +function testOnFailWithMultipleErrors() { + boolean isPositiveState = false; + retry(3) { + if isPositiveState { + fail error SampleComplexError("Transaction Failure", code = 20, pos = [30, 45], infoDetails = {moreInfo: "deadlock condition"}); + } + fail error SampleError("Transaction Failure", code = 50, reason = "deadlock condition"); + } on fail var error(msg) { + } +} diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/statements/retrystmt/retry_on_fail_negative_unreachable.bal b/tests/jballerina-unit-test/src/test/resources/test-src/statements/retrystmt/retry_on_fail_negative_unreachable.bal new file mode 100644 index 000000000000..1a8fd4f143ce --- /dev/null +++ b/tests/jballerina-unit-test/src/test/resources/test-src/statements/retrystmt/retry_on_fail_negative_unreachable.bal @@ -0,0 +1,89 @@ +type ErrorTypeA distinct error; + +const TYPE_A_ERROR_REASON = "TypeA_Error"; + +const TYPE_B_ERROR_REASON = "TypeB_Error"; + +type ErrorTypeB distinct error; + +function trxError() returns error { + return error("TransactionError"); +} + +function testUnreachableAfterFail () returns string|error { + string str = ""; + int count = 0; + retry (3) { + count = count+1; + str += (" attempt " + count.toString() + ":error,"); + fail trxError(); + str += (" attempt "+ count.toString() + ":result returned end."); + } on fail error e { + return error("Custom Error"); + } + return str; +} + +function testUnreachableInOnFail () returns string { + string str = ""; + retry(3) { + str += "Before failure throw"; + fail error ErrorTypeA(TYPE_A_ERROR_REASON, message = "Error Type A"); + } + on fail ErrorTypeA e { + str += "-> Error caught ! "; + return str; + str += "-> After returning string"; + } + str += "-> Execution continues..."; + return str; +} + +function testIgnoreReturnInOnFail () returns string { + string str = ""; + retry(3) { + str += "Before failure throw"; + fail error ErrorTypeA(TYPE_A_ERROR_REASON, message = "Error Type A"); + } + on fail ErrorTypeA e { + str += "-> Error caught ! "; + return str; + } + str += "-> Execution continues..."; + return str; +} + +function testNestedRetryWithLessOnFails () returns string { + string str = ""; + retry(3) { + str += "-> Before error 1 is thrown"; + retry(2) { + str += " -> Before error 2 is thrown"; + fail error ErrorTypeA(TYPE_A_ERROR_REASON, message = "Error Type A"); + } + fail error ErrorTypeA(TYPE_A_ERROR_REASON, message = "Error Type A"); + } + on fail error e1 { + str += " -> Error caught !"; + } + str += "-> Execution continues..."; + return str; +} + +function testOnFailWithUnion () returns string { + string str = ""; + var getTypeBError = function () returns int|ErrorTypeB{ + ErrorTypeB errorB = error ErrorTypeB(TYPE_B_ERROR_REASON, message = "Error Type B"); + return errorB; + }; + retry(3) { + str += "Before failure throw"; + int resB = check getTypeBError(); + } + on fail ErrorTypeB e { + str += "-> Error caught : "; + str = str.concat(e.message()); + } + str += "-> Execution continues..."; + return str; +} diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/statements/retrystmt/retry_stmt_with_on_fail.bal b/tests/jballerina-unit-test/src/test/resources/test-src/statements/retrystmt/retry_stmt_with_on_fail.bal index a97c7d788e2d..6551a1c430bb 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/statements/retrystmt/retry_stmt_with_on_fail.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/statements/retrystmt/retry_stmt_with_on_fail.bal @@ -289,6 +289,398 @@ function testNestedRetryOnFailJump2() returns string { return str; } +type SampleErrorData record {| + int code; + string reason; +|}; + +type SampleError error; + +string testMessage = ""; +int testErrorCode = 0; +string testErrorReason = ""; + +function testSimpleOnFailWithErrorBP() { + retry(3) { + fail error("error!"); + } on fail error error(msg) { + testMessage = msg; + } + assertEquality(testMessage, "error!"); +} + +function testSimpleOnFailWithErrorBPWithVar() { + retry(3) { + fail error("error!"); + } on fail var error(msg) { + testMessage = msg; + } + assertEquality(testMessage, "error!"); +} + +function testOnFailWithErrorBPHavingUserDefinedTypeWithError() { + retry(3) { + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } on fail error error(msg, code = errCode, reason = errReason) { + testErrorCode = errCode; + testErrorReason = errReason; + testMessage = msg; + } + assertEquality(testMessage, "error!"); + assertEquality(testErrorCode, 20); + assertEquality(testErrorReason, "deadlock condition"); + assertEquality(testErrorCode is int, true); + assertEquality(testErrorReason is string, true); +} + +function testOnFailWithErrorBPHavingUserDefinedTypeWithVar() { + retry(3) { + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } on fail var error(msg, code = errCode, reason = errReason) { + testErrorCode = errCode; + testErrorReason = errReason; + testMessage = msg; + } + assertEquality(testMessage, "error!"); + assertEquality(testErrorCode, 20); + assertEquality(testErrorReason, "deadlock condition"); + assertEquality(testErrorCode is int, true); + assertEquality(testErrorReason is string, true); +} + +function testOnFailWithErrorBPHavingUserDefinedType() { + retry(3) { + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } on fail SampleError error(msg, code = errCode, reason = errReason) { + testErrorCode = errCode; + testErrorReason = errReason; + testMessage = msg; + } + assertEquality(testMessage, "error!"); + assertEquality(testErrorCode, 20); + assertEquality(testErrorReason, "deadlock condition"); + assertEquality(testErrorCode is int, true); + assertEquality(testErrorReason is string, true); +} + +function testOnFailWithErrorBPHavingUserDefinedTypeWithErrDetail1() { + retry(3) { + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } on fail error error(msg, code = errCode, reason = errReason) { + testErrorCode = errCode; + testErrorReason = errReason; + testMessage = msg; + } + assertEquality(testMessage, "error!"); + assertEquality(testErrorCode, 20); + assertEquality(testErrorReason, "deadlock condition"); + assertEquality(testErrorCode is int, true); + assertEquality(testErrorReason is string, true); +} + +function testOnFailWithErrorBPHavingUserDefinedTypeWithErrDetail2() { + retry(3) { + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } on fail error error(code = errCode) { + testErrorCode = errCode; + } + assertEquality(testErrorCode, 20); + assertEquality(testErrorCode is int, true); +} + +function testOnFailWithErrorBPHavingUserDefinedTypeWithErrDetail3() { + retry(3) { + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } on fail error error(code = errCode, reason = errReason) { + testErrorCode = errCode; + testErrorReason = errReason; + } + assertEquality(testErrorCode, 20); + assertEquality(testErrorReason, "deadlock condition"); + assertEquality(testErrorCode is int, true); + assertEquality(testErrorReason is string, true); +} + +function testOnFailWithErrorBPHavingUserDefinedTypeWithErrDetail4() { + retry(3) { + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } on fail error error(code = errCode) { + testErrorCode = errCode; + } + assertEquality(testErrorCode, 20); + assertEquality(testErrorCode is int, true); +} + +function testOnFailWithErrorBPHavingAnonDetailRecord() { + retry(3) { + error errVar = error("error", code = 34); + fail errVar; + } on fail error error(code = errCode) { + testErrorCode = errCode; + } + assertEquality(testErrorCode, 34); + assertEquality(testErrorCode is int, true); +} + +function testOnFailWithErrorBPHavingAnonDetailRecordWithVar() { + retry(3) { + error errVar = error("error", code = 34); + fail errVar; + } on fail var error(msg, code = errCode) { + testErrorCode = errCode; + testErrorReason = msg; + } + assertEquality(testErrorCode, 34); + assertEquality(testErrorCode is int, true); + assertEquality(testErrorReason is string, true); + assertEquality(testErrorReason, "error"); +} + +function testOnFailWithErrorBPHavingAnonDetailRecordWithUnionType() { + retry(3) { + error errVar = error("error", code = 34); + fail errVar; + } on fail error error(code = errCode) { + testErrorCode = errCode; + } + assertEquality(testErrorCode, 34); + assertEquality(testErrorCode is int, true); +} + +type SampleComplexErrorData record {| + error cause; + int code; + int[2] pos; + record {string moreInfo;} infoDetails; +|}; + +type SampleComplexError error; + +int testErrorPosRow = 0; +int testErrorPosCol = 0; +string testErrorMoreInfo = ""; + + +function testOnFailWithErrorBPWithErrorArgsHavingBP1() { + string causeMsg; + retry(3) { + fail error SampleComplexError("Transaction Failure", cause = error("Database Error"), code = 20, pos = [30, 45], infoDetails = {moreInfo: "deadlock condition"}); + } on fail SampleComplexError error(_, cause = errCause, code = errCode, pos = errorPos, infoDetails = errInfo) { + testErrorCode = errCode; + testErrorPosRow = errorPos[0]; + testErrorPosCol = errorPos[1]; + testErrorMoreInfo = errInfo.moreInfo; + causeMsg = errCause.message(); + } + assertEquality(testErrorPosRow, 30); + assertEquality(testErrorPosRow is int, true); + assertEquality(testErrorPosCol, 45); + assertEquality(testErrorPosCol is int, true); + assertEquality(testErrorMoreInfo, "deadlock condition"); + assertEquality(testErrorMoreInfo is string, true); + assertEquality(testErrorCode, 20); + assertEquality(testErrorCode is int, true); + assertEquality(causeMsg, "Database Error"); + assertEquality(causeMsg is string, true); +} + +function testOnFailWithErrorBPWithErrorArgsHavingBP2() { + retry(3) { + fail error SampleComplexError("Transaction Failure", cause = error("Database Error"), code = 20, pos = [30, 45], infoDetails = {moreInfo: "deadlock condition"}); + } on fail SampleComplexError error(message, cause = error(msg), code = errCode, pos = errorPos, infoDetails = errInfo) { + testErrorCode = errCode; + testErrorPosRow = errorPos[0]; + testErrorPosCol = errorPos[1]; + testErrorMoreInfo = errInfo.moreInfo; + testMessage = msg; + } + assertEquality(testErrorPosRow, 30); + assertEquality(testErrorPosRow is int, true); + assertEquality(testErrorPosCol, 45); + assertEquality(testErrorPosCol is int, true); + assertEquality(testErrorMoreInfo, "deadlock condition"); + assertEquality(testErrorMoreInfo is string, true); + assertEquality(testErrorCode, 20); + assertEquality(testErrorCode is int, true); + assertEquality(testMessage, "Database Error"); + assertEquality(testMessage is string, true); +} + +function testOnFailWithErrorBPWithErrorArgsHavingBP3() { + retry(3) { + fail error SampleComplexError("Transaction Failure", cause = error("Database Error"), code = 20, pos = [30, 45], infoDetails = {moreInfo: "deadlock condition"}); + } on fail SampleComplexError error(message, cause = error(msg), code = errCode, pos = [row, col], infoDetails = errInfo) { + testErrorCode = errCode; + testErrorPosRow = row; + testErrorPosCol = col; + testErrorMoreInfo = errInfo.moreInfo; + testMessage = msg; + } + assertEquality(testErrorPosRow, 30); + assertEquality(testErrorPosRow is int, true); + assertEquality(testErrorPosCol, 45); + assertEquality(testErrorPosCol is int, true); + assertEquality(testErrorMoreInfo, "deadlock condition"); + assertEquality(testErrorMoreInfo is string, true); + assertEquality(testErrorCode, 20); + assertEquality(testErrorCode is int, true); + assertEquality(testMessage, "Database Error"); + assertEquality(testMessage is string, true); +} + +function testOnFailWithErrorBPWithErrorArgsHavingBP4() { + retry(3) { + fail error SampleComplexError("Transaction Failure", cause = error("Database Error"), code = 20, pos = [30, 45], infoDetails = {moreInfo: "deadlock condition"}); + } on fail SampleComplexError error(_, cause = error(msg), code = errCode, pos = [row, col], infoDetails = {moreInfo: errInfo}) { + testErrorCode = errCode; + testErrorPosRow = row; + testErrorPosCol = col; + testErrorMoreInfo = errInfo; + testMessage = msg; + } + assertEquality(testErrorPosRow, 30); + assertEquality(testErrorPosRow is int, true); + assertEquality(testErrorPosCol, 45); + assertEquality(testErrorPosCol is int, true); + assertEquality(testErrorMoreInfo, "deadlock condition"); + assertEquality(testErrorMoreInfo is string, true); + assertEquality(testErrorCode, 20); + assertEquality(testErrorCode is int, true); + assertEquality(testMessage, "Database Error"); + assertEquality(testMessage is string, true); +} + +function testOnFailWithErrorBPWithErrorArgsHavingBP5() { + retry(3) { + fail error SampleComplexError("Transaction Failure", cause = error("Database Error"), code = 20, pos = [30, 45], infoDetails = {moreInfo: "deadlock condition"}); + } on fail var error(_, cause = error(msg), code = errCode, pos = [row, col], infoDetails = {moreInfo: errInfo}) { + testErrorCode = errCode; + testErrorPosRow = row; + testErrorPosCol = col; + testErrorMoreInfo = errInfo; + testMessage = msg; + } + assertEquality(testErrorPosRow, 30); + assertEquality(testErrorPosRow is int, true); + assertEquality(testErrorPosCol, 45); + assertEquality(testErrorPosCol is int, true); + assertEquality(testErrorMoreInfo, "deadlock condition"); + assertEquality(testErrorMoreInfo is string, true); + assertEquality(testErrorCode, 20); + assertEquality(testErrorCode is int, true); + assertEquality(testMessage, "Database Error"); + assertEquality(testMessage is string, true); +} + +int testErrorCodeNested = 0; +string testMessageNested = ""; + +function testNestedOnFailWithErrorBP() { + string testErrorReasonNested = ""; + retry(3) { + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } on fail var error(msg1, code = errCode1, reason = errReason1) { + if errCode1 == 20 { + retry(3) { + fail error SampleError("nested error!", code = 30, reason = "database error"); + } on fail var error(msg2, code = errCode2, reason = errReason2) { + testErrorCode = errCode1; + testErrorCodeNested = errCode2; + testErrorReason = errReason1; + testErrorReasonNested = errReason2; + testMessage = msg1; + testMessageNested = msg2; + } + } + } + + assertEquality(testErrorCode, 20); + assertEquality(testErrorCodeNested, 30); + assertEquality(testErrorReason, "deadlock condition"); + assertEquality(testErrorReasonNested, "database error"); + assertEquality(testMessage, "error!"); + assertEquality(testMessageNested, "nested error!"); +} + +function testNestedOnFailWithErrorBPWithErrorArgsHavingBP() { + retry(3) { + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } on fail var error(msg1, code = errCode1, reason = errReason1) { + if errCode1 == 20 { + retry(3) { + fail error SampleComplexError("nested error!", cause = error("Database Error"), code = 30, pos = [35, 45], infoDetails = {moreInfo: "deadlock condition"}); + } on fail SampleComplexError error(_, cause = error(msg2), code = errCode2, pos = [row, col], infoDetails = {moreInfo: errInfo}) { + testErrorCode = errCode1; + testErrorCodeNested = errCode2; + testMessage = msg1; + testMessageNested = msg2; + testErrorPosRow = row; + testErrorPosCol = col; + testErrorMoreInfo = errInfo; + } + } + } + + assertEquality(testErrorCode, 20); + assertEquality(testErrorCodeNested, 30); + assertEquality(testErrorMoreInfo, "deadlock condition"); + assertEquality(testMessage, "error!"); + assertEquality(testMessageNested, "Database Error"); + assertEquality(testErrorPosRow, 35); + assertEquality(testErrorPosCol, 45); +} + +function testMultiLevelOnFailWithErrorBP() { + int i = 2; + string str = ""; + + while i <= 2 { + retry(3) { + str += " -> Iteration " + i.toString() + ", "; + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } on fail var error(msg1, code = errCode1, reason = errReason1) { + str += " -> On Fail #" + i.toString(); + testMessage = msg1; + testErrorCode = errCode1; + testErrorReason = errReason1; + } + i = i + 1; + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } on fail SampleError error(msg2, code = errCode2, reason = errReason2) { + str += " -> On Fail Final"; + } + + assertEquality(" -> Iteration 2, -> On Fail #2 -> On Fail Final", str); + assertEquality(testErrorCode, 20); + assertEquality(testErrorReason, "deadlock condition"); + assertEquality(testMessage, "error!"); +} + +function testMultiLevelOnFailWithoutErrorInOneLevel() { + int i = 2; + string str = ""; + + while i <= 2 { + retry(3) { + str += " -> Iteration " + i.toString() + ", "; + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } on fail var error(msg1, code = errCode1, reason = errReason1) { + str += " -> On Fail #" + i.toString(); + testMessage = msg1; + testErrorCode = errCode1; + testErrorReason = errReason1; + } + i = i + 1; + } on fail SampleError error(msg2, code = errCode2, reason = errReason2) { + str += " -> On Fail Final"; + } + + assertEquality(" -> Iteration 2, -> On Fail #2", str); + assertEquality(testErrorCode, 20); + assertEquality(testErrorReason, "deadlock condition"); + assertEquality(testMessage, "error!"); +} + const ASSERTION_ERROR_REASON = "AssertionError"; function assertEquality(any|error expected, any|error actual) { diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/statements/whilestatement/while-stmt-on-fail-negative-reachability.bal b/tests/jballerina-unit-test/src/test/resources/test-src/statements/whilestatement/while-stmt-on-fail-negative-reachability.bal new file mode 100644 index 000000000000..7505d5d1d78c --- /dev/null +++ b/tests/jballerina-unit-test/src/test/resources/test-src/statements/whilestatement/while-stmt-on-fail-negative-reachability.bal @@ -0,0 +1,114 @@ +type ErrorTypeA distinct error; + +const TYPE_A_ERROR_REASON = "TypeA_Error"; + +type ErrorTypeB distinct error; + +const TYPE_B_ERROR_REASON = "TypeB_Error"; + +function testUnreachableAfterFail (int i) returns string { + string str = ""; + int count = i; + while (count < 5) { + count += 1; + error err = error("custom error", message = "error value"); + str += "Before failure throw"; + fail err; + str += "After failure throw"; + } + on fail error e { + str += "-> Error caught ! "; + } + str += "-> Execution continues..."; + return str; +} + +function testIncompatibleErrorTypeOnFail (int i) returns string { + string str = ""; + int count = i; + while (count < 5) { + count += 1; + str += "Before failure throw"; + fail error ErrorTypeA(TYPE_A_ERROR_REASON, message = "Error Type A"); + } + on fail ErrorTypeA e { + str += "-> Error caught ! "; + } + str += "-> Execution continues..."; + return str; +} + +function testIgnoreReturnInOnFail (int i) returns string { + string str = ""; + int count = i; + while (count < 5) { + count += 1; + str += "Before failure throw"; + fail error ErrorTypeA(TYPE_A_ERROR_REASON, message = "Error Type A"); + } + on fail ErrorTypeA e { + str += "-> Error caught ! "; + return str; + } + str += "-> Execution continues..."; + return str; +} + +function testUnreachableInOnFail (int i) returns string { + string str = ""; + int count = i; + while (count < 5) { + count += 1; + str += "Before failure throw"; + fail error ErrorTypeA(TYPE_A_ERROR_REASON, message = "Error Type A"); + } + on fail ErrorTypeA e { + str += "-> Error caught ! "; + return str; + str += "-> After returning string"; + } + str += "-> Execution continues..."; + return str; +} + +function testReturnWitihinDo(int i) returns string { + string str = ""; + int count = i; + while (count < 5) { + count += 1; + str = str + "do statement start"; + return str; + } + str = str + "do statemtnt finished"; +} + +function testOnFailWithUnion (int i) returns string { + string str = ""; + var getTypeAError = function () returns int|ErrorTypeA{ + ErrorTypeA errorA = error ErrorTypeA(TYPE_A_ERROR_REASON, message = "Error Type A"); + return errorA; + }; + int count = i; + while (count < 5) { + count += 1; + str += "Before failure throw"; + int _ = check getTypeAError(); + } + on fail ErrorTypeA e { + str += "-> Error caught : "; + str = str.concat(e.message()); + } + str += "-> Execution continues..."; + return str; +} + +function testErrroDuplication() returns error? { + string str = ""; + int i = 3; + while (i > 2) { + i -= 1; + fail error("Custom Error"); + str += "-> unreachable"; + } + str += "-> unreachable"; +} diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/statements/whilestatement/while-stmt-on-fail-negative.bal b/tests/jballerina-unit-test/src/test/resources/test-src/statements/whilestatement/while-stmt-on-fail-negative.bal index 772c3a04accb..cff4f22915dd 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/statements/whilestatement/while-stmt-on-fail-negative.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/statements/whilestatement/while-stmt-on-fail-negative.bal @@ -6,23 +6,6 @@ type ErrorTypeB distinct error; const TYPE_B_ERROR_REASON = "TypeB_Error"; -function testUnreachableAfterFail (int i) returns string { - string str = ""; - int count = i; - while (count < 5) { - count += 1; - error err = error("custom error", message = "error value"); - str += "Before failure throw"; - fail err; - str += "After failure throw"; - } - on fail error e { - str += "-> Error caught ! "; - } - str += "-> Execution continues..."; - return str; -} - function testIncompatibleErrorTypeOnFail (int i) returns string { string str = ""; int count = i; @@ -38,50 +21,6 @@ function testIncompatibleErrorTypeOnFail (int i) returns string { return str; } -function testIgnoreReturnInOnFail (int i) returns string { - string str = ""; - int count = i; - while (count < 5) { - count += 1; - str += "Before failure throw"; - fail error ErrorTypeA(TYPE_A_ERROR_REASON, message = "Error Type A"); - } - on fail ErrorTypeA e { - str += "-> Error caught ! "; - return str; - } - str += "-> Execution continues..."; - return str; -} - -function testUnreachableInOnFail (int i) returns string { - string str = ""; - int count = i; - while (count < 5) { - count += 1; - str += "Before failure throw"; - fail error ErrorTypeA(TYPE_A_ERROR_REASON, message = "Error Type A"); - } - on fail ErrorTypeA e { - str += "-> Error caught ! "; - return str; - str += "-> After returning string"; - } - str += "-> Execution continues..."; - return str; -} - -function testReturnWitihinDo(int i) returns string { - string str = ""; - int count = i; - while (count < 5) { - count += 1; - str = str + "do statement start"; - return str; - } - str = str + "do statemtnt finished"; -} - function testOnFailWithUnion (int i) returns string { string str = ""; var getTypeAError = function () returns int|ErrorTypeA{ @@ -107,13 +46,29 @@ function testOnFailWithUnion (int i) returns string { return str; } -function testErrroDuplication() returns error? { - string str = ""; - int i = 3; - while (i > 2) { - i -= 1; - fail error("Custom Error"); - str += "-> unreachable"; +type SampleErrorData record {| + int code; + string reason; +|}; + +type SampleError error; + +type SampleComplexErrorData record {| + int code; + int[2] pos; + record {string moreInfo;} infoDetails; +|}; + +type SampleComplexError error; +int whileIndex = 0; + +function testOnFailWithMultipleErrors() { + while whileIndex >= 0 { + whileIndex = whileIndex + 1; + if whileIndex == 1 { + fail error SampleComplexError("Transaction Failure", code = 20, pos = [30, 45], infoDetails = {moreInfo: "deadlock condition"}); + } + fail error SampleError("Transaction Failure", code = 50, reason = "deadlock condition"); + } on fail var error(msg) { } - str += "-> unreachable"; } diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/statements/whilestatement/while-stmt-on-fail.bal b/tests/jballerina-unit-test/src/test/resources/test-src/statements/whilestatement/while-stmt-on-fail.bal index ef242e00c801..05318a157e4f 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/statements/whilestatement/while-stmt-on-fail.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/statements/whilestatement/while-stmt-on-fail.bal @@ -135,6 +135,490 @@ function testWhileStmtWithOnFailWithoutVariable() { assertEquality(" Value: 1 Value: 2 Value: 3-> error caught. -> reached end", str); } +type SampleErrorData record {| + int code; + string reason; +|}; + +type SampleError error; + +string testMessage = ""; +int testErrorCode = 0; +string testErrorReason = ""; +int whileIndex = 0; + +function testSimpleOnFailWithErrorBP() { + while whileIndex >= 0 { + whileIndex = whileIndex + 1; + if whileIndex == 1 { + fail error("error!"); + } + } on fail error error(msg) { + testMessage = msg; + } + assertEquality(testMessage, "error!"); +} + +function testSimpleOnFailWithErrorBPWithVar() { + whileIndex = 0; + while whileIndex >= 0 { + whileIndex = whileIndex + 1; + if whileIndex == 1 { + fail error("error!"); + } + } on fail var error(msg) { + testMessage = msg; + } + assertEquality(testMessage, "error!"); +} + +function testOnFailWithErrorBPHavingUserDefinedTypeWithError() { + whileIndex = 0; + while whileIndex >= 0 { + whileIndex = whileIndex + 1; + if whileIndex == 1 { + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } + } on fail error error(msg, code = errCode, reason = errReason) { + testErrorCode = errCode; + testErrorReason = errReason; + testMessage = msg; + } + assertEquality(testMessage, "error!"); + assertEquality(testErrorCode, 20); + assertEquality(testErrorReason, "deadlock condition"); + assertEquality(testErrorCode is int, true); + assertEquality(testErrorReason is string, true); +} + +function testOnFailWithErrorBPHavingUserDefinedTypeWithVar() { + whileIndex = 0; + while whileIndex >= 0 { + whileIndex = whileIndex + 1; + if whileIndex == 1 { + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } + } on fail var error(msg, code = errCode, reason = errReason) { + testErrorCode = errCode; + testErrorReason = errReason; + testMessage = msg; + } + assertEquality(testMessage, "error!"); + assertEquality(testErrorCode, 20); + assertEquality(testErrorReason, "deadlock condition"); + assertEquality(testErrorCode is int, true); + assertEquality(testErrorReason is string, true); +} + +function testOnFailWithErrorBPHavingUserDefinedType() { + whileIndex = 0; + while whileIndex >= 0 { + whileIndex = whileIndex + 1; + if whileIndex == 1 { + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } + } on fail SampleError error(msg, code = errCode, reason = errReason) { + testErrorCode = errCode; + testErrorReason = errReason; + testMessage = msg; + } + assertEquality(testMessage, "error!"); + assertEquality(testErrorCode, 20); + assertEquality(testErrorReason, "deadlock condition"); + assertEquality(testErrorCode is int, true); + assertEquality(testErrorReason is string, true); +} + +function testOnFailWithErrorBPHavingUserDefinedTypeWithErrDetail1() { + whileIndex = 0; + while whileIndex >= 0 { + whileIndex = whileIndex + 1; + if whileIndex == 1 { + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } + } on fail error error(msg, code = errCode, reason = errReason) { + testErrorCode = errCode; + testErrorReason = errReason; + testMessage = msg; + } + assertEquality(testMessage, "error!"); + assertEquality(testErrorCode, 20); + assertEquality(testErrorReason, "deadlock condition"); + assertEquality(testErrorCode is int, true); + assertEquality(testErrorReason is string, true); +} + +function testOnFailWithErrorBPHavingUserDefinedTypeWithErrDetail2() { + whileIndex = 0; + while whileIndex >= 0 { + whileIndex = whileIndex + 1; + if whileIndex == 1 { + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } + } on fail error error(code = errCode) { + testErrorCode = errCode; + } + assertEquality(testErrorCode, 20); + assertEquality(testErrorCode is int, true); +} + +function testOnFailWithErrorBPHavingUserDefinedTypeWithErrDetail3() { + whileIndex = 0; + while whileIndex >= 0 { + whileIndex = whileIndex + 1; + if whileIndex == 1 { + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } + } on fail error error(code = errCode, reason = errReason) { + testErrorCode = errCode; + testErrorReason = errReason; + } + assertEquality(testErrorCode, 20); + assertEquality(testErrorReason, "deadlock condition"); + assertEquality(testErrorCode is int, true); + assertEquality(testErrorReason is string, true); +} + +function testOnFailWithErrorBPHavingUserDefinedTypeWithErrDetail4() { + whileIndex = 0; + while whileIndex >= 0 { + whileIndex = whileIndex + 1; + if whileIndex == 1 { + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } + } on fail error error(code = errCode) { + testErrorCode = errCode; + } + assertEquality(testErrorCode, 20); + assertEquality(testErrorCode is int, true); +} + +function testOnFailWithErrorBPHavingAnonDetailRecord() { + whileIndex = 0; + while whileIndex >= 0 { + whileIndex = whileIndex + 1; + if whileIndex == 1 { + error errVar = error("error", code = 34); + fail errVar; + } + } on fail error error(code = errCode) { + testErrorCode = errCode; + } + assertEquality(testErrorCode, 34); + assertEquality(testErrorCode is int, true); +} + +function testOnFailWithErrorBPHavingAnonDetailRecordWithVar() { + whileIndex = 0; + while whileIndex >= 0 { + whileIndex = whileIndex + 1; + if whileIndex == 1 { + error errVar = error("error", code = 34); + fail errVar; + } + } on fail var error(msg, code = errCode) { + testErrorCode = errCode; + testErrorReason = msg; + } + assertEquality(testErrorCode, 34); + assertEquality(testErrorCode is int, true); + assertEquality(testErrorReason is string, true); + assertEquality(testErrorReason, "error"); +} + +function testOnFailWithErrorBPHavingAnonDetailRecordWithUnionType() { + whileIndex = 0; + while whileIndex >= 0 { + whileIndex = whileIndex + 1; + if whileIndex == 1 { + error errVar = error("error", code = 34); + fail errVar; + } + } on fail error error(code = errCode) { + testErrorCode = errCode; + } + assertEquality(testErrorCode, 34); + assertEquality(testErrorCode is int, true); +} + +type SampleComplexErrorData record {| + error cause; + int code; + int[2] pos; + record {string moreInfo;} infoDetails; +|}; + +type SampleComplexError error; + +int testErrorPosRow = 0; +int testErrorPosCol = 0; +string testErrorMoreInfo = ""; + + +function testOnFailWithErrorBPWithErrorArgsHavingBP1() { + string causeMsg = ""; + whileIndex = 0; + while whileIndex >= 0 { + whileIndex = whileIndex + 1; + if whileIndex == 1 { + fail error SampleComplexError("Transaction Failure", cause = error("Database Error"), code = 20, pos = [30, 45], infoDetails = {moreInfo: "deadlock condition"}); + } + } on fail SampleComplexError error(_, cause = errCause, code = errCode, pos = errorPos, infoDetails = errInfo) { + testErrorCode = errCode; + testErrorPosRow = errorPos[0]; + testErrorPosCol = errorPos[1]; + testErrorMoreInfo = errInfo.moreInfo; + causeMsg = errCause.message(); + } + assertEquality(testErrorPosRow, 30); + assertEquality(testErrorPosRow is int, true); + assertEquality(testErrorPosCol, 45); + assertEquality(testErrorPosCol is int, true); + assertEquality(testErrorMoreInfo, "deadlock condition"); + assertEquality(testErrorMoreInfo is string, true); + assertEquality(testErrorCode, 20); + assertEquality(testErrorCode is int, true); + assertEquality(causeMsg, "Database Error"); + assertEquality(causeMsg is string, true); +} + +function testOnFailWithErrorBPWithErrorArgsHavingBP2() { + whileIndex = 0; + while whileIndex >= 0 { + whileIndex = whileIndex + 1; + if whileIndex == 1 { + fail error SampleComplexError("Transaction Failure", cause = error("Database Error"), code = 20, pos = [30, 45], infoDetails = {moreInfo: "deadlock condition"}); + } + } on fail SampleComplexError error(message, cause = error(msg), code = errCode, pos = errorPos, infoDetails = errInfo) { + testErrorCode = errCode; + testErrorPosRow = errorPos[0]; + testErrorPosCol = errorPos[1]; + testErrorMoreInfo = errInfo.moreInfo; + testMessage = msg; + } + assertEquality(testErrorPosRow, 30); + assertEquality(testErrorPosRow is int, true); + assertEquality(testErrorPosCol, 45); + assertEquality(testErrorPosCol is int, true); + assertEquality(testErrorMoreInfo, "deadlock condition"); + assertEquality(testErrorMoreInfo is string, true); + assertEquality(testErrorCode, 20); + assertEquality(testErrorCode is int, true); + assertEquality(testMessage, "Database Error"); + assertEquality(testMessage is string, true); +} + +function testOnFailWithErrorBPWithErrorArgsHavingBP3() { + whileIndex = 0; + while whileIndex >= 0 { + whileIndex = whileIndex + 1; + if whileIndex == 1 { + fail error SampleComplexError("Transaction Failure", cause = error("Database Error"), code = 20, pos = [30, 45], infoDetails = {moreInfo: "deadlock condition"}); + } + } on fail SampleComplexError error(message, cause = error(msg), code = errCode, pos = [row, col], infoDetails = errInfo) { + testErrorCode = errCode; + testErrorPosRow = row; + testErrorPosCol = col; + testErrorMoreInfo = errInfo.moreInfo; + testMessage = msg; + } + assertEquality(testErrorPosRow, 30); + assertEquality(testErrorPosRow is int, true); + assertEquality(testErrorPosCol, 45); + assertEquality(testErrorPosCol is int, true); + assertEquality(testErrorMoreInfo, "deadlock condition"); + assertEquality(testErrorMoreInfo is string, true); + assertEquality(testErrorCode, 20); + assertEquality(testErrorCode is int, true); + assertEquality(testMessage, "Database Error"); + assertEquality(testMessage is string, true); +} + +function testOnFailWithErrorBPWithErrorArgsHavingBP4() { + whileIndex = 0; + while whileIndex >= 0 { + whileIndex = whileIndex + 1; + if whileIndex == 1 { + fail error SampleComplexError("Transaction Failure", cause = error("Database Error"), code = 20, pos = [30, 45], infoDetails = {moreInfo: "deadlock condition"}); + } + } on fail SampleComplexError error(_, cause = error(msg), code = errCode, pos = [row, col], infoDetails = {moreInfo: errInfo}) { + testErrorCode = errCode; + testErrorPosRow = row; + testErrorPosCol = col; + testErrorMoreInfo = errInfo; + testMessage = msg; + } + assertEquality(testErrorPosRow, 30); + assertEquality(testErrorPosRow is int, true); + assertEquality(testErrorPosCol, 45); + assertEquality(testErrorPosCol is int, true); + assertEquality(testErrorMoreInfo, "deadlock condition"); + assertEquality(testErrorMoreInfo is string, true); + assertEquality(testErrorCode, 20); + assertEquality(testErrorCode is int, true); + assertEquality(testMessage, "Database Error"); + assertEquality(testMessage is string, true); +} + +function testOnFailWithErrorBPWithErrorArgsHavingBP5() { + whileIndex = 0; + while whileIndex >= 0 { + whileIndex = whileIndex + 1; + if whileIndex == 1 { + fail error SampleComplexError("Transaction Failure", cause = error("Database Error"), code = 20, pos = [30, 45], infoDetails = {moreInfo: "deadlock condition"}); + } + } on fail var error(_, cause = error(msg), code = errCode, pos = [row, col], infoDetails = {moreInfo: errInfo}) { + testErrorCode = errCode; + testErrorPosRow = row; + testErrorPosCol = col; + testErrorMoreInfo = errInfo; + testMessage = msg; + } + assertEquality(testErrorPosRow, 30); + assertEquality(testErrorPosRow is int, true); + assertEquality(testErrorPosCol, 45); + assertEquality(testErrorPosCol is int, true); + assertEquality(testErrorMoreInfo, "deadlock condition"); + assertEquality(testErrorMoreInfo is string, true); + assertEquality(testErrorCode, 20); + assertEquality(testErrorCode is int, true); + assertEquality(testMessage, "Database Error"); + assertEquality(testMessage is string, true); +} + +int testErrorCodeNested = 0; +string testMessageNested = ""; + +function testNestedOnFailWithErrorBP() { + string testErrorReasonNested = ""; + whileIndex = 0; + int innerWhileIndex = 0; + while whileIndex >= 0 { + whileIndex = whileIndex + 1; + if whileIndex == 1 { + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } + } on fail var error(msg1, code = errCode1, reason = errReason1) { + if errCode1 == 20 { + while innerWhileIndex >= 0 { + innerWhileIndex = innerWhileIndex + 1; + if innerWhileIndex == 1 { + fail error SampleError("nested error!", code = 30, reason = "database error"); + } + } on fail var error(msg2, code = errCode2, reason = errReason2) { + testErrorCode = errCode1; + testErrorCodeNested = errCode2; + testErrorReason = errReason1; + testErrorReasonNested = errReason2; + testMessage = msg1; + testMessageNested = msg2; + } + } + } + + assertEquality(testErrorCode, 20); + assertEquality(testErrorCodeNested, 30); + assertEquality(testErrorReason, "deadlock condition"); + assertEquality(testErrorReasonNested, "database error"); + assertEquality(testMessage, "error!"); + assertEquality(testMessageNested, "nested error!"); +} + +function testNestedOnFailWithErrorBPWithErrorArgsHavingBP() { + whileIndex = 0; + int innerWhileIndex = 0; + while whileIndex >= 0 { + whileIndex = whileIndex + 1; + if whileIndex == 1 { + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } + } on fail var error(msg1, code = errCode1, reason = errReason1) { + if errCode1 == 20 { + while innerWhileIndex >= 0 { + innerWhileIndex = innerWhileIndex + 1; + if innerWhileIndex == 1 { + fail error SampleComplexError("nested error!", cause = error("Database Error"), code = 30, pos = [35, 45], infoDetails = {moreInfo: "deadlock condition"}); + } + } on fail SampleComplexError error(_, cause = error(msg2), code = errCode2, pos = [row, col], infoDetails = {moreInfo: errInfo}) { + testErrorCode = errCode1; + testErrorCodeNested = errCode2; + testMessage = msg1; + testMessageNested = msg2; + testErrorPosRow = row; + testErrorPosCol = col; + testErrorMoreInfo = errInfo; + } + } + } + + assertEquality(testErrorCode, 20); + assertEquality(testErrorCodeNested, 30); + assertEquality(testErrorMoreInfo, "deadlock condition"); + assertEquality(testMessage, "error!"); + assertEquality(testMessageNested, "Database Error"); + assertEquality(testErrorPosRow, 35); + assertEquality(testErrorPosCol, 45); +} + +function testMultiLevelOnFailWithErrorBP() { + int i = 0; + string str = ""; + whileIndex = 0; + + while i == 0 { + while whileIndex == 0 { + whileIndex = whileIndex + 1; + if (whileIndex == 1) { + str += " -> Iteration " + i.toString() + ", "; + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } + } on fail var error(msg1, code = errCode1, reason = errReason1) { + str += " -> On Fail #" + i.toString(); + testMessage = msg1; + testErrorCode = errCode1; + testErrorReason = errReason1; + } + i = i + 1; + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } on fail SampleError error(msg2, code = errCode2, reason = errReason2) { + str += " -> On Fail Final"; + } + + assertEquality(" -> Iteration 0, -> On Fail #0 -> On Fail Final", str); + assertEquality(testErrorCode, 20); + assertEquality(testErrorReason, "deadlock condition"); + assertEquality(testMessage, "error!"); +} + +function testMultiLevelOnFailWithoutErrorInOneLevel() { + int i = 0; + string str = ""; + whileIndex = 0; + + while i == 0 { + while whileIndex == 0 { + whileIndex = whileIndex + 1; + if (whileIndex == 1) { + str += " -> Iteration " + i.toString() + ", "; + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } + } on fail var error(msg1, code = errCode1, reason = errReason1) { + str += " -> On Fail #" + i.toString(); + testMessage = msg1; + testErrorCode = errCode1; + testErrorReason = errReason1; + } + i = i + 1; + } on fail SampleError error(msg2, code = errCode2, reason = errReason2) { + str += " -> On Fail Final"; + } + + assertEquality(" -> Iteration 0, -> On Fail #0", str); + assertEquality(testErrorCode, 20); + assertEquality(testErrorReason, "deadlock condition"); + assertEquality(testMessage, "error!"); +} + function assertEquality(anydata expected, anydata actual) { if actual == expected { return; From d275b779c535a080847eaa920561070a52e00a2e Mon Sep 17 00:00:00 2001 From: suleka96 Date: Mon, 22 May 2023 12:12:01 +0530 Subject: [PATCH 16/33] Update desugar code --- .../org/wso2/ballerinalang/compiler/desugar/Desugar.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java index 1002e4ee40f5..389691721131 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java @@ -5183,15 +5183,15 @@ private void handleOnFailErrorVarDefNode(VariableDefinitionNode onFailVarDefNode BLangStatement stmt; BLangVariable variableNode = (BLangVariable) onFailVarDefNode.getVariable(); if (variableNode.getKind() == NodeKind.ERROR_VARIABLE) { - stmt = handleErrorBPInOnFail((BLangErrorVariable) variableNode, onFailBody, fail); + stmt = handleErrorBPInOnFail((BLangErrorVariable) variableNode, fail); } else { - stmt = handleCaptureBPInOnFail((BLangSimpleVariable) variableNode, onFailBody, fail); + stmt = handleCaptureBPInOnFail((BLangSimpleVariable) variableNode, fail); } onFailBody.stmts.add(0, stmt); } } - private BLangStatement handleErrorBPInOnFail (BLangErrorVariable varNode, BLangBlockStmt onFailBody, BLangFail fail) { + private BLangStatement handleErrorBPInOnFail (BLangErrorVariable varNode, BLangFail fail) { BLangErrorVariable errorVar = ASTBuilderUtil.createErrorVariable(varNode.pos, varNode.getBType(), rewrite(fail.expr, env), varNode.message, varNode.cause, varNode.restDetail, varNode.detail); @@ -5199,7 +5199,7 @@ private BLangStatement handleErrorBPInOnFail (BLangErrorVariable varNode, BLangB return rewrite(errorVarDef, env); } - private BLangStatement handleCaptureBPInOnFail(BLangSimpleVariable varNode, BLangBlockStmt onFailBody, BLangFail fail) { + private BLangStatement handleCaptureBPInOnFail(BLangSimpleVariable varNode, BLangFail fail) { BVarSymbol onFailErrorVariableSymbol = varNode.symbol; BLangSimpleVariable errorVar = ASTBuilderUtil.createVariable(onFailErrorVariableSymbol.pos, onFailErrorVariableSymbol.name.value, onFailErrorVariableSymbol.type, rewrite(fail.expr, env), From 664c9a2cd4f81f4c71e687b2b2d6d4e5f30e3ccc Mon Sep 17 00:00:00 2001 From: suleka96 Date: Tue, 23 May 2023 11:38:55 +0530 Subject: [PATCH 17/33] Update Do tests --- .../statements/dostatement/DoStmtsTest.java | 52 ++++++++----- .../dostatement/do-stmt-negative-1.bal | 53 -------------- .../do-stmt-negative-unreachable.bal | 73 +++++++++++++++++++ 3 files changed, 108 insertions(+), 70 deletions(-) create mode 100644 tests/jballerina-unit-test/src/test/resources/test-src/statements/dostatement/do-stmt-negative-unreachable.bal diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/dostatement/DoStmtsTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/dostatement/DoStmtsTest.java index f2fc388ff8ef..6625354f0609 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/dostatement/DoStmtsTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/dostatement/DoStmtsTest.java @@ -31,13 +31,15 @@ */ public class DoStmtsTest { - private CompileResult programFile, negativeFile1, negativeFile2; + private CompileResult programFile, negativeFile1, negativeFile2, negativeFile3; @BeforeClass public void setup() { programFile = BCompileUtil.compile("test-src/statements/dostatement/do-stmt.bal"); negativeFile1 = BCompileUtil.compile("test-src/statements/dostatement/do-stmt-negative-1.bal"); negativeFile2 = BCompileUtil.compile("test-src/statements/dostatement/do-stmt-negative-2.bal"); + negativeFile3 = + BCompileUtil.compile("test-src/statements/dostatement/do-stmt-negative-unreachable.bal"); } @Test @@ -45,32 +47,47 @@ public void testOnFailStatement() { BRunUtil.invoke(programFile, "testOnFailStatement"); } - @Test(description = "Check not incompatible types and reachable statements.") + @Test(description = "Check not incompatible types.") public void testNegative1() { int index = 0; - BAssertUtil.validateError(negativeFile1, index++, "unreachable code", 15, 6); - BAssertUtil.validateWarning(negativeFile1, index++, "unused variable 'e'", 17, 12); BAssertUtil.validateError(negativeFile1, index++, "incompatible error definition type: " + - "'ErrorTypeA' will not be matched to 'ErrorTypeB'", 30, 12); - BAssertUtil.validateWarning(negativeFile1, index++, "unused variable 'e'", 30, 12); - BAssertUtil.validateWarning(negativeFile1, index++, "unused variable 'e'", 43, 12); - BAssertUtil.validateWarning(negativeFile1, index++, "unused variable 'e'", 57, 12); - BAssertUtil.validateError(negativeFile1, index++, "unreachable code", 60, 7); - BAssertUtil.validateError(negativeFile1, index++, "unreachable code", 72, 3); - BAssertUtil.validateError(negativeFile1, index++, "this function must return a result", 73, 1); + "'ErrorTypeA' will not be matched to 'ErrorTypeB'", 15, 12); + BAssertUtil.validateError(negativeFile1, index++, "incompatible types: expected 'ErrorTypeA', " + + "found 'ErrorTypeB'", 15, 12); BAssertUtil.validateError(negativeFile1, index++, "incompatible error definition type: " + - "'ErrorTypeB' will not be matched to 'ErrorTypeA'", 90, 12); + "'ErrorTypeB' will not be matched to 'ErrorTypeA'", 37, 12); + BAssertUtil.validateError(negativeFile1, index++, "incompatible types: expected " + + "'(ErrorTypeA|ErrorTypeB)', found 'ErrorTypeA'", 37, 12); Assert.assertEquals(negativeFile1.getDiagnostics().length, index); } + @Test(description = "Check unreachable statements.") + public void testNegativeUnreachable() { + int index = 0; + BAssertUtil.validateError(negativeFile3, index++, "unreachable code", 15, 6); + BAssertUtil.validateWarning(negativeFile3, index++, "unused variable 'e'", 17, 12); + BAssertUtil.validateWarning(negativeFile3, index++, "unused variable 'e'", 30, 12); + BAssertUtil.validateWarning(negativeFile3, index++, "unused variable 'e'", 43, 12); + BAssertUtil.validateWarning(negativeFile3, index++, "unused variable 'e'", 57, 12); + BAssertUtil.validateError(negativeFile3, index++, "unreachable code", 60, 7); + BAssertUtil.validateError(negativeFile3, index++, "unreachable code", 72, 3); + BAssertUtil.validateError(negativeFile3, index++, "this function must return a result", 73, 1); + Assert.assertEquals(negativeFile3.getDiagnostics().length, index); + } + @Test(description = "Check on fail scope.") public void testNegative2() { - Assert.assertEquals(negativeFile2.getErrorCount(), 3); - BAssertUtil.validateError(negativeFile2, 0, "type 'string' not allowed here; " + + int index = 0; + Assert.assertEquals(negativeFile2.getErrorCount(), 5); + BAssertUtil.validateError(negativeFile2, index++, "type 'string' not allowed here; " + "expected an 'error' or a subtype of 'error'.", 6, 11); - BAssertUtil.validateError(negativeFile2, 1, "incompatible types: expected 'string', " + - "found 'error'", 8, 12); - BAssertUtil.validateError(negativeFile2, 2, "undefined symbol 'd'", 26, 12); + BAssertUtil.validateError(negativeFile2, index++, "incompatible error definition " + + "type: 'other' will not be matched to 'string'", 8, 12); + BAssertUtil.validateError(negativeFile2, index++, "incompatible types: expected " + + "'other', found 'string'", 8, 12); + BAssertUtil.validateError(negativeFile2, index++, "invalid error variable; expecting " + + "an error type but found 'string' in type definition", 8, 12); + BAssertUtil.validateError(negativeFile2, index++, "undefined symbol 'd'", 26, 12); } @AfterClass @@ -78,5 +95,6 @@ public void tearDown() { programFile = null; negativeFile1 = null; negativeFile2 = null; + negativeFile3 = null; } } diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/statements/dostatement/do-stmt-negative-1.bal b/tests/jballerina-unit-test/src/test/resources/test-src/statements/dostatement/do-stmt-negative-1.bal index 35d5c44c49e2..3d55e383edd2 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/statements/dostatement/do-stmt-negative-1.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/statements/dostatement/do-stmt-negative-1.bal @@ -6,21 +6,6 @@ type ErrorTypeB distinct error; const TYPE_B_ERROR_REASON = "TypeB_Error"; -function testUnreachableAfterFail () returns string { - string str = ""; - do { - error err = error("custom error", message = "error value"); - str += "Before failure throw"; - fail err; - str += "After failure throw"; - } - on fail error e { - str += "-> Error caught ! "; - } - str += "-> Execution continues..."; - return str; -} - function testIncompatibleErrorTypeOnFail () returns string { string str = ""; do { @@ -34,44 +19,6 @@ function testIncompatibleErrorTypeOnFail () returns string { return str; } -function testIgnoreReturnInOnFail () returns string { - string str = ""; - do { - str += "Before failure throw"; - fail error ErrorTypeA(TYPE_A_ERROR_REASON, message = "Error Type A"); - } - on fail ErrorTypeA e { - str += "-> Error caught ! "; - return str; - } - str += "-> Execution continues..."; - return str; -} - -function testUnreachableInOnFail () returns string { - string str = ""; - do { - str += "Before failure throw"; - fail error ErrorTypeA(TYPE_A_ERROR_REASON, message = "Error Type A"); - } - on fail ErrorTypeA e { - str += "-> Error caught ! "; - return str; - str += "-> After returning string"; - } - str += "-> Execution continues..."; - return str; -} - -function testReturnWitihinDo() returns string { - string str = ""; - do { - str = str + "do statement start"; - return str; - } - str = str + "do statemtnt finished"; -} - function testOnFailWithUnion () returns string { string str = ""; var getTypeAError = function () returns int|ErrorTypeA{ diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/statements/dostatement/do-stmt-negative-unreachable.bal b/tests/jballerina-unit-test/src/test/resources/test-src/statements/dostatement/do-stmt-negative-unreachable.bal new file mode 100644 index 000000000000..aeba1771f56e --- /dev/null +++ b/tests/jballerina-unit-test/src/test/resources/test-src/statements/dostatement/do-stmt-negative-unreachable.bal @@ -0,0 +1,73 @@ +type ErrorTypeA distinct error; + +const TYPE_A_ERROR_REASON = "TypeA_Error"; + +type ErrorTypeB distinct error; + +const TYPE_B_ERROR_REASON = "TypeB_Error"; + +function testUnreachableAfterFail () returns string { + string str = ""; + do { + error err = error("custom error", message = "error value"); + str += "Before failure throw"; + fail err; + str += "After failure throw"; + } + on fail error e { + str += "-> Error caught ! "; + } + str += "-> Execution continues..."; + return str; +} + +function testIncompatibleErrorTypeOnFail () returns string { + string str = ""; + do { + str += "Before failure throw"; + fail error ErrorTypeA(TYPE_A_ERROR_REASON, message = "Error Type A"); + } + on fail ErrorTypeA e { + str += "-> Error caught ! "; + } + str += "-> Execution continues..."; + return str; +} + +function testIgnoreReturnInOnFail () returns string { + string str = ""; + do { + str += "Before failure throw"; + fail error ErrorTypeA(TYPE_A_ERROR_REASON, message = "Error Type A"); + } + on fail ErrorTypeA e { + str += "-> Error caught ! "; + return str; + } + str += "-> Execution continues..."; + return str; +} + +function testUnreachableInOnFail () returns string { + string str = ""; + do { + str += "Before failure throw"; + fail error ErrorTypeA(TYPE_A_ERROR_REASON, message = "Error Type A"); + } + on fail ErrorTypeA e { + str += "-> Error caught ! "; + return str; + str += "-> After returning string"; + } + str += "-> Execution continues..."; + return str; +} + +function testReturnWitihinDo() returns string { + string str = ""; + do { + str = str + "do statement start"; + return str; + } + str = str + "do statemtnt finished"; +} From 0f1c4e5e9d5d086e45b67ca82182da8b4eaddf10 Mon Sep 17 00:00:00 2001 From: suleka96 Date: Wed, 24 May 2023 13:32:12 +0530 Subject: [PATCH 18/33] Update transaction test --- .../internal/parser/BallerinaParser.java | 17 ++- .../transaction_stmt_assert_09.json | 120 ++++++++++++++---- .../transaction_stmt_source_09.bal | 54 ++++---- 3 files changed, 132 insertions(+), 59 deletions(-) diff --git a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/BallerinaParser.java b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/BallerinaParser.java index 6dd5ae45cebf..25659b73de44 100644 --- a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/BallerinaParser.java +++ b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/BallerinaParser.java @@ -13854,16 +13854,25 @@ private STNode parseOnFailClause() { startContext(ParserRuleContext.ON_FAIL_CLAUSE); STNode onKeyword = parseOnKeyword(); STNode failKeyword = parseFailKeyword(); - STNode typedBindingPattern = STNodeFactory.createEmptyNode(); - if (isTypedBPPresent()) { - typedBindingPattern = parseTypedBindingPattern(); - } + STNode typedBindingPattern = parseOnfailOptionalBP(); STNode blockStatement = parseBlockNode(); endContext(); return STNodeFactory.createOnFailClauseNode(onKeyword, failKeyword, typedBindingPattern, blockStatement); } + private STNode parseOnfailOptionalBP() { + STToken nextToken = peek(); + if (nextToken.kind == SyntaxKind.OPEN_BRACE_TOKEN) { + return STNodeFactory.createEmptyNode(); + } else if (isTypeStartingToken(nextToken.kind)) { + return parseTypedBindingPattern(); + } else { + recover(nextToken, ParserRuleContext.ON_FAIL_OPTIONAL_BINDING_PATTERN); + return parseOnfailOptionalBP(); + } + } + /** * Parse typed binding pattern. *

diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_09.json b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_09.json index f83d4e10ea87..98010e85a46d 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_09.json +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_assert_09.json @@ -171,7 +171,13 @@ "children": [ { "kind": "IDENTIFIER_TOKEN", - "value": "err" + "value": "err", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] } ] }, @@ -215,6 +221,10 @@ "kind": "END_OF_LINE_MINUTIAE", "value": "\n" }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + }, { "kind": "INVALID_NODE_MINUTIAE", "invalidNode": { @@ -304,6 +314,10 @@ "kind": "END_OF_LINE_MINUTIAE", "value": "\n" }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + }, { "kind": "INVALID_NODE_MINUTIAE", "invalidNode": { @@ -354,7 +368,7 @@ }, { "kind": "WHITESPACE_MINUTIAE", - "value": " " + "value": " " } ], "trailingMinutiae": [ @@ -397,7 +411,7 @@ "leadingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", - "value": " " + "value": " " } ], "trailingMinutiae": [ @@ -462,7 +476,7 @@ "leadingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", - "value": " " + "value": " " } ], "trailingMinutiae": [ @@ -532,7 +546,13 @@ "children": [ { "kind": "IDENTIFIER_TOKEN", - "value": "err" + "value": "err", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] } ] }, @@ -576,6 +596,10 @@ "kind": "END_OF_LINE_MINUTIAE", "value": "\n" }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + }, { "kind": "INVALID_NODE_MINUTIAE", "invalidNode": { @@ -665,6 +689,10 @@ "kind": "END_OF_LINE_MINUTIAE", "value": "\n" }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + }, { "kind": "INVALID_NODE_MINUTIAE", "invalidNode": { @@ -715,7 +743,7 @@ }, { "kind": "WHITESPACE_MINUTIAE", - "value": " " + "value": " " } ], "trailingMinutiae": [ @@ -748,7 +776,7 @@ "leadingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", - "value": " " + "value": " " } ], "trailingMinutiae": [ @@ -781,7 +809,7 @@ "leadingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", - "value": " " + "value": " " } ], "trailingMinutiae": [ @@ -824,7 +852,7 @@ "leadingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", - "value": " " + "value": " " } ], "trailingMinutiae": [ @@ -865,7 +893,7 @@ "leadingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", - "value": " " + "value": " " } ], "trailingMinutiae": [ @@ -886,7 +914,7 @@ "leadingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", - "value": " " + "value": " " } ], "trailingMinutiae": [ @@ -907,7 +935,7 @@ "leadingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", - "value": " " + "value": " " } ], "trailingMinutiae": [ @@ -977,7 +1005,13 @@ "children": [ { "kind": "IDENTIFIER_TOKEN", - "value": "err" + "value": "err", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] } ] }, @@ -1021,6 +1055,10 @@ "kind": "END_OF_LINE_MINUTIAE", "value": "\n" }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + }, { "kind": "INVALID_NODE_MINUTIAE", "invalidNode": { @@ -1110,6 +1148,10 @@ "kind": "END_OF_LINE_MINUTIAE", "value": "\n" }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + }, { "kind": "INVALID_NODE_MINUTIAE", "invalidNode": { @@ -1160,7 +1202,7 @@ }, { "kind": "WHITESPACE_MINUTIAE", - "value": " " + "value": " " } ], "trailingMinutiae": [ @@ -1196,7 +1238,7 @@ "leadingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", - "value": " " + "value": " " } ], "trailingMinutiae": [ @@ -1232,7 +1274,7 @@ "leadingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", - "value": " " + "value": " " } ], "trailingMinutiae": [ @@ -1275,7 +1317,7 @@ "leadingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", - "value": " " + "value": " " } ], "trailingMinutiae": [ @@ -1316,7 +1358,7 @@ "leadingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", - "value": " " + "value": " " } ], "trailingMinutiae": [ @@ -1386,7 +1428,13 @@ "children": [ { "kind": "IDENTIFIER_TOKEN", - "value": "err" + "value": "err", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] } ] }, @@ -1430,6 +1478,10 @@ "kind": "END_OF_LINE_MINUTIAE", "value": "\n" }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + }, { "kind": "INVALID_NODE_MINUTIAE", "invalidNode": { @@ -1519,6 +1571,10 @@ "kind": "END_OF_LINE_MINUTIAE", "value": "\n" }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + }, { "kind": "INVALID_NODE_MINUTIAE", "invalidNode": { @@ -1561,7 +1617,7 @@ "leadingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", - "value": " " + "value": " " } ], "trailingMinutiae": [ @@ -1584,7 +1640,7 @@ "leadingMinutiae": [ { "kind": "WHITESPACE_MINUTIAE", - "value": " " + "value": " " } ], "trailingMinutiae": [ @@ -1654,7 +1710,13 @@ "children": [ { "kind": "IDENTIFIER_TOKEN", - "value": "err" + "value": "err", + "trailingMinutiae": [ + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + } + ] } ] }, @@ -1698,6 +1760,10 @@ "kind": "END_OF_LINE_MINUTIAE", "value": "\n" }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + }, { "kind": "INVALID_NODE_MINUTIAE", "invalidNode": { @@ -1787,6 +1853,10 @@ "kind": "END_OF_LINE_MINUTIAE", "value": "\n" }, + { + "kind": "WHITESPACE_MINUTIAE", + "value": " " + }, { "kind": "INVALID_NODE_MINUTIAE", "invalidNode": { @@ -1826,12 +1896,6 @@ }, { "kind": "CLOSE_BRACE_TOKEN", - "leadingMinutiae": [ - { - "kind": "WHITESPACE_MINUTIAE", - "value": " " - } - ], "trailingMinutiae": [ { "kind": "END_OF_LINE_MINUTIAE", diff --git a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_09.bal b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_09.bal index ea972ba03bab..8e8ce48bb83f 100644 --- a/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_09.bal +++ b/compiler/ballerina-parser/src/test/resources/statements/transaction-stmt/transaction_stmt_source_09.bal @@ -1,34 +1,34 @@ function foo() { transaction { - } on fail error error err{ -io:println(err); -} + } on fail error error err { + io:println(err); + } - transaction { - int a = 5; - } on fail error error err{ -io:println(err); -} + transaction { + int a = 5; + } on fail error error err { + io:println(err); + } + transaction { + transaction { transaction { - transaction { - transaction { - string b; - } - } - } on fail error error err{ -io:println(err); -} + string b; + } + } + } on fail error error err { + io:println(err); + } - transaction { - transaction { - transaction { - string b; - } on fail error error err{ -io:println(err); -} - } - } on fail error error err{ -io:println(err); + transaction { + transaction { + transaction { + string b; + } on fail error error err { + io:println(err); + } + } + } on fail error error err { + io:println(err); + } } - } From 29ba1588b4db763fb1fcc9229dd3941419b5f03b Mon Sep 17 00:00:00 2001 From: suleka96 Date: Fri, 26 May 2023 09:18:58 +0530 Subject: [PATCH 19/33] Remove helper method --- .../compiler/internal/parser/BallerinaParser.java | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/BallerinaParser.java b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/BallerinaParser.java index 25659b73de44..4c6382557051 100644 --- a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/BallerinaParser.java +++ b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/BallerinaParser.java @@ -13829,18 +13829,6 @@ private boolean isStatementStartingToken(SyntaxKind nodeKind) { } } - private boolean isTypedBPPresent() { - SyntaxKind nextTokenKind = peek().kind; - if (nextTokenKind == SyntaxKind.OPEN_BRACE_TOKEN) { - return false; - } else if (isTypeStartingToken(nextTokenKind)) { - return true; - } else { - recover(peek(), ParserRuleContext.ON_FAIL_OPTIONAL_BINDING_PATTERN); - return isTypedBPPresent(); - } - } - /** * Parse on fail clause. *

From 38e6d1fbd38cd1c92c219661a4c402fe32329414 Mon Sep 17 00:00:00 2001 From: MaryamZi Date: Tue, 18 Jul 2023 22:07:58 +0530 Subject: [PATCH 20/33] Address basic review suggestions --- .../compiler/desugar/Desugar.java | 21 ++++++----- .../semantics/analyzer/SemanticAnalyzer.java | 24 +++++++------ .../compiler/semantics/analyzer/Types.java | 36 +++++++++++-------- .../retrystmt/RetryStmtWithOnFailTest.java | 7 ++-- .../retry_on_fail_negative_unreachable.bal | 2 +- 5 files changed, 48 insertions(+), 42 deletions(-) diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java index 355b3a439e11..f79766e22a51 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java @@ -5185,23 +5185,22 @@ private BLangFail createOnFailInvocation(BLangOnFailClause onFailClause, BLangFa private void handleOnFailErrorVarDefNode(VariableDefinitionNode onFailVarDefNode, BLangBlockStmt onFailBody, BLangFail fail) { - if (onFailVarDefNode != null) { - BLangStatement stmt; - BLangVariable variableNode = (BLangVariable) onFailVarDefNode.getVariable(); - if (variableNode.getKind() == NodeKind.ERROR_VARIABLE) { - stmt = handleErrorBPInOnFail((BLangErrorVariable) variableNode, fail); - } else { - stmt = handleCaptureBPInOnFail((BLangSimpleVariable) variableNode, fail); - } - onFailBody.stmts.add(0, stmt); + if (onFailVarDefNode == null) { + return; } + + BLangVariable variableNode = (BLangVariable) onFailVarDefNode.getVariable(); + onFailBody.stmts.add(0, + variableNode.getKind() == NodeKind.ERROR_VARIABLE ? + handleErrorBPInOnFail((BLangErrorVariable) variableNode, fail) : + handleCaptureBPInOnFail((BLangSimpleVariable) variableNode, fail)); } - private BLangStatement handleErrorBPInOnFail (BLangErrorVariable varNode, BLangFail fail) { + private BLangStatement handleErrorBPInOnFail(BLangErrorVariable varNode, BLangFail fail) { BLangErrorVariable errorVar = ASTBuilderUtil.createErrorVariable(varNode.pos, varNode.getBType(), rewrite(fail.expr, env), varNode.message, varNode.cause, varNode.restDetail, varNode.detail); - BLangErrorVariableDef errorVarDef = ASTBuilderUtil.createErrorVariableDef(onFailClause.pos, errorVar); + BLangErrorVariableDef errorVarDef = ASTBuilderUtil.createErrorVariableDef(varNode.pos, errorVar); return rewrite(errorVarDef, env); } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SemanticAnalyzer.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SemanticAnalyzer.java index 2b0ca3bd293d..5975f7378418 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SemanticAnalyzer.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SemanticAnalyzer.java @@ -3868,7 +3868,7 @@ public void visit(BLangForeach foreach, AnalyzerData data) { data.env = blockEnv; analyzeStmt(foreach.body, data); - updateBreakMode(onFailExists, foreach.body, foreach.onFailClause, data); + analyzeOnFailClause(onFailExists, foreach.body, foreach.onFailClause, data); data.notCompletedNormally = false; data.breakFound = prevBreakFound; } @@ -3921,12 +3921,14 @@ public void visit(BLangOnFailClause onFailClause, AnalyzerData data) { analyzeStmt(onFailClause.body, data); } - private void updateBreakMode(boolean onFailExists, BLangBlockStmt blockStmt, BLangOnFailClause onFailClause, - AnalyzerData data) { - if (onFailExists) { - blockStmt.failureBreakMode = getPossibleBreakMode(!data.commonAnalyzerData.errorTypes.peek().isEmpty()); - this.analyzeNode(onFailClause, data); + private void analyzeOnFailClause(boolean onFailExists, BLangBlockStmt blockStmt, BLangOnFailClause onFailClause, + AnalyzerData data) { + if (!onFailExists) { + return; } + + blockStmt.failureBreakMode = getPossibleBreakMode(!data.commonAnalyzerData.errorTypes.peek().isEmpty()); + this.analyzeNode(onFailClause, data); } private BLangBlockStmt.FailureBreakMode getPossibleBreakMode(boolean possibleFailurePresent) { @@ -3972,7 +3974,7 @@ public void visit(BLangWhile whileNode, AnalyzerData data) { ConditionResolver.checkConstCondition(types, symTable, whileNode.expr) == symTable.trueType && !data.breakFound; data.breakFound = prevBreakFound; - updateBreakMode(onFailExists, whileNode.body, whileNode.onFailClause, data); + analyzeOnFailClause(onFailExists, whileNode.body, whileNode.onFailClause, data); } @Override @@ -3983,7 +3985,7 @@ public void visit(BLangDo doNode, AnalyzerData data) { data.commonAnalyzerData.errorTypes.push(new LinkedHashSet<>()); } analyzeStmt(doNode.body, data); - updateBreakMode(onFailExists, doNode.body, doNode.onFailClause, data); + analyzeOnFailClause(onFailExists, doNode.body, doNode.onFailClause, data); } @Override @@ -4009,7 +4011,7 @@ public void visit(BLangLock lockNode, AnalyzerData data) { data.commonAnalyzerData.errorTypes.push(new LinkedHashSet<>()); } analyzeStmt(lockNode.body, data); - updateBreakMode(onFailExists, lockNode.body, lockNode.onFailClause, data); + analyzeOnFailClause(onFailExists, lockNode.body, lockNode.onFailClause, data); } @Override @@ -4223,7 +4225,7 @@ public void visit(BLangTransaction transactionNode, AnalyzerData data) { data.commonAnalyzerData.errorTypes.push(new LinkedHashSet<>()); } analyzeStmt(transactionNode.transactionBody, data); - updateBreakMode(onFailExists, transactionNode.transactionBody, transactionNode.onFailClause, data); + analyzeOnFailClause(onFailExists, transactionNode.transactionBody, transactionNode.onFailClause, data); } @Override @@ -4255,7 +4257,7 @@ public void visit(BLangRetry retryNode, AnalyzerData data) { data.commonAnalyzerData.errorTypes.push(new LinkedHashSet<>()); } analyzeStmt(retryNode.retryBody, data); - updateBreakMode(onFailExists, retryNode.retryBody, retryNode.onFailClause, data); + analyzeOnFailClause(onFailExists, retryNode.retryBody, retryNode.onFailClause, data); } @Override diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/Types.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/Types.java index ca31943f4bee..1b1929979125 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/Types.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/Types.java @@ -266,26 +266,32 @@ public BType getErrorTypes(BType bType) { return getErrorTypes(Types.getReferredType(bType)); } if (tag == TypeTags.ERROR) { - errorType = bType; - } else if (tag == TypeTags.READONLY) { - errorType = symTable.errorType; - } else if (tag == TypeTags.UNION) { - LinkedHashSet errTypes = new LinkedHashSet<>(); - Set memTypes = ((BUnionType) bType).getMemberTypes(); - for (BType memType : memTypes) { - BType memErrType = getErrorTypes(memType); + return bType; + } - if (memErrType != symTable.semanticError) { - errTypes.add(memErrType); - } - } + if (tag == TypeTags.READONLY) { + return symTable.errorType; + } + + if (tag != TypeTags.UNION) { + return errorType; + } + + LinkedHashSet errTypes = new LinkedHashSet<>(); + Set memTypes = ((BUnionType) bType).getMemberTypes(); + for (BType memType : memTypes) { + BType memErrType = getErrorTypes(memType); - if (!errTypes.isEmpty()) { - errorType = errTypes.size() == 1 ? errTypes.iterator().next() : BUnionType.create(null, errTypes); + if (memErrType != symTable.semanticError) { + errTypes.add(memErrType); } } - return errorType; + if (errTypes.isEmpty()) { + return errorType; + } + + return errTypes.size() == 1 ? errTypes.iterator().next() : BUnionType.create(null, errTypes); } public BType checkType(Location pos, diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/retrystmt/RetryStmtWithOnFailTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/retrystmt/RetryStmtWithOnFailTest.java index 80af1463707d..85d226eb9c07 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/retrystmt/RetryStmtWithOnFailTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/retrystmt/RetryStmtWithOnFailTest.java @@ -32,14 +32,12 @@ */ public class RetryStmtWithOnFailTest { - private CompileResult programFile, negativeFile1, negativeFile2; + private CompileResult programFile, negativeFile1; @BeforeClass public void setup() { programFile = BCompileUtil.compile("test-src/statements/retrystmt/retry_stmt_with_on_fail.bal"); negativeFile1 = BCompileUtil.compile("test-src/statements/retrystmt/retry_on_fail_negative.bal"); - negativeFile2 = BCompileUtil.compile("test-src/statements/retrystmt/retry_on_fail_negative_unreachable.bal"); - } @Test @@ -96,6 +94,8 @@ public void testNegative1() { @Test(description = "Check unreachable statements.") public void testNegative2() { + CompileResult negativeFile2 = BCompileUtil.compile( + "test-src/statements/retrystmt/retry_on_fail_negative_unreachable.bal"); int index = 0; BAssertUtil.validateError(negativeFile2, index++, "unreachable code", 20, 12); BAssertUtil.validateWarning(negativeFile2, index++, "unused variable 'e'", 21, 16); @@ -111,6 +111,5 @@ public void testNegative2() { public void tearDown() { programFile = null; negativeFile1 = null; - negativeFile2 = null; } } diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/statements/retrystmt/retry_on_fail_negative_unreachable.bal b/tests/jballerina-unit-test/src/test/resources/test-src/statements/retrystmt/retry_on_fail_negative_unreachable.bal index 1a8fd4f143ce..fbeb6d39823d 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/statements/retrystmt/retry_on_fail_negative_unreachable.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/statements/retrystmt/retry_on_fail_negative_unreachable.bal @@ -70,7 +70,7 @@ function testNestedRetryWithLessOnFails () returns string { return str; } -function testOnFailWithUnion () returns string { +function testOnFailWithUnion() returns string { string str = ""; var getTypeBError = function () returns int|ErrorTypeB{ ErrorTypeB errorB = error ErrorTypeB(TYPE_B_ERROR_REASON, message = "Error Type B"); From 8597873eb8693e60c2f83bef5859da7885fa3155 Mon Sep 17 00:00:00 2001 From: MaryamZi Date: Wed, 19 Jul 2023 10:55:32 +0530 Subject: [PATCH 21/33] Fix analysis with checkpanic and remove duplicate error --- .../util/diagnostic/DiagnosticErrorCode.java | 1 - .../semantics/analyzer/SemanticAnalyzer.java | 7 ------- .../compiler/semantics/analyzer/TypeChecker.java | 2 +- .../src/main/resources/compiler.properties | 3 --- .../test/statements/dostatement/DoStmtsTest.java | 8 +------- .../matchstmt/MatchStatementOnFailTest.java | 6 ------ .../test/statements/onfail/OnFailClauseTest.java | 13 ------------- .../retrystmt/RetryStmtWithOnFailTest.java | 4 ---- .../statements/whilestatement/WhileStmtTest.java | 4 ---- 9 files changed, 2 insertions(+), 46 deletions(-) diff --git a/compiler/ballerina-lang/src/main/java/org/ballerinalang/util/diagnostic/DiagnosticErrorCode.java b/compiler/ballerina-lang/src/main/java/org/ballerinalang/util/diagnostic/DiagnosticErrorCode.java index c2f84eb061a4..de7d3248903a 100644 --- a/compiler/ballerina-lang/src/main/java/org/ballerinalang/util/diagnostic/DiagnosticErrorCode.java +++ b/compiler/ballerina-lang/src/main/java/org/ballerinalang/util/diagnostic/DiagnosticErrorCode.java @@ -468,7 +468,6 @@ public enum DiagnosticErrorCode implements DiagnosticCode { FAIL_EXPR_NO_MATCHING_ERROR_RETURN_IN_ENCL_INVOKABLE( "BCE3035", "fail.expr.no.matching.error.return.in.encl.invokable"), - INCOMPATIBLE_ON_FAIL_ERROR_DEFINITION("BCE3036", "on.fail.no.matching.error"), START_REQUIRE_INVOCATION("BCE3037", "start.require.invocation"), INVALID_EXPR_STATEMENT("BCE3038", "invalid.expr.statement"), diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SemanticAnalyzer.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SemanticAnalyzer.java index 5975f7378418..2f0c37b0e1a7 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SemanticAnalyzer.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SemanticAnalyzer.java @@ -3907,13 +3907,6 @@ public void visit(BLangOnFailClause onFailClause, AnalyzerData data) { dlog.error(onFailVarNode.pos, DiagnosticErrorCode.INVALID_TYPE_DEFINITION_FOR_ERROR_VAR, onFailVarNode.getBType()); } - - for (BType errorType : onFailErrTypes.peek()) { - if (onFailVarNode.getBType() != null && !types.isAssignable(errorType, onFailVarNode.getBType())) { - dlog.error(onFailVarNode.pos, DiagnosticErrorCode.INCOMPATIBLE_ON_FAIL_ERROR_DEFINITION, errorType, - onFailVarNode.getBType()); - } - } } onFailErrTypes.pop(); diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/TypeChecker.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/TypeChecker.java index 4b56009f7e8a..1a8e1eb0841f 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/TypeChecker.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/TypeChecker.java @@ -6139,7 +6139,7 @@ protected void visitCheckAndCheckPanicExpr(BLangCheckedExpr checkedExpr, Analyze errorTypes.add(exprType); } - if (!data.commonAnalyzerData.errorTypes.empty()) { + if (operatorType.equals(OperatorKind.CHECK.value()) && !data.commonAnalyzerData.errorTypes.empty()) { data.commonAnalyzerData.errorTypes.peek().add(types.getErrorTypes(checkedExpr.expr.getBType())); } diff --git a/compiler/ballerina-lang/src/main/resources/compiler.properties b/compiler/ballerina-lang/src/main/resources/compiler.properties index 7ea0711efb48..72b680d877d6 100644 --- a/compiler/ballerina-lang/src/main/resources/compiler.properties +++ b/compiler/ballerina-lang/src/main/resources/compiler.properties @@ -1135,9 +1135,6 @@ error.checked.expr.no.matching.error.return.in.encl.invokable=\ error.fail.expr.no.matching.error.return.in.encl.invokable=\ invalid usage of the ''fail'' expression operator: no matching error return type(s) in the enclosing invokable -error.on.fail.no.matching.error=\ - incompatible error definition type: ''{0}'' will not be matched to ''{1}'' - error.start.require.invocation=\ invalid async operation usage, require an invocation diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/dostatement/DoStmtsTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/dostatement/DoStmtsTest.java index 6625354f0609..f52446141989 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/dostatement/DoStmtsTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/dostatement/DoStmtsTest.java @@ -50,12 +50,8 @@ public void testOnFailStatement() { @Test(description = "Check not incompatible types.") public void testNegative1() { int index = 0; - BAssertUtil.validateError(negativeFile1, index++, "incompatible error definition type: " + - "'ErrorTypeA' will not be matched to 'ErrorTypeB'", 15, 12); BAssertUtil.validateError(negativeFile1, index++, "incompatible types: expected 'ErrorTypeA', " + "found 'ErrorTypeB'", 15, 12); - BAssertUtil.validateError(negativeFile1, index++, "incompatible error definition type: " + - "'ErrorTypeB' will not be matched to 'ErrorTypeA'", 37, 12); BAssertUtil.validateError(negativeFile1, index++, "incompatible types: expected " + "'(ErrorTypeA|ErrorTypeB)', found 'ErrorTypeA'", 37, 12); Assert.assertEquals(negativeFile1.getDiagnostics().length, index); @@ -78,16 +74,14 @@ public void testNegativeUnreachable() { @Test(description = "Check on fail scope.") public void testNegative2() { int index = 0; - Assert.assertEquals(negativeFile2.getErrorCount(), 5); BAssertUtil.validateError(negativeFile2, index++, "type 'string' not allowed here; " + "expected an 'error' or a subtype of 'error'.", 6, 11); - BAssertUtil.validateError(negativeFile2, index++, "incompatible error definition " + - "type: 'other' will not be matched to 'string'", 8, 12); BAssertUtil.validateError(negativeFile2, index++, "incompatible types: expected " + "'other', found 'string'", 8, 12); BAssertUtil.validateError(negativeFile2, index++, "invalid error variable; expecting " + "an error type but found 'string' in type definition", 8, 12); BAssertUtil.validateError(negativeFile2, index++, "undefined symbol 'd'", 26, 12); + Assert.assertEquals(negativeFile2.getErrorCount(), index); } @AfterClass diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/matchstmt/MatchStatementOnFailTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/matchstmt/MatchStatementOnFailTest.java index 080a4d748a6c..d2397c5171d6 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/matchstmt/MatchStatementOnFailTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/matchstmt/MatchStatementOnFailTest.java @@ -109,16 +109,10 @@ public Object[] onFailClauseWithErrorBPTestDataProvider() { @Test(description = "Check incompatible types.") public void testNegative1() { int i = 0; - BAssertUtil.validateError(resultNegative1, i++, "incompatible error definition type: " + - "'ErrorTypeA' will not be matched to 'ErrorTypeB'", 30, 15); BAssertUtil.validateError(resultNegative1, i++, "incompatible types: " + "expected 'ErrorTypeA', found 'ErrorTypeB'", 30, 15); - BAssertUtil.validateError(resultNegative1, i++, "incompatible error definition type: " + - "'ErrorTypeA' will not be matched to 'ErrorTypeB'", 59, 15); BAssertUtil.validateError(resultNegative1, i++, "incompatible types: " + "expected 'ErrorTypeA', found 'ErrorTypeB'", 59, 15); - BAssertUtil.validateError(resultNegative1, i++, "incompatible error definition type: " + - "'ErrorTypeA' will not be matched to 'ErrorTypeB'", 94, 15); BAssertUtil.validateError(resultNegative1, i++, "incompatible types: " + "expected '(ErrorTypeA|ErrorTypeB)', found 'ErrorTypeB'", 94, 15); BAssertUtil.validateError(resultNegative1, i++, "invalid error variable; expecting an error " + diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/onfail/OnFailClauseTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/onfail/OnFailClauseTest.java index dfed4e304043..82b8e7ac27b5 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/onfail/OnFailClauseTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/onfail/OnFailClauseTest.java @@ -53,37 +53,24 @@ public void testOnFailClauseNegativeCaseV1() { "test-src/statements/onfail/on-fail-clause-negative.bal"); int i = 0; BAssertUtil.validateError(negativeResult, i++, "undefined symbol 'i'", 22, 55); - BAssertUtil.validateError(negativeResult, i++, "incompatible error definition type: " + - "'SampleError' will not be matched to 'error'", 49, 15); BAssertUtil.validateError(negativeResult, i++, "incompatible types: expected 'SampleError', " + "found 'error'", 49, 15); - BAssertUtil.validateError(negativeResult, i++, "incompatible error definition type: " + - "'SampleError' will not be matched to 'SampleComplexError'", 56, 15); BAssertUtil.validateError(negativeResult, i++, "incompatible types: expected 'SampleError', " + "found 'SampleComplexError'", 56, 15); - BAssertUtil.validateError(negativeResult, i++, "incompatible error definition type: " + - "'SampleError' will not be matched to 'int'", 63, 15); BAssertUtil.validateError(negativeResult, i++, "incompatible types: expected 'SampleError', " + "found 'int'", 63, 15); BAssertUtil.validateError(negativeResult, i++, "invalid error variable; expecting an error " + "type but found 'int' in type definition", 63, 15); BAssertUtil.validateError(negativeResult, i++, "invalid error variable; expecting an error " + "type but found 'int' in type definition", 63, 15); - BAssertUtil.validateError(negativeResult, i++, "incompatible error definition type: " + - "'error' will not be matched to " + - "'error'", 71, 15); BAssertUtil.validateError(negativeResult, i++, "incompatible types: expected 'error', found 'error'", 71, 15); - BAssertUtil.validateError(negativeResult, i++, "incompatible error definition type: 'error' " + - "will not be matched to 'anydata'", 78, 15); BAssertUtil.validateError(negativeResult, i++, "incompatible types: expected 'error', " + "found 'anydata'", 78, 15); BAssertUtil.validateError(negativeResult, i++, "invalid error variable; expecting an error " + "type but found 'anydata' in type definition", 78, 15); BAssertUtil.validateError(negativeResult, i++, "invalid error variable; expecting an error " + "type but found 'anydata' in type definition", 78, 15); - BAssertUtil.validateError(negativeResult, i++, "incompatible error definition type: 'error' will" + - " not be matched to '[error]'", 85, 15); BAssertUtil.validateError(negativeResult, i++, "incompatible types: expected 'error', " + "found '[error]'", 85, 15); BAssertUtil.validateError(negativeResult, i++, "invalid binding pattern in 'on fail' clause: " + diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/retrystmt/RetryStmtWithOnFailTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/retrystmt/RetryStmtWithOnFailTest.java index 85d226eb9c07..7781cc6d1aa3 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/retrystmt/RetryStmtWithOnFailTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/retrystmt/RetryStmtWithOnFailTest.java @@ -79,12 +79,8 @@ public Object[] onFailClauseWithErrorBPTestDataProvider() { @Test(description = "Check not incompatible types.") public void testNegative1() { int index = 0; - BAssertUtil.validateError(negativeFile1, index++, "incompatible error definition type: " + - "'ErrorTypeA' will not be matched to 'ErrorTypeB'", 14, 14); BAssertUtil.validateError(negativeFile1, index++, "incompatible types: " + "expected 'ErrorTypeA', found 'ErrorTypeB'", 14, 14); - BAssertUtil.validateError(negativeFile1, index++, "incompatible error definition type: " + - "'ErrorTypeB' will not be matched to 'ErrorTypeA'", 36, 12); BAssertUtil.validateError(negativeFile1, index++, "incompatible types: " + "expected '(ErrorTypeA|ErrorTypeB)', found 'ErrorTypeA'", 36, 12); BAssertUtil.validateError(negativeFile1, index++, "invalid error variable; " + diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/whilestatement/WhileStmtTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/whilestatement/WhileStmtTest.java index 4d158ecdb502..401e4a497533 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/whilestatement/WhileStmtTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/whilestatement/WhileStmtTest.java @@ -249,12 +249,8 @@ public void testNestedWhileStmtLoopTerminationWithFail() { @Test(description = "Check incompatible types.") public void testNegative1() { int index = 0; - BAssertUtil.validateError(onfailNegativeCompileResult, index++, "incompatible error definition type: " + - "'ErrorTypeA' will not be matched to 'ErrorTypeB'", 17, 12); BAssertUtil.validateError(onfailNegativeCompileResult, index++, "incompatible types: expected 'ErrorTypeA', found 'ErrorTypeB'", 17, 12); - BAssertUtil.validateError(onfailNegativeCompileResult, index++, "incompatible error definition type: " + - "'ErrorTypeB' will not be matched to 'ErrorTypeA'", 41, 12); BAssertUtil.validateError(onfailNegativeCompileResult, index++, "incompatible types: expected '(ErrorTypeA|ErrorTypeB)', found 'ErrorTypeA'", 41, 12); BAssertUtil.validateError(onfailNegativeCompileResult, index++, "invalid error variable; " + From 261c4a10042763689e959bcb961f366e82229ada Mon Sep 17 00:00:00 2001 From: MaryamZi Date: Wed, 19 Jul 2023 13:14:27 +0530 Subject: [PATCH 22/33] Fix error variable symbol and update tests --- .../semantics/analyzer/DataflowAnalyzer.java | 9 +- .../semantics/analyzer/SemanticAnalyzer.java | 10 +- .../statements/foreach/foreach-on-fail.bal | 80 +++++++++-- .../retrystmt/RetryStmtWithOnFailTest.java | 13 +- .../retry_on_fail_negative_unreachable.bal | 135 +++++++++--------- 5 files changed, 149 insertions(+), 98 deletions(-) diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/DataflowAnalyzer.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/DataflowAnalyzer.java index e301b1e46e59..df70f1cab4b6 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/DataflowAnalyzer.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/DataflowAnalyzer.java @@ -2315,12 +2315,9 @@ public void visit(BLangRecordVariableDef bLangRecordVariableDef) { public void visit(BLangErrorVariable bLangErrorVariable) { analyzeNode(bLangErrorVariable.typeNode, env); populateUnusedVariableMapForNonSimpleBindingPatternVariables(this.unusedLocalVariables, bLangErrorVariable); - // When we visit this path from on fail clause the symbol is null - if (bLangErrorVariable.symbol != null) { - this.currDependentSymbolDeque.push(bLangErrorVariable.symbol); - analyzeNode(bLangErrorVariable.expr, env); - this.currDependentSymbolDeque.pop(); - } + this.currDependentSymbolDeque.push(bLangErrorVariable.symbol); + analyzeNode(bLangErrorVariable.expr, env); + this.currDependentSymbolDeque.pop(); } @Override diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SemanticAnalyzer.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SemanticAnalyzer.java index 2f0c37b0e1a7..fa44ea86c135 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SemanticAnalyzer.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SemanticAnalyzer.java @@ -3882,7 +3882,8 @@ public void visit(BLangOnFailClause onFailClause, AnalyzerData data) { if (onFailVarDefNode != null) { BLangVariable variableNode = (BLangVariable) onFailVarDefNode.getVariable(); - if (variableNode.getKind() != NodeKind.VARIABLE && variableNode.getKind() != NodeKind.ERROR_VARIABLE) { + NodeKind kind = variableNode.getKind(); + if (kind != NodeKind.VARIABLE && kind != NodeKind.ERROR_VARIABLE) { dlog.error(variableNode.pos, DiagnosticErrorCode.INVALID_BINDING_PATTERN_IN_ON_FAIL); } @@ -3907,6 +3908,13 @@ public void visit(BLangOnFailClause onFailClause, AnalyzerData data) { dlog.error(onFailVarNode.pos, DiagnosticErrorCode.INVALID_TYPE_DEFINITION_FOR_ERROR_VAR, onFailVarNode.getBType()); } + + if (kind == NodeKind.ERROR_VARIABLE) { + BLangErrorVariable var = (BLangErrorVariable) variableNode; + var.symbol = symbolEnter.defineVarSymbol(var.pos, var.flagSet, var.getBType(), + Names.fromString(anonModelHelper.getNextErrorVarKey( + onFailEnv.enclPkg.packageID)), onFailEnv, true); + } } onFailErrTypes.pop(); diff --git a/langlib/langlib-test/src/test/resources/test-src/statements/foreach/foreach-on-fail.bal b/langlib/langlib-test/src/test/resources/test-src/statements/foreach/foreach-on-fail.bal index 4dd0f1ffc8da..91da18dc0969 100644 --- a/langlib/langlib-test/src/test/resources/test-src/statements/foreach/foreach-on-fail.bal +++ b/langlib/langlib-test/src/test/resources/test-src/statements/foreach/foreach-on-fail.bal @@ -101,29 +101,30 @@ type SampleErrorData record {| type SampleError error; -string testMessage = ""; -int testErrorCode = 0; -string testErrorReason = ""; - function testSimpleOnFailWithErrorBP() { + string testMessage; foreach var i in data { fail error("error!"); } on fail error error(msg) { testMessage = msg; } - assertEquality(testMessage, "error!"); + assertEquality(testMessage, "error!"); } function testSimpleOnFailWithErrorBPWithVar() { + string testMessage; foreach var i in data { fail error("error!"); } on fail var error(msg) { testMessage = msg; } - assertEquality(testMessage, "error!"); + assertEquality(testMessage, "error!"); } function testOnFailWithErrorBPHavingUserDefinedTypeWithError() { + int testErrorCode; + string testMessage; + string testErrorReason; foreach var i in data { fail error SampleError("error!", code = 20, reason = "deadlock condition"); } on fail error error(msg, code = errCode, reason = errReason) { @@ -139,6 +140,9 @@ function testOnFailWithErrorBPHavingUserDefinedTypeWithError() { } function testOnFailWithErrorBPHavingUserDefinedTypeWithVar() { + string testMessage; + int testErrorCode; + string testErrorReason; foreach var i in data { fail error SampleError("error!", code = 20, reason = "deadlock condition"); } on fail var error(msg, code = errCode, reason = errReason) { @@ -154,6 +158,9 @@ function testOnFailWithErrorBPHavingUserDefinedTypeWithVar() { } function testOnFailWithErrorBPHavingUserDefinedType() { + string testMessage; + int testErrorCode; + string testErrorReason; foreach var i in data { fail error SampleError("error!", code = 20, reason = "deadlock condition"); } on fail SampleError error(msg, code = errCode, reason = errReason) { @@ -169,6 +176,9 @@ function testOnFailWithErrorBPHavingUserDefinedType() { } function testOnFailWithErrorBPHavingUserDefinedTypeWithErrDetail1() { + string testMessage; + int testErrorCode; + string testErrorReason; foreach var i in data { fail error SampleError("error!", code = 20, reason = "deadlock condition"); } on fail error error(msg, code = errCode, reason = errReason) { @@ -184,6 +194,7 @@ function testOnFailWithErrorBPHavingUserDefinedTypeWithErrDetail1() { } function testOnFailWithErrorBPHavingUserDefinedTypeWithErrDetail2() { + int testErrorCode; foreach var i in data { fail error SampleError("error!", code = 20, reason = "deadlock condition"); } on fail error error(code = errCode) { @@ -194,6 +205,8 @@ function testOnFailWithErrorBPHavingUserDefinedTypeWithErrDetail2() { } function testOnFailWithErrorBPHavingUserDefinedTypeWithErrDetail3() { + int testErrorCode; + string testErrorReason; foreach var i in data { fail error SampleError("error!", code = 20, reason = "deadlock condition"); } on fail error error(code = errCode, reason = errReason) { @@ -207,6 +220,7 @@ function testOnFailWithErrorBPHavingUserDefinedTypeWithErrDetail3() { } function testOnFailWithErrorBPHavingUserDefinedTypeWithErrDetail4() { + int testErrorCode; foreach var i in data { fail error SampleError("error!", code = 20, reason = "deadlock condition"); } on fail error error(code = errCode) { @@ -217,6 +231,7 @@ function testOnFailWithErrorBPHavingUserDefinedTypeWithErrDetail4() { } function testOnFailWithErrorBPHavingAnonDetailRecord() { + int testErrorCode; foreach var i in data { error errVar = error("error", code = 34); fail errVar; @@ -228,6 +243,8 @@ function testOnFailWithErrorBPHavingAnonDetailRecord() { } function testOnFailWithErrorBPHavingAnonDetailRecordWithVar() { + int testErrorCode; + string testErrorReason; foreach var i in data { error errVar = error("error", code = 34); fail errVar; @@ -242,6 +259,7 @@ function testOnFailWithErrorBPHavingAnonDetailRecordWithVar() { } function testOnFailWithErrorBPHavingAnonDetailRecordWithUnionType() { + int testErrorCode; foreach var i in data { error errVar = error("error", code = 34); fail errVar; @@ -261,13 +279,12 @@ type SampleComplexErrorData record {| type SampleComplexError error; -int testErrorPosRow = 0; -int testErrorPosCol = 0; -string testErrorMoreInfo = ""; - - function testOnFailWithErrorBPWithErrorArgsHavingBP1() { string causeMsg; + int testErrorCode; + int testErrorPosRow; + int testErrorPosCol; + string testErrorMoreInfo; foreach var i in data { fail error SampleComplexError("Transaction Failure", cause = error("Database Error"), code = 20, pos = [30, 45], infoDetails = {moreInfo: "deadlock condition"}); } on fail SampleComplexError error(_, cause = errCause, code = errCode, pos = errorPos, infoDetails = errInfo) { @@ -290,6 +307,11 @@ function testOnFailWithErrorBPWithErrorArgsHavingBP1() { } function testOnFailWithErrorBPWithErrorArgsHavingBP2() { + string testMessage; + int testErrorCode; + int testErrorPosRow; + int testErrorPosCol; + string testErrorMoreInfo; foreach var i in data { fail error SampleComplexError("Transaction Failure", cause = error("Database Error"), code = 20, pos = [30, 45], infoDetails = {moreInfo: "deadlock condition"}); } on fail SampleComplexError error(message, cause = error(msg), code = errCode, pos = errorPos, infoDetails = errInfo) { @@ -312,6 +334,11 @@ function testOnFailWithErrorBPWithErrorArgsHavingBP2() { } function testOnFailWithErrorBPWithErrorArgsHavingBP3() { + string testMessage; + int testErrorCode; + int testErrorPosRow; + int testErrorPosCol; + string testErrorMoreInfo; foreach var i in data { fail error SampleComplexError("Transaction Failure", cause = error("Database Error"), code = 20, pos = [30, 45], infoDetails = {moreInfo: "deadlock condition"}); } on fail SampleComplexError error(message, cause = error(msg), code = errCode, pos = [row, col], infoDetails = errInfo) { @@ -334,6 +361,11 @@ function testOnFailWithErrorBPWithErrorArgsHavingBP3() { } function testOnFailWithErrorBPWithErrorArgsHavingBP4() { + string testMessage; + int testErrorCode; + int testErrorPosRow; + int testErrorPosCol; + string testErrorMoreInfo; foreach var i in data { fail error SampleComplexError("Transaction Failure", cause = error("Database Error"), code = 20, pos = [30, 45], infoDetails = {moreInfo: "deadlock condition"}); } on fail SampleComplexError error(_, cause = error(msg), code = errCode, pos = [row, col], infoDetails = {moreInfo: errInfo}) { @@ -356,6 +388,11 @@ function testOnFailWithErrorBPWithErrorArgsHavingBP4() { } function testOnFailWithErrorBPWithErrorArgsHavingBP5() { + string testMessage; + int testErrorCode; + int testErrorPosRow; + int testErrorPosCol; + string testErrorMoreInfo; foreach var i in data { fail error SampleComplexError("Transaction Failure", cause = error("Database Error"), code = 20, pos = [30, 45], infoDetails = {moreInfo: "deadlock condition"}); } on fail var error(_, cause = error(msg), code = errCode, pos = [row, col], infoDetails = {moreInfo: errInfo}) { @@ -377,10 +414,12 @@ function testOnFailWithErrorBPWithErrorArgsHavingBP5() { assertEquality(testMessage is string, true); } -int testErrorCodeNested = 0; -string testMessageNested = ""; - function testNestedOnFailWithErrorBP() { + string testMessage = ""; + int testErrorCode = 0; + string testErrorReason = ""; + int testErrorCodeNested = 0; + string testMessageNested = ""; string testErrorReasonNested = ""; foreach var i in data { fail error SampleError("error!", code = 20, reason = "deadlock condition"); @@ -408,6 +447,13 @@ function testNestedOnFailWithErrorBP() { } function testNestedOnFailWithErrorBPWithErrorArgsHavingBP() { + string testMessage = ""; + int testErrorCode = 0; + int testErrorCodeNested = 0; + string testMessageNested = ""; + int testErrorPosRow = 0; + int testErrorPosCol = 0; + string testErrorMoreInfo = ""; foreach var i in data { fail error SampleError("error!", code = 20, reason = "deadlock condition"); } on fail var error(msg1, code = errCode1, reason = errReason1) { @@ -436,6 +482,9 @@ function testNestedOnFailWithErrorBPWithErrorArgsHavingBP() { } function testMultiLevelOnFailWithErrorBP() { + string testMessage; + int testErrorCode; + string testErrorReason; string str = ""; int[] level1dData = [2]; int[] nestedData = [1]; @@ -465,6 +514,9 @@ function testMultiLevelOnFailWithoutErrorInOneLevel() { string str = ""; int[] nestedData = [1]; int[] level1dData = [2]; + string testMessage; + int testErrorCode; + string testErrorReason; foreach var i in level1dData { foreach var j in nestedData { diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/retrystmt/RetryStmtWithOnFailTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/retrystmt/RetryStmtWithOnFailTest.java index 7781cc6d1aa3..108bbaeadf92 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/retrystmt/RetryStmtWithOnFailTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/retrystmt/RetryStmtWithOnFailTest.java @@ -93,13 +93,12 @@ public void testNegative2() { CompileResult negativeFile2 = BCompileUtil.compile( "test-src/statements/retrystmt/retry_on_fail_negative_unreachable.bal"); int index = 0; - BAssertUtil.validateError(negativeFile2, index++, "unreachable code", 20, 12); - BAssertUtil.validateWarning(negativeFile2, index++, "unused variable 'e'", 21, 16); - BAssertUtil.validateWarning(negativeFile2, index++, "unused variable 'e'", 33, 12); - BAssertUtil.validateError(negativeFile2, index++, "unreachable code", 36, 7); - BAssertUtil.validateWarning(negativeFile2, index++, "unused variable 'e'", 48, 12); - BAssertUtil.validateWarning(negativeFile2, index++, "unused variable 'e1'", 66, 12); - BAssertUtil.validateWarning(negativeFile2, index++, "unused variable 'resB'", 81, 6); + BAssertUtil.validateError(negativeFile2, index++, "unreachable code", 34, 9); + BAssertUtil.validateWarning(negativeFile2, index++, "unused variable 'e'", 35, 15); + BAssertUtil.validateWarning(negativeFile2, index++, "unused variable 'e'", 45, 15); + BAssertUtil.validateError(negativeFile2, index++, "unreachable code", 48, 9); + BAssertUtil.validateWarning(negativeFile2, index++, "unused variable 'e1'", 62, 15); + BAssertUtil.validateWarning(negativeFile2, index++, "unused variable 'resB'", 77, 9); Assert.assertEquals(negativeFile2.getDiagnostics().length, index); } diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/statements/retrystmt/retry_on_fail_negative_unreachable.bal b/tests/jballerina-unit-test/src/test/resources/test-src/statements/retrystmt/retry_on_fail_negative_unreachable.bal index fbeb6d39823d..5a634a3d35f3 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/statements/retrystmt/retry_on_fail_negative_unreachable.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/statements/retrystmt/retry_on_fail_negative_unreachable.bal @@ -1,3 +1,19 @@ +// Copyright (c) 2023 WSO2 LLC. (http://www.wso2.com). +// +// WSO2 LLC. licenses this file to you under the Apache License, +// Version 2.0 (the "License"); you may not use this file except +// in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + type ErrorTypeA distinct error; const TYPE_A_ERROR_REASON = "TypeA_Error"; @@ -6,84 +22,63 @@ const TYPE_B_ERROR_REASON = "TypeB_Error"; type ErrorTypeB distinct error; -function trxError() returns error { +function trxError() returns error { return error("TransactionError"); } -function testUnreachableAfterFail () returns string|error { - string str = ""; - int count = 0; - retry (3) { - count = count+1; - str += (" attempt " + count.toString() + ":error,"); - fail trxError(); - str += (" attempt "+ count.toString() + ":result returned end."); - } on fail error e { - return error("Custom Error"); - } - return str; -} - -function testUnreachableInOnFail () returns string { - string str = ""; - retry(3) { - str += "Before failure throw"; - fail error ErrorTypeA(TYPE_A_ERROR_REASON, message = "Error Type A"); - } - on fail ErrorTypeA e { - str += "-> Error caught ! "; - return str; - str += "-> After returning string"; - } - str += "-> Execution continues..."; - return str; +function testUnreachableAfterFail() returns error? { + int count = 0; + retry(3) { + count = count + 1; + fail trxError(); + count = count + 1; + } on fail error e { + return error("Custom Error"); + } } -function testIgnoreReturnInOnFail () returns string { - string str = ""; - retry(3) { - str += "Before failure throw"; - fail error ErrorTypeA(TYPE_A_ERROR_REASON, message = "Error Type A"); - } - on fail ErrorTypeA e { - str += "-> Error caught ! "; - return str; - } - str += "-> Execution continues..."; - return str; +function testUnreachableInOnFail() returns int? { + int count = 0; + retry(3) { + count += 1; + fail error ErrorTypeA(TYPE_A_ERROR_REASON, message = "Error Type A"); + } on fail ErrorTypeA e { + count += 1; + return count; + count += 1; + } + return (); } -function testNestedRetryWithLessOnFails () returns string { - string str = ""; - retry(3) { - str += "-> Before error 1 is thrown"; - retry(2) { - str += " -> Before error 2 is thrown"; - fail error ErrorTypeA(TYPE_A_ERROR_REASON, message = "Error Type A"); - } - fail error ErrorTypeA(TYPE_A_ERROR_REASON, message = "Error Type A"); - } - on fail error e1 { - str += " -> Error caught !"; - } - str += "-> Execution continues..."; - return str; +function testNestedRetryWithLessOnFails() returns string { + int count = 0; + retry(3) { + count += 1; + retry(2) { + count += 1; + fail error ErrorTypeA(TYPE_A_ERROR_REASON, message = "Error Type A"); + } + fail error ErrorTypeA(TYPE_A_ERROR_REASON, message = "Error Type A"); + } on fail error e1 { + count += 1; + } + count += 1; + return count.toString(); } function testOnFailWithUnion() returns string { - string str = ""; - var getTypeBError = function () returns int|ErrorTypeB{ - ErrorTypeB errorB = error ErrorTypeB(TYPE_B_ERROR_REASON, message = "Error Type B"); - return errorB; - }; - retry(3) { - str += "Before failure throw"; - int resB = check getTypeBError(); - } - on fail ErrorTypeB e { - str += "-> Error caught : "; - str = str.concat(e.message()); - } - str += "-> Execution continues..."; - return str; + string str = ""; + var getTypeBError = function() returns int|ErrorTypeB { + ErrorTypeB errorB = error ErrorTypeB(TYPE_B_ERROR_REASON, message = "Error Type B"); + return errorB; + }; + retry(3) { + str += "Before failure throw"; + int resB = check getTypeBError(); + } on fail ErrorTypeB e { + str += "-> Error caught : "; + str = str.concat(e.message()); + } + str += "-> Execution continues..."; + return str; } From 767d87cf14615d79e39fa84a0fcc807c5afa1096 Mon Sep 17 00:00:00 2001 From: MaryamZi Date: Thu, 20 Jul 2023 09:35:34 +0530 Subject: [PATCH 23/33] Refactor code --- .../semantics/analyzer/CodeAnalyzer.java | 16 +++++++--------- .../semantics/analyzer/SemanticAnalyzer.java | 9 +++++---- .../internal/parser/BallerinaParser.java | 2 +- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/CodeAnalyzer.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/CodeAnalyzer.java index f1e5b109f31a..f00148d412ec 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/CodeAnalyzer.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/CodeAnalyzer.java @@ -597,8 +597,7 @@ public void visit(BLangTransaction transactionNode, AnalyzerData data) { data.commitRollbackAllowed = prevCommitRollbackAllowed; data.returnWithinTransactionCheckStack.pop(); data.loopWithinTransactionCheckStack.pop(); - analyseOnFailAndUpdateBreakMode(onFailExists, transactionNode.transactionBody, - transactionNode.onFailClause, data); + analyseOnFailClause(onFailExists, transactionNode.onFailClause, data); } private void analyzeOnFailClause(BLangOnFailClause onFailClause, AnalyzerData data) { @@ -662,7 +661,7 @@ public void visit(BLangRetry retryNode, AnalyzerData data) { visitNode(retryNode.retrySpec, data); visitNode(retryNode.retryBody, data); data.failureHandled = failureHandled; - analyseOnFailAndUpdateBreakMode(onFailExists, retryNode.retryBody, retryNode.onFailClause, data); + analyseOnFailClause(onFailExists, retryNode.onFailClause, data); } @Override @@ -1482,7 +1481,7 @@ public void visit(BLangForeach foreach, AnalyzerData data) { data.failureHandled = failureHandled; data.loopWithinTransactionCheckStack.pop(); analyzeExpr(foreach.collection, data); - analyseOnFailAndUpdateBreakMode(onFailExists, body, foreach.onFailClause, data); + analyseOnFailClause(onFailExists, foreach.onFailClause, data); } @Override @@ -1502,7 +1501,7 @@ public void visit(BLangWhile whileNode, AnalyzerData data) { data.failureHandled = failureHandled; data.loopWithinTransactionCheckStack.pop(); analyzeExpr(whileNode.expr, data); - analyseOnFailAndUpdateBreakMode(onFailExists, whileNode.body, whileNode.onFailClause, data); + analyseOnFailClause(onFailExists, whileNode.onFailClause, data); } @Override @@ -1514,7 +1513,7 @@ public void visit(BLangDo doNode, AnalyzerData data) { } analyzeNode(doNode.body, data); data.failureHandled = failureHandled; - analyseOnFailAndUpdateBreakMode(onFailExists, doNode.body, doNode.onFailClause, data); + analyseOnFailClause(onFailExists, doNode.onFailClause, data); } @@ -1548,7 +1547,7 @@ public void visit(BLangLock lockNode, AnalyzerData data) { lockNode.body.stmts.forEach(e -> analyzeNode(e, data)); data.withinLockBlock = previousWithinLockBlock; data.failureHandled = failureHandled; - analyseOnFailAndUpdateBreakMode(onFailExists, lockNode.body, lockNode.onFailClause, data); + analyseOnFailClause(onFailExists, lockNode.onFailClause, data); } @Override @@ -3370,8 +3369,7 @@ public void visit(BLangOnFailClause onFailClause, AnalyzerData data) { data.failVisited = currentFailVisited; } - private void analyseOnFailAndUpdateBreakMode(boolean onFailExists, BLangBlockStmt blockStmt, - BLangOnFailClause onFailClause, AnalyzerData data) { + private void analyseOnFailClause(boolean onFailExists, BLangOnFailClause onFailClause, AnalyzerData data) { if (onFailExists) { analyzeOnFailClause(onFailClause, data); } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SemanticAnalyzer.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SemanticAnalyzer.java index fa44ea86c135..761089b2160b 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SemanticAnalyzer.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SemanticAnalyzer.java @@ -3910,10 +3910,11 @@ public void visit(BLangOnFailClause onFailClause, AnalyzerData data) { } if (kind == NodeKind.ERROR_VARIABLE) { - BLangErrorVariable var = (BLangErrorVariable) variableNode; - var.symbol = symbolEnter.defineVarSymbol(var.pos, var.flagSet, var.getBType(), - Names.fromString(anonModelHelper.getNextErrorVarKey( - onFailEnv.enclPkg.packageID)), onFailEnv, true); + BLangErrorVariable errorVar = (BLangErrorVariable) variableNode; + errorVar.symbol = symbolEnter.defineVarSymbol(errorVar.pos, errorVar.flagSet, errorVar.getBType(), + Names.fromString(anonModelHelper.getNextErrorVarKey( + onFailEnv.enclPkg.packageID)), + onFailEnv, true); } } diff --git a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/BallerinaParser.java b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/BallerinaParser.java index 811b9fc2a4c1..bfa1fc5b0669 100644 --- a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/BallerinaParser.java +++ b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/BallerinaParser.java @@ -14104,7 +14104,7 @@ private STNode parseOnFailClause() { private STNode parseOnfailOptionalBP() { STToken nextToken = peek(); if (nextToken.kind == SyntaxKind.OPEN_BRACE_TOKEN) { - return STNodeFactory.createEmptyNode(); + return STAbstractNodeFactory.createEmptyNode(); } else if (isTypeStartingToken(nextToken.kind)) { return parseTypedBindingPattern(); } else { From ebed5f64bde5437e8f2ace724fcb82bb076002d9 Mon Sep 17 00:00:00 2001 From: MaryamZi Date: Thu, 20 Jul 2023 11:19:40 +0530 Subject: [PATCH 24/33] Refactor code --- .../semantics/analyzer/SemanticAnalyzer.java | 33 +++++++++---------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SemanticAnalyzer.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SemanticAnalyzer.java index 761089b2160b..93f4c7eb5d97 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SemanticAnalyzer.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SemanticAnalyzer.java @@ -3888,20 +3888,18 @@ public void visit(BLangOnFailClause onFailClause, AnalyzerData data) { } BType failErrorType; - LinkedHashSet onFailErrType = onFailErrTypes.peek(); - boolean isVarTypeHardcoded = false; - if (onFailErrType.size() == 1) { - failErrorType = onFailErrType.iterator().next(); - } else if (onFailErrType.size() > 1) { - failErrorType = BUnionType.create(null, onFailErrType); + LinkedHashSet currentOnFailErrTypes = onFailErrTypes.peek(); + if (currentOnFailErrTypes.size() == 1) { + failErrorType = currentOnFailErrTypes.iterator().next(); + } else if (currentOnFailErrTypes.size() > 1) { + failErrorType = BUnionType.create(null, currentOnFailErrTypes); } else { - failErrorType = symTable.errorType; - isVarTypeHardcoded = true; + failErrorType = symTable.neverType; } // Check on-fail node's variables and set types. - handleForeachDefinitionVariables(onFailVarDefNode, failErrorType, - onFailClause.isDeclaredWithVar, isVarTypeHardcoded, onFailEnv); + handleForeachDefinitionVariables(onFailVarDefNode, failErrorType, onFailClause.isDeclaredWithVar, true, + onFailEnv); BLangVariable onFailVarNode = (BLangVariable) onFailVarDefNode.getVariable(); if (onFailVarNode.getBType() != null && !types.isAssignable(onFailVarNode.getBType(), symTable.errorType)) { @@ -4485,11 +4483,14 @@ private void checkAnnotConstantExpression(BLangExpression expression) { } private void handleForeachDefinitionVariables(VariableDefinitionNode variableDefinitionNode, BType varType, - boolean isDeclaredWithVar, boolean isVarTypeHardcoded, - SymbolEnv blockEnv) { + boolean isDeclaredWithVar, boolean onFail, SymbolEnv blockEnv) { BLangVariable variableNode = (BLangVariable) variableDefinitionNode.getVariable(); // Check whether the foreach node's variables are declared with var. if (isDeclaredWithVar) { + if (onFail && varType == symTable.neverType) { + varType = symTable.errorType; + } + // If the foreach node's variables are declared with var, type is `varType`. handleDeclaredVarInForeach(variableNode, varType, blockEnv); return; @@ -4498,13 +4499,11 @@ private void handleForeachDefinitionVariables(VariableDefinitionNode variableDef // Then, if the `varType` was hardcoded as `symtable.errorType`, we swap them and check whether `typeNodeType` // is assignable to `symtable.errorType` BType typeNodeType = symResolver.resolveTypeNode(variableNode.typeNode, blockEnv); - if (isVarTypeHardcoded) { - BType sourceType = varType; - varType = typeNodeType; - typeNodeType = sourceType; - } // Checking whether the RHS type is assignable to LHS type. if (types.isAssignable(varType, typeNodeType)) { + if (onFail && varType == symTable.neverType) { + varType = typeNodeType; + } // If assignable, we set types to the variables. handleDeclaredVarInForeach(variableNode, varType, blockEnv); return; From 9518f4f5414b894b19550dbd91f246772ee13b27 Mon Sep 17 00:00:00 2001 From: MaryamZi Date: Thu, 20 Jul 2023 11:48:29 +0530 Subject: [PATCH 25/33] Add tests --- .../dataflow/analysis/UnusedVariableTest.java | 7 +++++ .../statements/onfail/OnFailClauseTest.java | 7 +++++ .../unused_variable_analysis_test.bal | 16 +++++++++++ .../onfail/on-fail-clause-negative.bal | 17 ++++++++++++ .../statements/onfail/on-fail-clause.bal | 27 +++++++++++++++++++ 5 files changed, 74 insertions(+) diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/dataflow/analysis/UnusedVariableTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/dataflow/analysis/UnusedVariableTest.java index 6ef128910ed3..168bbd54b8fb 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/dataflow/analysis/UnusedVariableTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/dataflow/analysis/UnusedVariableTest.java @@ -110,6 +110,13 @@ public void testUnusedVariableAnalysis() { validateWarning(result, i++, getUnusedVariableWarning("k"), 405, 9); validateWarning(result, i++, getUnusedVariableWarning("k1"), 418, 5); validateWarning(result, i++, getUnusedVariableWarning("k2"), 421, 5); + validateWarning(result, i++, getUnusedVariableWarning("msg1"), 432, 29); + validateWarning(result, i++, getUnusedVariableWarning("errCode1"), 432, 42); + validateWarning(result, i++, getUnusedVariableWarning("errReason1"), 432, 61); + validateWarning(result, i++, getUnusedVariableWarning("msg2"), 436, 33); + validateWarning(result, i++, getUnusedVariableWarning("cause"), 436, 39); + validateWarning(result, i++, getUnusedVariableWarning("errCode2"), 436, 53); + validateWarning(result, i++, getUnusedVariableWarning("errReason2"), 436, 72); Assert.assertEquals(result.getWarnCount(), i); Assert.assertEquals(result.getErrorCount(), 0); } diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/onfail/OnFailClauseTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/onfail/OnFailClauseTest.java index 82b8e7ac27b5..653a6d3b91e8 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/onfail/OnFailClauseTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/onfail/OnFailClauseTest.java @@ -47,6 +47,11 @@ public void testOnFailClause() { BRunUtil.invoke(result, "testOnFailEdgeTestcases"); } + @Test + public void testOnFailWithCheckpanicOfDifferentErrorInDoClause() { + BRunUtil.invoke(result, "testOnFailWithCheckpanicOfDifferentErrorInDoClause"); + } + @Test(description = "Test on-fail clause negative cases - v1") public void testOnFailClauseNegativeCaseV1() { CompileResult negativeResult = BCompileUtil.compile( @@ -91,6 +96,8 @@ public void testOnFailClauseNegativeCaseV1() { "closed error detail type 'SampleComplexErrorData'", 114, 66); BAssertUtil.validateError(negativeResult, i++, "invalid error variable; expecting an error " + "type but found '(SampleComplexError|SampleError)' in type definition", 117, 15); + BAssertUtil.validateError(negativeResult, i++, "incompatible types: expected '(Error2|error)', found " + + "'Error1'", 132, 15); Assert.assertEquals(negativeResult.getErrorCount(), i); } diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/dataflow/analysis/unused_variable_analysis_test.bal b/tests/jballerina-unit-test/src/test/resources/test-src/dataflow/analysis/unused_variable_analysis_test.bal index 6c554c8b0cf5..db89ff244da6 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/dataflow/analysis/unused_variable_analysis_test.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/dataflow/analysis/unused_variable_analysis_test.bal @@ -420,3 +420,19 @@ function f19() { string n4 = "n4"; // used `n4` record {@annotOne {value: n4} string x;} k2 = {x: ""}; // unused `k2` } + +type SampleError error; + +function testUnusedVariablesInErrorBindingPatternsOfOnFailClauses() { + int i = 2; + + while i <= 2 { + do { + fail error SampleError("error!", code = 20, reason = "deadlock condition"); + } on fail var error(msg1, code = errCode1, reason = errReason1) { + + } + i = i + 1; + } on fail SampleError error(msg2, cause, code = errCode2, reason = errReason2) { + } +} diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/statements/onfail/on-fail-clause-negative.bal b/tests/jballerina-unit-test/src/test/resources/test-src/statements/onfail/on-fail-clause-negative.bal index 51355c30d19d..384b74391ca3 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/statements/onfail/on-fail-clause-negative.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/statements/onfail/on-fail-clause-negative.bal @@ -117,3 +117,20 @@ function testOnFailWithMultipleErrors() { } on fail var error(msg) { } } + +type Error1 distinct error; +type Error2 distinct error; + +function functionWithCheckpanicInDoClauseNegative() { + do { + _ = checkpanic fn(); + + Error2? x = (); + check x; + + fail error("Error"); + } on fail Error1 e { + } +} + +function fn() returns int|Error1 => 1; diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/statements/onfail/on-fail-clause.bal b/tests/jballerina-unit-test/src/test/resources/test-src/statements/onfail/on-fail-clause.bal index c105eec2be31..aed9e3746eef 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/statements/onfail/on-fail-clause.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/statements/onfail/on-fail-clause.bal @@ -979,6 +979,33 @@ function testMultiLevelOnFailWithoutErrorInOneLevel() { assertEquality(testErrorReason, "deadlock condition"); assertEquality(testMessage, "error!"); } + +type Error distinct error; + +function testOnFailWithCheckpanicOfDifferentErrorInDoClause() returns error? { + [int, Error]? res = functionWithCheckpanicInDoClause(1); + assertTrue(res !is ()); + [int, Error] [a, b] = checkpanic res.ensureType(); + assertEquality(1, a); + assertEquality("Error", b.message()); + + [int, Error]|error? errRes = trap functionWithCheckpanicInDoClause(2); + assertTrue(errRes is error && errRes !is Error); + error c = errRes; + assertEquality("error!", c.message()); +} + +function functionWithCheckpanicInDoClause(1|2 val) returns [int, Error]? { + do { + _ = checkpanic fn(val); + fail error Error("Error"); + } on fail Error e { + return [val, e]; + } + return (); +} + +function fn(1|2 val) returns int|error => val == 1 ? 1 : error("error!"); //------------------------------------------------------------------------------- type AssertionError error; From c2a827fdcdc0ddb652fd743dbe077138dfe59de5 Mon Sep 17 00:00:00 2001 From: Maryam Ziyad Date: Fri, 21 Jul 2023 09:37:31 +0530 Subject: [PATCH 26/33] Remove the feature branch from workflows --- .github/workflows/pull_request_ubuntu_build.yml | 1 - .github/workflows/pull_request_windows_build.yml | 1 - 2 files changed, 2 deletions(-) diff --git a/.github/workflows/pull_request_ubuntu_build.yml b/.github/workflows/pull_request_ubuntu_build.yml index aa9ce6184d07..f7a482c4feb0 100644 --- a/.github/workflows/pull_request_ubuntu_build.yml +++ b/.github/workflows/pull_request_ubuntu_build.yml @@ -15,7 +15,6 @@ on: - native-build - revert-client-decl-master - query-grouping-aggregation - - on-fail-error-bp jobs: ubuntu_build: diff --git a/.github/workflows/pull_request_windows_build.yml b/.github/workflows/pull_request_windows_build.yml index 1a1d14f36b7f..b35a61ec92b9 100644 --- a/.github/workflows/pull_request_windows_build.yml +++ b/.github/workflows/pull_request_windows_build.yml @@ -15,7 +15,6 @@ on: - native-build - revert-client-decl-master - query-grouping-aggregation - - on-fail-error-bp jobs: windows_build: From e45ac1a0824427b52fb31bd79d325775b43787c1 Mon Sep 17 00:00:00 2001 From: MaryamZi Date: Fri, 21 Jul 2023 10:34:50 +0530 Subject: [PATCH 27/33] Fix diagnostic ID --- .../org/ballerinalang/util/diagnostic/DiagnosticErrorCode.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/ballerina-lang/src/main/java/org/ballerinalang/util/diagnostic/DiagnosticErrorCode.java b/compiler/ballerina-lang/src/main/java/org/ballerinalang/util/diagnostic/DiagnosticErrorCode.java index de7d3248903a..b049c512fbc2 100644 --- a/compiler/ballerina-lang/src/main/java/org/ballerinalang/util/diagnostic/DiagnosticErrorCode.java +++ b/compiler/ballerina-lang/src/main/java/org/ballerinalang/util/diagnostic/DiagnosticErrorCode.java @@ -810,7 +810,7 @@ public enum DiagnosticErrorCode implements DiagnosticCode { INVALID_GROUPING_KEY_TYPE("BCE4051", "invalid.grouping.key.type"), NAMED_ARG_NOT_ALLOWED_FOR_REST_PARAM("BCE4052", "named.arg.not.allowed.for.rest.param"), - INVALID_BINDING_PATTERN_IN_ON_FAIL("BCS4053", "invalid.binding.pattern.in.on.fail") + INVALID_BINDING_PATTERN_IN_ON_FAIL("BCE4053", "invalid.binding.pattern.in.on.fail") ; private String diagnosticId; From 6abc96d96be76861060aa8a3e1fb3dbdfd2e4eaf Mon Sep 17 00:00:00 2001 From: MaryamZi Date: Mon, 24 Jul 2023 09:32:06 +0530 Subject: [PATCH 28/33] Add back original NodeFactory method and deprecate it --- .../compiler/syntax/tree/NodeFactory.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/NodeFactory.java b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/NodeFactory.java index a00f0fbe18a5..60c1b9632f4a 100644 --- a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/NodeFactory.java +++ b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/NodeFactory.java @@ -3081,6 +3081,23 @@ public static GroupingKeyVarDeclarationNode createGroupingKeyVarDeclarationNode( return stGroupingKeyVarDeclarationNode.createUnlinkedFacade(); } + /** + * @deprecated Use {@link #createOnFailClauseNode(Token, Token, TypedBindingPatternNode, BlockStatementNode)} + * instead. + */ + @Deprecated + public static OnFailClauseNode createOnFailClauseNode( + Token onKeyword, + Token failKeyword, + TypeDescriptorNode typeDescriptor, + IdentifierToken failErrorName, + BlockStatementNode blockStatement) { + return createOnFailClauseNode(onKeyword, failKeyword, + createTypedBindingPatternNode(typeDescriptor, + createCaptureBindingPatternNode(failErrorName)), + blockStatement); + } + public static OnFailClauseNode createOnFailClauseNode( Token onKeyword, Token failKeyword, From a44aaba9bec4d37e7d91dd8c2b23ac8921f944be Mon Sep 17 00:00:00 2001 From: MaryamZi Date: Mon, 24 Jul 2023 12:47:22 +0530 Subject: [PATCH 29/33] Refactor code --- .../semantics/analyzer/SemanticAnalyzer.java | 2 -- .../test/lock/LocksWithOnFailTest.java | 12 +++---- .../statements/dostatement/DoStmtsTest.java | 25 +++++++------ .../matchstmt/MatchStatementOnFailTest.java | 35 +++++++++---------- .../whilestatement/WhileStmtTest.java | 5 ++- 5 files changed, 35 insertions(+), 44 deletions(-) diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SemanticAnalyzer.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SemanticAnalyzer.java index 93f4c7eb5d97..cda29660e8c0 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SemanticAnalyzer.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SemanticAnalyzer.java @@ -4496,8 +4496,6 @@ private void handleForeachDefinitionVariables(VariableDefinitionNode variableDef return; } // If the type node is available, we get the type from it. - // Then, if the `varType` was hardcoded as `symtable.errorType`, we swap them and check whether `typeNodeType` - // is assignable to `symtable.errorType` BType typeNodeType = symResolver.resolveTypeNode(variableNode.typeNode, blockEnv); // Checking whether the RHS type is assignable to LHS type. if (types.isAssignable(varType, typeNodeType)) { diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/lock/LocksWithOnFailTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/lock/LocksWithOnFailTest.java index 76247449b2df..9d6a3a484f03 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/lock/LocksWithOnFailTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/lock/LocksWithOnFailTest.java @@ -36,18 +36,16 @@ /** * Tests for Ballerina locks with on fail clause. - * + * * @since 0.961.0 */ public class LocksWithOnFailTest { - private CompileResult compileResult, compileResultNegative; + private CompileResult compileResult; @BeforeClass public void setup() { - compileResult = BCompileUtil.compile("test-src/lock/lock-on-fail.bal"); - compileResultNegative = BCompileUtil.compile("test-src/lock/lock-on-fail-negative.bal"); } @Test(description = "Tests lock within a lock") @@ -108,15 +106,15 @@ public Object[] onFailClauseWithErrorBPTestDataProvider() { @Test(description = "Check incompatible types.") public void testNegative() { + CompileResult resultNegative = BCompileUtil.compile("test-src/lock/lock-on-fail-negative.bal"); int i = 0; - BAssertUtil.validateError(compileResultNegative, i++, "invalid error variable; expecting an " + + BAssertUtil.validateError(resultNegative, i++, "invalid error variable; expecting an " + "error type but found '(SampleComplexError|SampleError)' in type definition", 39, 15); - Assert.assertEquals(compileResultNegative.getErrorCount(), i); + Assert.assertEquals(resultNegative.getErrorCount(), i); } @AfterClass public void tearDown() { compileResult = null; - compileResultNegative = null; } } diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/dostatement/DoStmtsTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/dostatement/DoStmtsTest.java index f52446141989..44155d88cf67 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/dostatement/DoStmtsTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/dostatement/DoStmtsTest.java @@ -31,15 +31,13 @@ */ public class DoStmtsTest { - private CompileResult programFile, negativeFile1, negativeFile2, negativeFile3; + private CompileResult programFile, negativeFile1, negativeFile2; @BeforeClass public void setup() { programFile = BCompileUtil.compile("test-src/statements/dostatement/do-stmt.bal"); negativeFile1 = BCompileUtil.compile("test-src/statements/dostatement/do-stmt-negative-1.bal"); negativeFile2 = BCompileUtil.compile("test-src/statements/dostatement/do-stmt-negative-2.bal"); - negativeFile3 = - BCompileUtil.compile("test-src/statements/dostatement/do-stmt-negative-unreachable.bal"); } @Test @@ -59,16 +57,18 @@ public void testNegative1() { @Test(description = "Check unreachable statements.") public void testNegativeUnreachable() { + CompileResult negativeRes = + BCompileUtil.compile("test-src/statements/dostatement/do-stmt-negative-unreachable.bal"); int index = 0; - BAssertUtil.validateError(negativeFile3, index++, "unreachable code", 15, 6); - BAssertUtil.validateWarning(negativeFile3, index++, "unused variable 'e'", 17, 12); - BAssertUtil.validateWarning(negativeFile3, index++, "unused variable 'e'", 30, 12); - BAssertUtil.validateWarning(negativeFile3, index++, "unused variable 'e'", 43, 12); - BAssertUtil.validateWarning(negativeFile3, index++, "unused variable 'e'", 57, 12); - BAssertUtil.validateError(negativeFile3, index++, "unreachable code", 60, 7); - BAssertUtil.validateError(negativeFile3, index++, "unreachable code", 72, 3); - BAssertUtil.validateError(negativeFile3, index++, "this function must return a result", 73, 1); - Assert.assertEquals(negativeFile3.getDiagnostics().length, index); + BAssertUtil.validateError(negativeRes, index++, "unreachable code", 15, 6); + BAssertUtil.validateWarning(negativeRes, index++, "unused variable 'e'", 17, 12); + BAssertUtil.validateWarning(negativeRes, index++, "unused variable 'e'", 30, 12); + BAssertUtil.validateWarning(negativeRes, index++, "unused variable 'e'", 43, 12); + BAssertUtil.validateWarning(negativeRes, index++, "unused variable 'e'", 57, 12); + BAssertUtil.validateError(negativeRes, index++, "unreachable code", 60, 7); + BAssertUtil.validateError(negativeRes, index++, "unreachable code", 72, 3); + BAssertUtil.validateError(negativeRes, index++, "this function must return a result", 73, 1); + Assert.assertEquals(negativeRes.getDiagnostics().length, index); } @Test(description = "Check on fail scope.") @@ -89,6 +89,5 @@ public void tearDown() { programFile = null; negativeFile1 = null; negativeFile2 = null; - negativeFile3 = null; } } diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/matchstmt/MatchStatementOnFailTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/matchstmt/MatchStatementOnFailTest.java index d2397c5171d6..86c8a1ba5f66 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/matchstmt/MatchStatementOnFailTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/matchstmt/MatchStatementOnFailTest.java @@ -34,16 +34,11 @@ */ public class MatchStatementOnFailTest { - private CompileResult result, resultNegative1, resultNegative2; + private CompileResult result; @BeforeClass public void setup() { result = BCompileUtil.compile("test-src/statements/matchstmt/matchstmt_on_fail.bal"); - resultNegative1 = - BCompileUtil.compile("test-src/statements/matchstmt/matchstmt_on_fail_negative.bal"); - resultNegative2 = - BCompileUtil.compile("test-src/statements/matchstmt/matchstmt_on_fail" + - "_negative_unreachable.bal"); } @Test(description = "Test basics of static pattern match statement with fail statement") @@ -108,33 +103,35 @@ public Object[] onFailClauseWithErrorBPTestDataProvider() { @Test(description = "Check incompatible types.") public void testNegative1() { + CompileResult resultNegative = + BCompileUtil.compile("test-src/statements/matchstmt/matchstmt_on_fail_negative.bal"); int i = 0; - BAssertUtil.validateError(resultNegative1, i++, "incompatible types: " + + BAssertUtil.validateError(resultNegative, i++, "incompatible types: " + "expected 'ErrorTypeA', found 'ErrorTypeB'", 30, 15); - BAssertUtil.validateError(resultNegative1, i++, "incompatible types: " + + BAssertUtil.validateError(resultNegative, i++, "incompatible types: " + "expected 'ErrorTypeA', found 'ErrorTypeB'", 59, 15); - BAssertUtil.validateError(resultNegative1, i++, "incompatible types: " + + BAssertUtil.validateError(resultNegative, i++, "incompatible types: " + "expected '(ErrorTypeA|ErrorTypeB)', found 'ErrorTypeB'", 94, 15); - BAssertUtil.validateError(resultNegative1, i++, "invalid error variable; expecting an error " + + BAssertUtil.validateError(resultNegative, i++, "invalid error variable; expecting an error " + "type but found '(SampleComplexError|SampleError)' in type definition", 125, 15); - Assert.assertEquals(resultNegative1.getErrorCount(), i); + Assert.assertEquals(resultNegative.getErrorCount(), i); } @Test(description = "Check reachable statements.") public void testNegative2() { + CompileResult resultNegative = + BCompileUtil.compile("test-src/statements/matchstmt/matchstmt_on_fail_negative_unreachable.bal"); int i = -1; - BAssertUtil.validateError(resultNegative2, ++i, "unreachable code", 29, 14); - BAssertUtil.validateWarning(resultNegative2, ++i, "unused variable 'e'", 31, 15); - BAssertUtil.validateWarning(resultNegative2, ++i, "unused variable 'err'", 57, 14); - BAssertUtil.validateWarning(resultNegative2, ++i, "unused variable 'e'", 60, 15); - BAssertUtil.validateError(resultNegative2, ++i, "unreachable code", 62, 9); - Assert.assertEquals(resultNegative2.getDiagnostics().length, i + 1); + BAssertUtil.validateError(resultNegative, ++i, "unreachable code", 29, 14); + BAssertUtil.validateWarning(resultNegative, ++i, "unused variable 'e'", 31, 15); + BAssertUtil.validateWarning(resultNegative, ++i, "unused variable 'err'", 57, 14); + BAssertUtil.validateWarning(resultNegative, ++i, "unused variable 'e'", 60, 15); + BAssertUtil.validateError(resultNegative, ++i, "unreachable code", 62, 9); + Assert.assertEquals(resultNegative.getDiagnostics().length, i + 1); } @AfterClass public void tearDown() { result = null; - resultNegative1 = null; - resultNegative2 = null; } } diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/whilestatement/WhileStmtTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/whilestatement/WhileStmtTest.java index 401e4a497533..18a566b15d5b 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/whilestatement/WhileStmtTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/whilestatement/WhileStmtTest.java @@ -39,7 +39,6 @@ public class WhileStmtTest { private CompileResult negativeCompileResult; private CompileResult onfailCompileResult; private CompileResult onfailNegativeCompileResult; - private CompileResult onfailNegativeUnreachableCompileResult; @BeforeClass public void setup() { @@ -48,8 +47,6 @@ public void setup() { onfailCompileResult = BCompileUtil.compile("test-src/statements/whilestatement/while-stmt-on-fail.bal"); onfailNegativeCompileResult = BCompileUtil.compile( "test-src/statements/whilestatement/while-stmt-on-fail-negative.bal"); - onfailNegativeUnreachableCompileResult = BCompileUtil.compile( - "test-src/statements/whilestatement/while-stmt-on-fail-negative-reachability.bal"); } @Test(description = "Test while loop with a condition which evaluates to true") @@ -260,6 +257,8 @@ public void testNegative1() { @Test(description = "Check unreachable statements.") public void testNegative2() { + CompileResult onfailNegativeUnreachableCompileResult = BCompileUtil.compile( + "test-src/statements/whilestatement/while-stmt-on-fail-negative-reachability.bal"); int index = 0; BAssertUtil.validateError(onfailNegativeUnreachableCompileResult, index++, "unreachable code", 17, 6); From 389b4116584bd54e137fb6ddd6d5b3c473c712ca Mon Sep 17 00:00:00 2001 From: MaryamZi Date: Wed, 16 Aug 2023 11:38:16 +0530 Subject: [PATCH 30/33] Update now invalid test --- .../test-src/statements/foreach/foreach-on-fail.bal | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/langlib/langlib-test/src/test/resources/test-src/statements/foreach/foreach-on-fail.bal b/langlib/langlib-test/src/test/resources/test-src/statements/foreach/foreach-on-fail.bal index 91da18dc0969..45207c274a3f 100644 --- a/langlib/langlib-test/src/test/resources/test-src/statements/foreach/foreach-on-fail.bal +++ b/langlib/langlib-test/src/test/resources/test-src/statements/foreach/foreach-on-fail.bal @@ -482,9 +482,9 @@ function testNestedOnFailWithErrorBPWithErrorArgsHavingBP() { } function testMultiLevelOnFailWithErrorBP() { - string testMessage; - int testErrorCode; - string testErrorReason; + string? testMessage = (); + int? testErrorCode = (); + string? testErrorReason = (); string str = ""; int[] level1dData = [2]; int[] nestedData = [1]; @@ -514,9 +514,9 @@ function testMultiLevelOnFailWithoutErrorInOneLevel() { string str = ""; int[] nestedData = [1]; int[] level1dData = [2]; - string testMessage; - int testErrorCode; - string testErrorReason; + string? testMessage = (); + int? testErrorCode = (); + string? testErrorReason = (); foreach var i in level1dData { foreach var j in nestedData { From 222f18a1126ec66729230c50cdf73bad3b6d46c8 Mon Sep 17 00:00:00 2001 From: MaryamZi Date: Tue, 24 Oct 2023 10:54:51 +0530 Subject: [PATCH 31/33] Address review suggestion --- .../compiler/semantics/analyzer/TypeChecker.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/TypeChecker.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/TypeChecker.java index cdbb78f37b35..d9aace10aac3 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/TypeChecker.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/TypeChecker.java @@ -6149,7 +6149,9 @@ public void visit(BLangOnFailClause onFailClause, AnalyzerData data) { } protected void visitCheckAndCheckPanicExpr(BLangCheckedExpr checkedExpr, AnalyzerData data) { - String operatorType = checkedExpr.getKind() == NodeKind.CHECK_EXPR ? "check" : "checkpanic"; + OperatorKind operatorKind = checkedExpr.getKind() == NodeKind.CHECK_EXPR ? + OperatorKind.CHECK : + OperatorKind.CHECK_PANIC; BLangExpression exprWithCheckingKeyword = checkedExpr.expr; boolean firstVisit = exprWithCheckingKeyword.getBType() == null; @@ -6193,7 +6195,7 @@ protected void visitCheckAndCheckPanicExpr(BLangCheckedExpr checkedExpr, Analyze } else if (exprType != symTable.semanticError) { dlog.warning(checkedExpr.expr.pos, DiagnosticWarningCode.CHECKED_EXPR_INVALID_USAGE_NO_ERROR_TYPE_IN_RHS, - operatorType); + operatorKind.value()); checkedExpr.isRedundantChecking = true; data.resultType = checkedExpr.expr.getBType(); @@ -6224,7 +6226,7 @@ protected void visitCheckAndCheckPanicExpr(BLangCheckedExpr checkedExpr, Analyze errorTypes.add(exprType); } - if (operatorType.equals(OperatorKind.CHECK.value()) && !data.commonAnalyzerData.errorTypes.empty()) { + if (operatorKind == OperatorKind.CHECK && !data.commonAnalyzerData.errorTypes.empty()) { data.commonAnalyzerData.errorTypes.peek().add(types.getErrorTypes(checkedExpr.expr.getBType())); } @@ -6233,7 +6235,7 @@ protected void visitCheckAndCheckPanicExpr(BLangCheckedExpr checkedExpr, Analyze if (errorTypes.isEmpty()) { // No member types in this union is equivalent to the error type dlog.warning(checkedExpr.expr.pos, - DiagnosticWarningCode.CHECKED_EXPR_INVALID_USAGE_NO_ERROR_TYPE_IN_RHS, operatorType); + DiagnosticWarningCode.CHECKED_EXPR_INVALID_USAGE_NO_ERROR_TYPE_IN_RHS, operatorKind.value()); checkedExpr.isRedundantChecking = true; // Reset impConversionExpr as it was previously based on default error added union type From bbbbf352598acc874b7b3bf4af9c7d99c8fb1296 Mon Sep 17 00:00:00 2001 From: MaryamZi Date: Fri, 17 Nov 2023 15:21:28 +0530 Subject: [PATCH 32/33] Improve errors --- .../semantics/analyzer/SemanticAnalyzer.java | 18 +++++--- .../src/main/resources/compiler.properties | 2 +- .../statements/dostatement/DoStmtsTest.java | 2 +- .../test/statements/fail/FailStmtTest.java | 2 +- .../statements/onfail/OnFailClauseTest.java | 7 +++ .../test/types/stream/BStreamValueTest.java | 2 +- .../onfail/on-fail-clause-negative.bal | 43 +++++++++++++++++++ 7 files changed, 67 insertions(+), 9 deletions(-) diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SemanticAnalyzer.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SemanticAnalyzer.java index 67f01278ceb9..8d0def98b32d 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SemanticAnalyzer.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SemanticAnalyzer.java @@ -2103,7 +2103,9 @@ void handleDeclaredVarInForeach(BLangVariable variable, BType rhsType, SymbolEnv BLangErrorVariable errorVariable = (BLangErrorVariable) variable; errorVariable.setBType(rhsType); if (TypeTags.ERROR != referredRhsType.tag) { - dlog.error(variable.pos, DiagnosticErrorCode.INVALID_TYPE_DEFINITION_FOR_ERROR_VAR, rhsType); + if (referredRhsType != symTable.semanticError) { + dlog.error(variable.pos, DiagnosticErrorCode.INVALID_TYPE_DEFINITION_FOR_ERROR_VAR, rhsType); + } recursivelyDefineVariables(errorVariable, blockEnv); return; } @@ -3883,9 +3885,12 @@ public void visit(BLangOnFailClause onFailClause, AnalyzerData data) { onFailEnv); BLangVariable onFailVarNode = (BLangVariable) onFailVarDefNode.getVariable(); - if (onFailVarNode.getBType() != null && !types.isAssignable(onFailVarNode.getBType(), symTable.errorType)) { + BType onFailVarNodeBType = onFailVarNode.getBType(); + if (onFailVarNodeBType != null && + onFailVarNodeBType != symTable.semanticError && + !types.isAssignable(onFailVarNodeBType, symTable.errorType)) { dlog.error(onFailVarNode.pos, DiagnosticErrorCode.INVALID_TYPE_DEFINITION_FOR_ERROR_VAR, - onFailVarNode.getBType()); + onFailVarNodeBType); } if (kind == NodeKind.ERROR_VARIABLE) { @@ -3975,9 +3980,12 @@ public void visit(BLangFail failNode, AnalyzerData data) { BType errorExpressionType = typeChecker.checkExpr(errorExpression, data.env, data.prevEnvs, data.commonAnalyzerData); if (!data.commonAnalyzerData.errorTypes.empty()) { - data.commonAnalyzerData.errorTypes.peek().add(types.getErrorTypes(failNode.expr.getBType())); + BType failExprType = failNode.expr.getBType(); + if (failExprType != symTable.semanticError) { + data.commonAnalyzerData.errorTypes.peek().add(types.getErrorTypes(failExprType)); + } } - if (errorExpressionType == symTable.semanticError || + if (errorExpressionType != symTable.semanticError && !types.isSubTypeOfBaseType(errorExpressionType, symTable.errorType.tag)) { dlog.error(errorExpression.pos, DiagnosticErrorCode.ERROR_TYPE_EXPECTED, errorExpressionType); } diff --git a/compiler/ballerina-lang/src/main/resources/compiler.properties b/compiler/ballerina-lang/src/main/resources/compiler.properties index 638a94c66457..76166a081ed6 100644 --- a/compiler/ballerina-lang/src/main/resources/compiler.properties +++ b/compiler/ballerina-lang/src/main/resources/compiler.properties @@ -1349,7 +1349,7 @@ error.order.by.not.supported=\ order by not supported for complex type fields, order key should belong to a basic type error.error.type.expected = \ - type ''{0}'' not allowed here; expected an ''error'' or a subtype of ''error''. + type ''{0}'' not allowed here; expected an ''error'' or a subtype of ''error'' error.invalid.table.constraint.subtype = \ invalid constraint type. expected subtype of ''map'' but found ''{0}'' diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/dostatement/DoStmtsTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/dostatement/DoStmtsTest.java index 44155d88cf67..1bba7419d44d 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/dostatement/DoStmtsTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/dostatement/DoStmtsTest.java @@ -75,7 +75,7 @@ public void testNegativeUnreachable() { public void testNegative2() { int index = 0; BAssertUtil.validateError(negativeFile2, index++, "type 'string' not allowed here; " + - "expected an 'error' or a subtype of 'error'.", 6, 11); + "expected an 'error' or a subtype of 'error'", 6, 11); BAssertUtil.validateError(negativeFile2, index++, "incompatible types: expected " + "'other', found 'string'", 8, 12); BAssertUtil.validateError(negativeFile2, index++, "invalid error variable; expecting " + diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/fail/FailStmtTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/fail/FailStmtTest.java index 7fb94fec069d..bf7bb43d8bfd 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/fail/FailStmtTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/fail/FailStmtTest.java @@ -60,7 +60,7 @@ public void testFailActionNegative() { int index = 0; validateError(negativeResult, index++, - "type '(error|int)' not allowed here; expected an 'error' or a subtype of 'error'.", + "type '(error|int)' not allowed here; expected an 'error' or a subtype of 'error'", 5, 10); } diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/onfail/OnFailClauseTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/onfail/OnFailClauseTest.java index e028fb8a99cc..c0cdea71cbe0 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/onfail/OnFailClauseTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/onfail/OnFailClauseTest.java @@ -98,6 +98,13 @@ public void testOnFailClauseNegativeCaseV1() { "type but found '(SampleComplexError|SampleError)' in type definition", 117, 15); BAssertUtil.validateError(negativeResult, i++, "incompatible types: expected '(Error2|error)', found " + "'Error1'", 132, 15); + BAssertUtil.validateError(negativeResult, i++, "type 'int?' not allowed here; expected an 'error' or a " + + "subtype of 'error'", 141, 14); + BAssertUtil.validateError(negativeResult, i++, "type 'int?' not allowed here; expected an 'error' or a " + + "subtype of 'error'", 150, 14); + BAssertUtil.validateError(negativeResult, i++, "undefined symbol 'e'", 158, 14); + BAssertUtil.validateError(negativeResult, i++, "undefined symbol 'e'", 166, 14); + BAssertUtil.validateError(negativeResult, i++, "redeclared symbol 'm'", 176, 25); Assert.assertEquals(negativeResult.getErrorCount(), i); } diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/types/stream/BStreamValueTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/types/stream/BStreamValueTest.java index 7d4a90ced036..1e3b4897b8ca 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/types/stream/BStreamValueTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/types/stream/BStreamValueTest.java @@ -254,7 +254,7 @@ public void testStreamTypeNegative() { "of 'object { public isolated function next() returns record {| int value; |}?; }', but found " + "'string'", 381, 31); BAssertUtil.validateError(negativeResult, i++, "type 'readonly' not allowed here; " + - "expected an 'error' or a subtype of 'error'.", 387, 31); + "expected an 'error' or a subtype of 'error'", 387, 31); BAssertUtil.validateError(negativeResult, i++, "no stream constructor provided. " + "expected a subtype of 'object { public isolated function next() " + "returns (record {| int value; |}|error); }'", 389, 28); diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/statements/onfail/on-fail-clause-negative.bal b/tests/jballerina-unit-test/src/test/resources/test-src/statements/onfail/on-fail-clause-negative.bal index 384b74391ca3..44e25df50622 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/statements/onfail/on-fail-clause-negative.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/statements/onfail/on-fail-clause-negative.bal @@ -134,3 +134,46 @@ function functionWithCheckpanicInDoClauseNegative() { } function fn() returns int|Error1 => 1; + +function f1() { + int? e = 10; + do { + fail e; + } on fail var m { + + } +} + +function f2() { + int? e = 10; + do { + fail e; + } on fail var error(m) { + + } +} + +function f3() { + do { + fail e; + } on fail var m { + + } +} + +function f4() { + do { + fail e; + } on fail error error(m) { + + } +} + +function f5() { + string m = "str"; + do { + fail error(m); + } on fail var error(m) { + + } +} From 781e3ee604d0661e1408b0ea7e3359d35e98b9d4 Mon Sep 17 00:00:00 2001 From: MaryamZi Date: Tue, 21 Nov 2023 17:47:34 +0530 Subject: [PATCH 33/33] Fix check for errors --- .../compiler/semantics/analyzer/SemanticAnalyzer.java | 5 ++++- .../test/statements/dostatement/DoStmtsTest.java | 2 -- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SemanticAnalyzer.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SemanticAnalyzer.java index 8d0def98b32d..4f83042c1965 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SemanticAnalyzer.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SemanticAnalyzer.java @@ -3982,7 +3982,10 @@ public void visit(BLangFail failNode, AnalyzerData data) { if (!data.commonAnalyzerData.errorTypes.empty()) { BType failExprType = failNode.expr.getBType(); if (failExprType != symTable.semanticError) { - data.commonAnalyzerData.errorTypes.peek().add(types.getErrorTypes(failExprType)); + BType errorTypes = types.getErrorTypes(failExprType); + if (errorTypes != symTable.semanticError) { + data.commonAnalyzerData.errorTypes.peek().add(errorTypes); + } } } if (errorExpressionType != symTable.semanticError && diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/dostatement/DoStmtsTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/dostatement/DoStmtsTest.java index 1bba7419d44d..0a276a07718d 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/dostatement/DoStmtsTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/statements/dostatement/DoStmtsTest.java @@ -76,8 +76,6 @@ public void testNegative2() { int index = 0; BAssertUtil.validateError(negativeFile2, index++, "type 'string' not allowed here; " + "expected an 'error' or a subtype of 'error'", 6, 11); - BAssertUtil.validateError(negativeFile2, index++, "incompatible types: expected " + - "'other', found 'string'", 8, 12); BAssertUtil.validateError(negativeFile2, index++, "invalid error variable; expecting " + "an error type but found 'string' in type definition", 8, 12); BAssertUtil.validateError(negativeFile2, index++, "undefined symbol 'd'", 26, 12);