Skip to content

Commit

Permalink
Fixed cases.
Browse files Browse the repository at this point in the history
  • Loading branch information
traceyyoshima committed Nov 15, 2023
1 parent b1fd1cb commit c58f6ae
Showing 1 changed file with 22 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -733,24 +733,27 @@ private J.ClassDeclaration visitClassDeclaration(TSCNode node) {
private J visitCaseClause(TSCNode node) {
TSCNode expression = node.getOptionalNodeProperty("expression");
List<TSCNode> statements = node.getNodeListProperty("statements");
List<JRightPadded<Statement>> list = new ArrayList<>();
Space prefix = whitespace();
JContainer<Expression> expressions = JContainer.build(
expression == null ? EMPTY : sourceBefore(TSCSyntaxKind.CaseKeyword),
singletonList(JRightPadded.build((Expression) visitNode(expression))),
Markers.EMPTY
);
List<JRightPadded<Statement>> list = new ArrayList<>(statements.size());
Space before = sourceBefore(TSCSyntaxKind.ColonToken);
for (TSCNode it : statements) {
JRightPadded<Statement> statementJRightPadded = maybeSemicolon((Statement) visitNode(it));
list.add(statementJRightPadded);
}
return new J.Case(
randomId(),
whitespace(),
prefix,
Markers.EMPTY,
J.Case.Type.Statement,
null,
expressions,
JContainer.build(
expression == null ? EMPTY : sourceBefore(TSCSyntaxKind.CaseKeyword),
singletonList(JRightPadded.build((Expression) visitNode(expression))),
Markers.EMPTY
),
JContainer.build(
sourceBefore(TSCSyntaxKind.ColonToken),
before,
list,
Markers.EMPTY
),
Expand Down Expand Up @@ -859,24 +862,27 @@ private J.Annotation visitDecorator(TSCNode node) {

private J visitDefaultClause(TSCNode node) {
List<TSCNode> statements = node.getNodeListProperty("statements");
List<JRightPadded<Statement>> list = new ArrayList<>();
Space prefix = whitespace();
JContainer<Expression> expressions = JContainer.build(
EMPTY,
singletonList(JRightPadded.build(new J.Identifier(randomId(), sourceBefore(TSCSyntaxKind.DefaultKeyword), Markers.EMPTY, emptyList(), "default", null, null))),
Markers.EMPTY
);
Space before = sourceBefore(TSCSyntaxKind.ColonToken);
List<JRightPadded<Statement>> list = new ArrayList<>(statements.size());
for (TSCNode it : statements) {
JRightPadded<Statement> statementJRightPadded = maybeSemicolon((Statement) visitNode(it));
list.add(statementJRightPadded);
}
return new J.Case(
randomId(),
whitespace(),
prefix,
Markers.EMPTY,
J.Case.Type.Statement,
null,
expressions,
JContainer.build(
EMPTY,
singletonList(JRightPadded.build(new J.Identifier(randomId(), sourceBefore(TSCSyntaxKind.DefaultKeyword), Markers.EMPTY, emptyList(), "default", null, null))),
Markers.EMPTY
),
JContainer.build(
sourceBefore(TSCSyntaxKind.ColonToken),
before,
list,
Markers.EMPTY
),
Expand Down

0 comments on commit c58f6ae

Please sign in to comment.