Skip to content

Commit

Permalink
fix: add whitespace between label and statement
Browse files Browse the repository at this point in the history
  • Loading branch information
jtkiesel committed Oct 11, 2024
1 parent 0e4370e commit 5719251
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export class BlocksAndStatementPrettierVisitor extends BaseCstPrettierPrinter {
const identifier = ctx.Identifier[0];
const statement = this.visit(ctx.statement);

return rejectAndJoin(ctx.Colon[0], [identifier, statement]);
return concat([identifier, ctx.Colon[0], " ", statement]);
}

expressionStatement(ctx: ExpressionStatementCtx) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ private void myFunction(

// Label statement
//foreach
loop:for (int num /* num is every number in arr*/: arr) {
loop: for (int num /* num is every number in arr*/: arr) {
/*switch*/switch (num) { //switch
case 1:
System.out.println("One ");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,5 +140,10 @@ void commentsLabeledStatementMixedComment() {
for (int num : arr) {
}
}
}

void labeledBlockStatement() {
label: {
example();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,104 +3,110 @@ class LabeledStatements {
void commentsLabeledStatementLineComment() {
// Label statement
// comment1
loop:for (int num : arr) {}
loop: for (int num : arr) {}

// Label statement
// comment1
// comment2
loop:for (int num : arr) {}
loop: for (int num : arr) {}

// Label statement
// comment1
// comment2
loop:for (int num : arr) {}
loop: for (int num : arr) {}

// comment1
// comment2
loop:for (int num : arr) {}
loop: for (int num : arr) {}

// comment1
loop:for (int num : arr) {}
loop: for (int num : arr) {}

// comment1
loop:for (int num : arr) {}
loop: for (int num : arr) {}

loop:for (int num : arr) {}
loop: for (int num : arr) {}
}

void commentsLabeledStatementBlockComment() {
/* Label statement */
/* comment1 */
loop:for (int num : arr) {}
loop: for (int num : arr) {}

/* Label statement */
/* comment1 */
/* comment2 */
loop:for (int num : arr) {}
loop: for (int num : arr) {}

/* Label statement */
/* comment1 */
/* comment2 */
loop:for (int num : arr) {}
loop: for (int num : arr) {}

/* comment1 */
/* comment2 */
loop:for (int num : arr) {}
loop: for (int num : arr) {}

/* comment1 */
loop:for (int num : arr) {}
loop: for (int num : arr) {}

/* comment1 */
loop:for (int num : arr) {}
loop: for (int num : arr) {}

loop:for (int num : arr) {}
loop: for (int num : arr) {}
}

void commentsLabeledStatementMixedComment() {
// Label statement
/* comment1 */
loop:for (int num : arr) {}
loop: for (int num : arr) {}

/* Label statement */
// comment1
loop:for (int num : arr) {}
loop: for (int num : arr) {}

/* Label statement */
// comment1
// comment2
loop:for (int num : arr) {}
loop: for (int num : arr) {}

// Label statement
/* comment1 */
// comment2
loop:for (int num : arr) {}
loop: for (int num : arr) {}

// Label statement
// comment1
/* comment2 */
loop:for (int num : arr) {}
loop: for (int num : arr) {}

/* Label statement */
// comment1
/* comment2 */
loop:for (int num : arr) {}
loop: for (int num : arr) {}

// Label statement
/* comment1 */
/* comment2 */
loop:for (int num : arr) {}
loop: for (int num : arr) {}

/* Label statement */
/* comment1 */
// comment2
loop:for (int num : arr) {}
loop: for (int num : arr) {}

// comment1
/* comment2 */
loop:for (int num : arr) {}
loop: for (int num : arr) {}

/* comment1 */
// comment2
oop:for (int num : arr) {}
oop: for (int num : arr) {}
}

void labeledBlockStatement() {
label: {
example();
}
}
}

0 comments on commit 5719251

Please sign in to comment.