[cfe-dev] clang-format Java 8 lambda operator

Skyler Hawthorne via cfe-dev cfe-dev at lists.llvm.org
Fri Nov 6 10:32:32 PST 2015


Hello,

I was wondering if it is possible to configure clang-format to not
break the line before the Java 8 lambda operator. For example,

    entries.forEach(entry ->
            assertTrue(String.format("Host set includes '%s'",
                                                entry.getName()),
                                  hostNames.contains(entry.getName())))
;

gets turned into:

    entries.forEach(entry
                    -> assertTrue(String.format("Host set includes
'%s'",
                                                entry.getName()),
                                  hostNames.contains(entry.getName())))
;

This is my .clang-format:

---
Language:        Java
AccessModifierOffset: -2
AlignAfterOpenBracket: true
AlignConsecutiveAssignments: false
AlignEscapedNewlinesLeft: false
AlignOperands:   false
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: false
BinPackArguments: true
BinPackParameters: false
BreakBeforeBinaryOperators: false
BreakBeforeBraces: Attach
BreakBeforeTernaryOperators: false
BreakConstructorInitializersBeforeComma: false
ColumnLimit:     85
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 8
DerivePointerAlignment: false
ExperimentalAutoDetectBinPacking: false
IndentCaseLabels: false
IndentWidth:     4
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: true
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Right
SpaceAfterCStyleCast: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles:  false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
TabWidth:        4
UseTab:          Never
...

-- 
<html>	<body>		<div style="font-family: sans-serif; font-size: 12px; width: 600px; border-width: 1px 0px 0px 0px; border-color: #b0b0b0; border-style: solid; padding: 10px;">			<table cellpadding="0" cellspacing="0" style="font-family: sans-serif; font-size: 12px; width: 100%;">				<tr>					<td style="text-align: left; vertical-align: top; width: 545px;">						<div style="font-size: 14px; font-weight: bold;">Skyler Hawthorne</div>						<div>Research Systems Software Engineer</div>					</td>					<!-- OpenDNS logo -->					<td style="text-align: left; vertical-align: top; width: 101px; padding-left: 10px;">						<a href="http://opendns.com"><img alt="OpenDNS" src="http://images.disthost.opendns.com/signature/opendns_cisco.png" /></a>					</td>				</tr>			</table>		</div>		<div style="font-family: sans-serif; font-size: 12px; width: 600px; border-width: 1px 0px 0px 0px; border-color: #b0b0b0; border-style: solid; padding: 10px;">			<table cellpadding="0" cellspacing="0" style="font-family: sans-serif; font-size: 12px; width: 100%;">				<tr>					<td style="text-align: left; vertical-align: top; width: 4em;">						<span style="font-weight: bold; color: #909090;">Mobile:</span><br />					</td>					<td style="text-align: left; vertical-align: top;">						+1-510-371-4123<br />					</td>					<td style="text-align: left; vertical-align: top; padding-left: 10px; width: 4em;">						<span style="font-weight: bold; color: #909090;">Email:</span><br />						<span style="font-weight: bold; color: #909090;">IM:</span><br />					</td>					<td style="text-align: left; vertical-align: top;">						<a href="mailto:skhawtho at cisco.com" style="text-decoration: none; color: #000">skhawtho at cisco.com</a><br />						<a href="xmpp:skhawtho%40cisco.com?message" style="text-decoration: none; color: #000;">skhawtho at cisco.com</a> (XMPP)<br />					</td>					<!-- SS:address_135_bluxome -->					<td style="text-align: left; vertical-align: top; padding-left: 10px;">						<a target="_blank" href="http://opendns.com/" style="color: #f07000;"><b>OpenDNS</b></a><br>						<a target="_blank" href="http://maps.google.com/maps?q=135+Bluxome+Street%2CSan+Francisco%2CCA+94107%2CUnited+States&hl=en" style="text-decoration: none; color: #000000">135 Bluxome St<br />San Francisco, CA 94107<br />United States</a>					</td>					<!-- SE:address_135_bluxome -->					<td style="text-align: right; vertical-align: top; width: 82px;">						<a href="http://github.com/opendns" title="Github"><img alt="GH" src="http://images.disthost.opendns.com/signature/github.png" /></a>					</td>				</tr>			</table>		</div>		<br />	</body></html>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20151106/c94eb0c3/attachment.html>


More information about the cfe-dev mailing list