-
Notifications
You must be signed in to change notification settings - Fork 28
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
[java] not enough indentation when using builder pattern (redux) #337
Comments
The problem appears to be that the grammar doesn't understand |
Ah, my bad! A more representative example is class Clazz {
void foo() {
return Foo.builder(
Bar.builder().);
}
} That one does work (gives a +4 indent before the last period), but only when that last period is already there. When you're writing new code, that's generally not the case: class Clazz {
void foo() {
return Foo.builder(
Bar.builder());
}
} In this version, when pressing enter before the last close paren the indentation goes +0 where it should go +4. |
Right, but at that point there isn't really enough information yet to determine whether the expression will continue, so the +0 is reasonable. Does adding the case where the line starts with a period to |
I'm not sure I follow you. There's an expression in the outer set of parens, it's had one non-empty line in it (
Option 1 is theoretically possible, but I wouldn't consider it at all normal (since grouping whitespace is typcially useful between parallel pieces of code). Similarly option 2 would be quite strange since comments are usually either above some code to the right of it on the same line. Or am I missing something? |
The mode acts on a parse of the actual code, and doesn't use whitespace-based heuristics to predict what is likely to be added to that code next. Also, the same indentation logic is used to block-indent stuff, so it doesn't really assume the cursor is on/near the start of the line that's being indented. Again, would setting things up so that lines are reindented when you type a period at their start (after whitespace) help address this? |
On some detailed inspection, I noticed the patch for #124 didn't actually fix the problem with the initial example:
pressing enter before the last
.
should indent +4, but currently indents +0The text was updated successfully, but these errors were encountered: