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

[dom ast] case statement rewrite formatting #3253

Open
subyssurendran666 opened this issue Nov 5, 2024 · 3 comments · May be fixed by #3349
Open

[dom ast] case statement rewrite formatting #3253

subyssurendran666 opened this issue Nov 5, 2024 · 3 comments · May be fixed by #3349
Assignees

Comments

@subyssurendran666
Copy link
Contributor

subyssurendran666 commented Nov 5, 2024

Consider the following code:

public class X {
    static int foo(int i) {
        int tw = 0;
        switch (i) {
            case 1 : {
                 int z = 100;
                 break;
            }
            default : {
                break;
            }
        }
        return tw;
    }
    public static void main(String[] args) {
        System.out.print(foo(1));
    }
}

Now add case 100: with a block having a singleton break;

The resulting code looks like:

public class X {
    static int foo(int i) {
        int tw = 0;
        switch (i) {
            case 1 : {
                 int z = 100;
                 break;
            }
            case 100:
                {
                    break;
                }
            default : {
                break;
            }
        }
        return tw;
    }
    public static void main(String[] args) {
        System.out.print(foo(1));
    }
}

The case 100: block format is different.

Ref: https://bugs.eclipse.org/bugs/show_bug.cgi?id=545439

@subyssurendran666
Copy link
Contributor Author

@mpalat could you please assign this ticket to me ?

@subyssurendran666
Copy link
Contributor Author

After the ASTRewrite, the new switch case format should be

case 100: {
    break;
}

Also, for the arrow case labels(->), after the ASTRewrite, the format should be

case 100 -> {
    break;
}

@mpalat could you please share your thoughts ?

@mpalat
Copy link
Contributor

mpalat commented Nov 8, 2024

@subyssurendran666 - yes. Do check the formatting preferences for sure

@subyssurendran666 subyssurendran666 linked a pull request Nov 26, 2024 that will close this issue
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants