From 4bcdd666ec5d3857226ab8c82172a2d7c7badfd4 Mon Sep 17 00:00:00 2001 From: lochana-chathura <39232462+lochana-chathura@users.noreply.github.com> Date: Wed, 9 Mar 2022 10:47:41 +0530 Subject: [PATCH] Change expressions() to listMembers() in ListConstructorExpressionNode --- .../compiler/parser/BLangNodeBuilder.java | 2 +- .../tree/STListConstructorExpressionNode.java | 20 ++++++++-------- .../internal/parser/tree/STNodeFactory.java | 4 ++-- .../internal/parser/tree/STTreeModifier.java | 4 ++-- .../tree/ListConstructorExpressionNode.java | 24 +++++++++---------- .../compiler/syntax/tree/NodeFactory.java | 6 ++--- .../compiler/syntax/tree/TreeModifier.java | 6 ++--- .../resources/syntax_tree_descriptor.json | 2 +- .../MatchedExpressionNodeResolver.java | 6 ++--- .../core/FormattingTreeModifier.java | 4 ++-- .../testerina/core/TestProcessor.java | 12 +++++----- 11 files changed, 45 insertions(+), 45 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 f2977f7a8321..b9b7b214689e 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 @@ -1981,7 +1981,7 @@ public BLangNode transform(ListConstructorExpressionNode listConstructorExprNode List argExprList = new ArrayList<>(); BLangListConstructorExpr listConstructorExpr = (BLangListConstructorExpr) TreeBuilder.createListConstructorExpressionNode(); - for (Node expr : listConstructorExprNode.expressions()) { + for (Node expr : listConstructorExprNode.listMembers()) { argExprList.add(createExpression(expr)); } listConstructorExpr.exprs = argExprList; diff --git a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/tree/STListConstructorExpressionNode.java b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/tree/STListConstructorExpressionNode.java index 9eec0b3cc2d0..abc61f614967 100644 --- a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/tree/STListConstructorExpressionNode.java +++ b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/internal/parser/tree/STListConstructorExpressionNode.java @@ -32,58 +32,58 @@ */ public class STListConstructorExpressionNode extends STExpressionNode { public final STNode openBracket; - public final STNode expressions; + public final STNode listMembers; public final STNode closeBracket; STListConstructorExpressionNode( STNode openBracket, - STNode expressions, + STNode listMembers, STNode closeBracket) { this( openBracket, - expressions, + listMembers, closeBracket, Collections.emptyList()); } STListConstructorExpressionNode( STNode openBracket, - STNode expressions, + STNode listMembers, STNode closeBracket, Collection diagnostics) { super(SyntaxKind.LIST_CONSTRUCTOR, diagnostics); this.openBracket = openBracket; - this.expressions = expressions; + this.listMembers = listMembers; this.closeBracket = closeBracket; addChildren( openBracket, - expressions, + listMembers, closeBracket); } public STNode modifyWith(Collection diagnostics) { return new STListConstructorExpressionNode( this.openBracket, - this.expressions, + this.listMembers, this.closeBracket, diagnostics); } public STListConstructorExpressionNode modify( STNode openBracket, - STNode expressions, + STNode listMembers, STNode closeBracket) { if (checkForReferenceEquality( openBracket, - expressions, + listMembers, closeBracket)) { return this; } return new STListConstructorExpressionNode( openBracket, - expressions, + listMembers, closeBracket, diagnostics); } 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 5a1e21a8732d..5cc1c06d81d2 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 @@ -1044,12 +1044,12 @@ public static STNode createTrapExpressionNode( public static STNode createListConstructorExpressionNode( STNode openBracket, - STNode expressions, + STNode listMembers, STNode closeBracket) { return new STListConstructorExpressionNode( openBracket, - expressions, + listMembers, closeBracket); } 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 c931b4bf9421..9281c42e1bde 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 @@ -1107,11 +1107,11 @@ public STTrapExpressionNode transform( public STListConstructorExpressionNode transform( STListConstructorExpressionNode listConstructorExpressionNode) { STNode openBracket = modifyNode(listConstructorExpressionNode.openBracket); - STNode expressions = modifyNode(listConstructorExpressionNode.expressions); + STNode listMembers = modifyNode(listConstructorExpressionNode.listMembers); STNode closeBracket = modifyNode(listConstructorExpressionNode.closeBracket); return listConstructorExpressionNode.modify( openBracket, - expressions, + listMembers, closeBracket); } diff --git a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/ListConstructorExpressionNode.java b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/ListConstructorExpressionNode.java index ac921aa1c9d8..e42a1e1197c4 100644 --- a/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/ListConstructorExpressionNode.java +++ b/compiler/ballerina-parser/src/main/java/io/ballerina/compiler/syntax/tree/ListConstructorExpressionNode.java @@ -36,7 +36,7 @@ public Token openBracket() { return childInBucket(0); } - public SeparatedNodeList expressions() { + public SeparatedNodeList listMembers() { return new SeparatedNodeList<>(childInBucket(1)); } @@ -58,24 +58,24 @@ public T apply(NodeTransformer visitor) { protected String[] childNames() { return new String[]{ "openBracket", - "expressions", + "listMembers", "closeBracket"}; } public ListConstructorExpressionNode modify( Token openBracket, - SeparatedNodeList expressions, + SeparatedNodeList listMembers, Token closeBracket) { if (checkForReferenceEquality( openBracket, - expressions.underlyingListNode(), + listMembers.underlyingListNode(), closeBracket)) { return this; } return NodeFactory.createListConstructorExpressionNode( openBracket, - expressions, + listMembers, closeBracket); } @@ -91,13 +91,13 @@ public ListConstructorExpressionNodeModifier modify() { public static class ListConstructorExpressionNodeModifier { private final ListConstructorExpressionNode oldNode; private Token openBracket; - private SeparatedNodeList expressions; + private SeparatedNodeList listMembers; private Token closeBracket; public ListConstructorExpressionNodeModifier(ListConstructorExpressionNode oldNode) { this.oldNode = oldNode; this.openBracket = oldNode.openBracket(); - this.expressions = oldNode.expressions(); + this.listMembers = oldNode.listMembers(); this.closeBracket = oldNode.closeBracket(); } @@ -108,10 +108,10 @@ public ListConstructorExpressionNodeModifier withOpenBracket( return this; } - public ListConstructorExpressionNodeModifier withExpressions( - SeparatedNodeList expressions) { - Objects.requireNonNull(expressions, "expressions must not be null"); - this.expressions = expressions; + public ListConstructorExpressionNodeModifier withListMembers( + SeparatedNodeList listMembers) { + Objects.requireNonNull(listMembers, "listMembers must not be null"); + this.listMembers = listMembers; return this; } @@ -125,7 +125,7 @@ public ListConstructorExpressionNodeModifier withCloseBracket( public ListConstructorExpressionNode apply() { return oldNode.modify( openBracket, - expressions, + listMembers, closeBracket); } } 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 f88bdd94019a..ba033e1a3dd5 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 @@ -1362,15 +1362,15 @@ public static TrapExpressionNode createTrapExpressionNode( public static ListConstructorExpressionNode createListConstructorExpressionNode( Token openBracket, - SeparatedNodeList expressions, + SeparatedNodeList listMembers, Token closeBracket) { Objects.requireNonNull(openBracket, "openBracket must not be null"); - Objects.requireNonNull(expressions, "expressions must not be null"); + Objects.requireNonNull(listMembers, "listMembers must not be null"); Objects.requireNonNull(closeBracket, "closeBracket must not be null"); STNode stListConstructorExpressionNode = STNodeFactory.createListConstructorExpressionNode( openBracket.internalNode(), - expressions.underlyingListNode().internalNode(), + listMembers.underlyingListNode().internalNode(), closeBracket.internalNode()); return stListConstructorExpressionNode.createUnlinkedFacade(); } 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 e308109a760e..91d702edcbc9 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 @@ -1412,13 +1412,13 @@ public ListConstructorExpressionNode transform( ListConstructorExpressionNode listConstructorExpressionNode) { Token openBracket = modifyToken(listConstructorExpressionNode.openBracket()); - SeparatedNodeList expressions = - modifySeparatedNodeList(listConstructorExpressionNode.expressions()); + SeparatedNodeList listMembers = + modifySeparatedNodeList(listConstructorExpressionNode.listMembers()); Token closeBracket = modifyToken(listConstructorExpressionNode.closeBracket()); return listConstructorExpressionNode.modify( openBracket, - expressions, + listMembers, closeBracket); } 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 271e5ab0a294..9e1334bb76b2 100644 --- a/compiler/ballerina-treegen/src/main/resources/syntax_tree_descriptor.json +++ b/compiler/ballerina-treegen/src/main/resources/syntax_tree_descriptor.json @@ -1902,7 +1902,7 @@ "type": "Token" }, { - "name": "expressions", + "name": "listMembers", "type": "Node", "occurrences": "MULTIPLE_SEPARATED" }, diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/MatchedExpressionNodeResolver.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/MatchedExpressionNodeResolver.java index e277ce626d77..e121dd0a7336 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/MatchedExpressionNodeResolver.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/MatchedExpressionNodeResolver.java @@ -131,11 +131,11 @@ public Optional transform(ExplicitNewExpressionNode explicitNewE @Override public Optional transform(ListConstructorExpressionNode listConstructorExpressionNode) { - Optional expressionNode = listConstructorExpressionNode.expressions().stream() + Optional listMemberNode = listConstructorExpressionNode.listMembers().stream() .filter(expression -> this.matchedNode == expression) .findFirst(); - if (expressionNode.isPresent() && expressionNode.get() instanceof ExpressionNode) { - return Optional.of((ExpressionNode) expressionNode.get()); + if (listMemberNode.isPresent() && listMemberNode.get() instanceof ExpressionNode) { + return Optional.of((ExpressionNode) listMemberNode.get()); } return Optional.empty(); } 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 ecdd40d51da9..1d7495def8c2 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 @@ -1230,7 +1230,7 @@ public ListConstructorExpressionNode transform(ListConstructorExpressionNode lis Token openBracket = formatToken(listConstructorExpressionNode.openBracket(), 0, fieldTrailingNL); indent(); - SeparatedNodeList expressions = formatSeparatedNodeList(listConstructorExpressionNode.expressions(), + SeparatedNodeList listMembers = formatSeparatedNodeList(listConstructorExpressionNode.listMembers(), 0, 0, fieldTrailingWS, fieldTrailingNL, 0, fieldTrailingNL); unindent(); Token closeBracket = formatToken(listConstructorExpressionNode.closeBracket(), @@ -1238,7 +1238,7 @@ public ListConstructorExpressionNode transform(ListConstructorExpressionNode lis return listConstructorExpressionNode.modify() .withOpenBracket(openBracket) - .withExpressions(expressions) + .withListMembers(listMembers) .withCloseBracket(closeBracket) .apply(); } diff --git a/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/core/TestProcessor.java b/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/core/TestProcessor.java index 39f8c5930d3d..0071e86f5194 100644 --- a/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/core/TestProcessor.java +++ b/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/core/TestProcessor.java @@ -414,8 +414,8 @@ private void processGroupsAnnotation(AnnotationNode annotationNode, String funct if (SyntaxKind.LIST_CONSTRUCTOR == valueExpr.kind() && valueExpr instanceof ListConstructorExpressionNode) { List groupList = new ArrayList<>(); - ((ListConstructorExpressionNode) valueExpr).expressions().forEach( - expression -> groupList.add(getStringValue(expression))); + ((ListConstructorExpressionNode) valueExpr).listMembers().forEach( + listMember -> groupList.add(getStringValue(listMember))); if (isBeforeGroups) { suite.addBeforeGroupsFunction(functionName, groupList); } else { @@ -466,8 +466,8 @@ private void processTestAnnotation(AnnotationNode annotationNode, String functio if (SyntaxKind.LIST_CONSTRUCTOR == valueExpr.kind() && valueExpr instanceof ListConstructorExpressionNode) { List groupList = new ArrayList<>(); - ((ListConstructorExpressionNode) valueExpr).expressions().forEach( - expression -> groupList.add(getStringValue(expression))); + ((ListConstructorExpressionNode) valueExpr).listMembers().forEach( + listMember -> groupList.add(getStringValue(listMember))); test.setGroups(groupList); suite.addTestToGroups(test); @@ -506,8 +506,8 @@ private void processTestAnnotation(AnnotationNode annotationNode, String functio if (SyntaxKind.LIST_CONSTRUCTOR == valueExpr.kind() && valueExpr instanceof ListConstructorExpressionNode) { List dependsOnFunctions = new ArrayList<>(); - ((ListConstructorExpressionNode) valueExpr).expressions().forEach( - expression -> dependsOnFunctions.add(getStringValue(expression))); + ((ListConstructorExpressionNode) valueExpr).listMembers().forEach( + listMember -> dependsOnFunctions.add(getStringValue(listMember))); for (String function : dependsOnFunctions) { test.addDependsOnTestFunction(function); }