Issue |
150507
|
Summary |
clang-format wrongly indents Java code after a switch returning value and variable assignment
|
Labels |
clang-format
|
Assignees |
|
Reporter |
biodranik
|
The result of `clang-format -i file.java`:
```
if (image == null)
{
@DrawableRes
int drawableRes = switch (mode)
{
case LocationState.PENDING_POSITION -> R.drawable.ic_menu_location_pending;
case LocationState.NOT_FOLLOW_NO_POSITION -> R.drawable.ic_location_off;
case LocationState.NOT_FOLLOW -> R.drawable.ic_not_follow;
case LocationState.FOLLOW -> R.drawable.ic_follow;
case LocationState.FOLLOW_AND_ROTATE -> R.drawable.ic_follow_and_rotate;
default -> throw new IllegalArgumentException("Invalid button mode: " + mode);
};
image = ResourcesCompat.getDrawable(resources, drawableRes, context.getTheme());
mIcons.put(mode, image);
}
```
```
clang-format --version
clang-format version 20.1.8
```
```
cat .clang-format
# Configuration file for clang-format, based on docs/CPP_STYLE.md.
BasedOnStyle: Google
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignArrayOfStructures: Right
AlignConsecutiveMacros: AcrossEmptyLinesAndComments
AlignEscapedNewlines: LeftWithLastLine
AlignOperands: AlignAfterOperator
AllowShortBlocksOnASingleLine: Empty
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
BraceWrapping:
AfterCaseLabel: true
AfterClass: true
AfterControlStatement: Always
AfterEnum: true
AfterExternBlock: true
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: true
AfterStruct: true
AfterUnion: true
BeforeCatch: true
BeforeElse: true
BeforeLambdaBody: true
BeforeWhile: true
SplitEmptyFunction: false
SplitEmptyNamespace: false
SplitEmptyRecord: false
BinPackArguments: true
BinPackParameters: true
BreakAfterJavaFieldAnnotations: true
BreakBeforeBraces: Custom
BreakConstructorInitializers: BeforeComma
BreakInheritanceList: BeforeComma
ColumnLimit: 120
ConstructorInitializerIndentWidth: 2
ContinuationIndentWidth: 4
DerivePointerAlignment: false
EmptyLineBeforeAccessModifier: Always
IncludeBlocks: Preserve
IndentAccessModifiers: false
IndentCaseLabels: false
IndentExternBlock: NoIndent
InsertBraces: false
InsertNewlineAtEOF: true
LambdaBodyIndentation: OuterScope
PackConstructorInitializers: CurrentLine
PointerAlignment: Middle
RemoveBracesLLVM: true
QualifierAlignment: Right
SpacesInContainerLiterals: false
Standard: Latest
TabWidth: 2
---
Language: Java
AllowShortFunctionsOnASingleLine: Empty
```
>From Organic Maps code https://github.com/organicmaps/organicmaps
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs