@NotNull private WrapType noParenthesesOneArgumentChildrenWrapType(@NotNull ASTNode noParenthesesOneArgument) { WrapType childrenWrapType; ASTNode noParenthesesKeywords = noParenthesesOneArgument.findChildByType(NO_PARENTHESES_KEYWORDS); if (noParenthesesKeywords != null) { ASTNode[] noParenthesesKeywordPairs = noParenthesesKeywords.getChildren(NO_PARENTHESES_KEYWORD_PAIR_TOKEN_SET); childrenWrapType = null; for (ASTNode noParenthesesKeywordPair : noParenthesesKeywordPairs) { if (oneLinerKeywordPair(noParenthesesKeywordPair)) { childrenWrapType = WrapType.CHOP_DOWN_IF_LONG; break; } } if (childrenWrapType == null) { childrenWrapType = noParenthesesOneArgumentWrapType(noParenthesesOneArgument); if (childrenWrapType == WrapType.ALWAYS && !noParenthesesKeywords.textContains('\n')) { childrenWrapType = WrapType.CHOP_DOWN_IF_LONG; } } } else { childrenWrapType = WrapType.CHOP_DOWN_IF_LONG; } return childrenWrapType; }
@NotNull private List<com.intellij.formatting.Block> buildParentheticalStabChildren(@NotNull ASTNode parentheticalStab) { Indent childIndent = Indent.getNormalIndent(); Wrap stabBodyChildrenWrap; if (parentheticalStab.textContains('\n')) { stabBodyChildrenWrap = null; } else { stabBodyChildrenWrap = Wrap.createWrap(WrapType.CHOP_DOWN_IF_LONG, true); } return buildChildren( parentheticalStab, (child, childElementType, blockList) -> { if (childElementType == SEMICOLON) { blockList.add( buildChild(child, Wrap.createWrap(WrapType.NONE, true), childIndent) ); } else if (childElementType == STAB) { blockList.addAll(buildStabChildren((CompositeElement) child, stabBodyChildrenWrap)); } else { blockList.add(buildChild(child)); } return blockList; } ); }
@Override public boolean textContains(char c) { return getNode().textContains(c); }