Created
January 28, 2017 22:52
-
-
Save romani/72acaeeb7f7e04a28c1913f11f911a38 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private static boolean isAloneOnLine(Details details) { | |
| final DetailAST rcurly = details.rcurly; | |
| final DetailAST lcurly = details.lcurly; | |
| final int lcurlyNo = lcurly.getLineNo(); | |
| final int rcurlyNo = rcurly.getLineNo(); | |
| boolean result = false; | |
| if (lcurlyNo != rcurlyNo) { | |
| final int tokenLambda = details.lcurly.getParent().getType(); | |
| if (tokenLambda == TokenTypes.LAMBDA) { | |
| result = rcurly.getPreviousSibling() == null | |
| || rcurlyNo != rcurly.getPreviousSibling().getLineNo(); | |
| } else { | |
| final DetailAST nextToken = details.nextToken; | |
| result = rcurly.getLineNo() != nextToken.getLineNo(); | |
| } | |
| } | |
| return result; | |
| } | |
| private static boolean shouldBeAloneOnLine(RightCurlyOption bracePolicy, Details details) { | |
| return bracePolicy == RightCurlyOption.ALONE | |
| && !isAloneOnLine(details) | |
| && !isEmptyBody(details.lcurly) | |
| || bracePolicy == RightCurlyOption.ALONE_OR_SINGLELINE | |
| && !isAloneOnLine(details) | |
| && !isSingleLineBlock(details) | |
| && !isAnonInnerClassInit(details.lcurly) | |
| && !isEmptyBody(details.lcurly) | |
| ; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment