Formatting classes Android Studio / IntelliJ Anonymous

I was wondering if it is possible to change the automatic formatting in Android Studio so that the brackets for anonymous classes are placed on the same line, while maintaining curly braces for ordinary classes, methods and blocks on a new line.

IntelliJ is currently giving me this result:

class TestClass
{
    public void test()
    {
        FooBar foo = new FooBar(new Runnable() // I want the brace here...
        { // ...not here.
            @Override
            public void run()
            {
                //
            }
        });
    }
}

However, I would like the code to be formatted as follows:

class TestClass
{
    public void test()
    {
        FooBar foo = new FooBar(new Runnable() { // <- Same Line
            @Override
            public void run()
            {
                //
            }
        });
    }
}

Everything is in order, except for one detail that I cannot get so that the bracket is formatted, as in the second example. Is it not possible or I just did not notice the settings?

+4
source share
1 answer

, , , Intellij.

, , - "" "/" / " , " " " ( ). , , ( ), ; /if/else//while/do-while/try/catch/finally/switch .. .

, IntelliJ Wrapping Braces/Braces Placement/ , Eclipse.

+3

Source: https://habr.com/ru/post/1523652/


All Articles