Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add whitespace between label and statement #689

Merged
merged 1 commit into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
}
}
}
Loading