Skip to content

Commit

Permalink
Change expressions() to listMembers() in ListConstructorExpressionNode
Browse files Browse the repository at this point in the history
  • Loading branch information
lochana-chathura committed Mar 9, 2022
1 parent b6b5965 commit 4bcdd66
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1981,7 +1981,7 @@ public BLangNode transform(ListConstructorExpressionNode listConstructorExprNode
List<BLangExpression> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<STNodeDiagnostic> 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<STNodeDiagnostic> 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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public Token openBracket() {
return childInBucket(0);
}

public SeparatedNodeList<Node> expressions() {
public SeparatedNodeList<Node> listMembers() {
return new SeparatedNodeList<>(childInBucket(1));
}

Expand All @@ -58,24 +58,24 @@ public <T> T apply(NodeTransformer<T> visitor) {
protected String[] childNames() {
return new String[]{
"openBracket",
"expressions",
"listMembers",
"closeBracket"};
}

public ListConstructorExpressionNode modify(
Token openBracket,
SeparatedNodeList<Node> expressions,
SeparatedNodeList<Node> listMembers,
Token closeBracket) {
if (checkForReferenceEquality(
openBracket,
expressions.underlyingListNode(),
listMembers.underlyingListNode(),
closeBracket)) {
return this;
}

return NodeFactory.createListConstructorExpressionNode(
openBracket,
expressions,
listMembers,
closeBracket);
}

Expand All @@ -91,13 +91,13 @@ public ListConstructorExpressionNodeModifier modify() {
public static class ListConstructorExpressionNodeModifier {
private final ListConstructorExpressionNode oldNode;
private Token openBracket;
private SeparatedNodeList<Node> expressions;
private SeparatedNodeList<Node> 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();
}

Expand All @@ -108,10 +108,10 @@ public ListConstructorExpressionNodeModifier withOpenBracket(
return this;
}

public ListConstructorExpressionNodeModifier withExpressions(
SeparatedNodeList<Node> expressions) {
Objects.requireNonNull(expressions, "expressions must not be null");
this.expressions = expressions;
public ListConstructorExpressionNodeModifier withListMembers(
SeparatedNodeList<Node> listMembers) {
Objects.requireNonNull(listMembers, "listMembers must not be null");
this.listMembers = listMembers;
return this;
}

Expand All @@ -125,7 +125,7 @@ public ListConstructorExpressionNodeModifier withCloseBracket(
public ListConstructorExpressionNode apply() {
return oldNode.modify(
openBracket,
expressions,
listMembers,
closeBracket);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1362,15 +1362,15 @@ public static TrapExpressionNode createTrapExpressionNode(

public static ListConstructorExpressionNode createListConstructorExpressionNode(
Token openBracket,
SeparatedNodeList<Node> expressions,
SeparatedNodeList<Node> 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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1412,13 +1412,13 @@ public ListConstructorExpressionNode transform(
ListConstructorExpressionNode listConstructorExpressionNode) {
Token openBracket =
modifyToken(listConstructorExpressionNode.openBracket());
SeparatedNodeList<Node> expressions =
modifySeparatedNodeList(listConstructorExpressionNode.expressions());
SeparatedNodeList<Node> listMembers =
modifySeparatedNodeList(listConstructorExpressionNode.listMembers());
Token closeBracket =
modifyToken(listConstructorExpressionNode.closeBracket());
return listConstructorExpressionNode.modify(
openBracket,
expressions,
listMembers,
closeBracket);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1902,7 +1902,7 @@
"type": "Token"
},
{
"name": "expressions",
"name": "listMembers",
"type": "Node",
"occurrences": "MULTIPLE_SEPARATED"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,11 @@ public Optional<ExpressionNode> transform(ExplicitNewExpressionNode explicitNewE

@Override
public Optional<ExpressionNode> transform(ListConstructorExpressionNode listConstructorExpressionNode) {
Optional<Node> expressionNode = listConstructorExpressionNode.expressions().stream()
Optional<Node> 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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1230,15 +1230,15 @@ public ListConstructorExpressionNode transform(ListConstructorExpressionNode lis

Token openBracket = formatToken(listConstructorExpressionNode.openBracket(), 0, fieldTrailingNL);
indent();
SeparatedNodeList<Node> expressions = formatSeparatedNodeList(listConstructorExpressionNode.expressions(),
SeparatedNodeList<Node> listMembers = formatSeparatedNodeList(listConstructorExpressionNode.listMembers(),
0, 0, fieldTrailingWS, fieldTrailingNL, 0, fieldTrailingNL);
unindent();
Token closeBracket = formatToken(listConstructorExpressionNode.closeBracket(),
env.trailingWS, env.trailingNL);

return listConstructorExpressionNode.modify()
.withOpenBracket(openBracket)
.withExpressions(expressions)
.withListMembers(listMembers)
.withCloseBracket(closeBracket)
.apply();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,8 +414,8 @@ private void processGroupsAnnotation(AnnotationNode annotationNode, String funct
if (SyntaxKind.LIST_CONSTRUCTOR == valueExpr.kind() &&
valueExpr instanceof ListConstructorExpressionNode) {
List<String> 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 {
Expand Down Expand Up @@ -466,8 +466,8 @@ private void processTestAnnotation(AnnotationNode annotationNode, String functio
if (SyntaxKind.LIST_CONSTRUCTOR == valueExpr.kind() &&
valueExpr instanceof ListConstructorExpressionNode) {
List<String> 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);

Expand Down Expand Up @@ -506,8 +506,8 @@ private void processTestAnnotation(AnnotationNode annotationNode, String functio
if (SyntaxKind.LIST_CONSTRUCTOR == valueExpr.kind() &&
valueExpr instanceof ListConstructorExpressionNode) {
List<String> 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);
}
Expand Down

0 comments on commit 4bcdd66

Please sign in to comment.