Reputation: 6083
I'm wondering whats the point of this, first I think it's not a good idea to use space for indentation (somehow Android Studio think it does), second even if I tell it to use tabs it always starts with two tabs on new line, instead of one, turning this:
getSupportFragmentManager().beginTransaction().commit();
into this:
getSupportFragmentManager()
.beginTransaction()
.commit();
Why the two tabs? I know you can set it as "Continuation Indent" to one tab or whatever you want, but cant really understand this, is there anyone who uses two tabs instead of one? What is the thought behind it? Why two tabs by default?
Upvotes: 3
Views: 333
Reputation: 6069
I can only assume it's so that the continuation method calls are somewhat closer to the first method in the chain, for readability. Variable/field/method names are generally more than 8 characters long; they are rarely around 4 characters. When writing using a builder pattern, you generally put the first method on the first line and then subsequent methods should be roughly underneath.
E.g. this:
foobarbaz.builder()
.foo()
.bar()
.baz()
.build();
Rather than this:
foobarbaz.builder()
.foo()
.bar()
.baz()
.build();
In this case, it's more obvious that the methods are stacked on top of each other in the first case.
Obviously the readability depends on the length of the method/variable name on the first line. But I think JetBrains just tried to guess the typical length and set the continuation indent accordingly.
Upvotes: 0