-
Notifications
You must be signed in to change notification settings - Fork 885
fixing formatter issues #8484
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
base: master
Are you sure you want to change the base?
fixing formatter issues #8484
Conversation
Boolean hasErrThenStatement = Optional.ofNullable(node.getThenStatement()) | ||
.filter(it-> it instanceof ExpressionStatementTree) | ||
.map(it -> ((ExpressionStatementTree)it).getExpression()) | ||
.map(it-> (it instanceof ErroneousTree)) | ||
.orElse(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
boolean hasErrThenStatement = node.getThenStatement() instanceof ExpressionStatementTree tree
&& tree.getExpression() instanceof ErroneousTree;
easier to read and probably less overhead too
var isPreviousIfTree = false; | ||
var endPositionOfErrThenStatement = endPos; | ||
for (var statment : parentStTree.getStatements()) { | ||
if (isPreviousIfTree) { | ||
var startPositionOfNextErrorStatement = (int) sp.getStartPosition(getCurrentPath().getCompilationUnit(), statment); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets not use var
here. int
has 3 chars too - no need for extra obfuscation just to make the IDE draw the type as inline hint wasting space ;)
Makes it also easier to review without checking this out in NetBeans.
var
is more interesting for collections with complex generics signatures etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 Also statment
-> statement
.
providing fix for issue
{}
of braces are injected at the erroneous then part in IfTreesp.getStartPosition
andsp.getEndPosition
always returns begining index for erroneous then statement