diff options
| author | Nico Weber <nicolasweber@gmx.de> | 2015-10-15 16:03:01 +0000 |
|---|---|---|
| committer | Nico Weber <nicolasweber@gmx.de> | 2015-10-15 16:03:01 +0000 |
| commit | 2cd92f1cc789a7570893f5e72cd8fa3330da4ebf (patch) | |
| tree | 20aa34cefdcf0e963a9bcb602a4af0d53dd7206b /clang/lib/Format | |
| parent | aa19708f88e4f8444d59e8250796610712026c1b (diff) | |
| download | bcm5719-llvm-2cd92f1cc789a7570893f5e72cd8fa3330da4ebf.tar.gz bcm5719-llvm-2cd92f1cc789a7570893f5e72cd8fa3330da4ebf.zip | |
clang-format/java: Break after annotations on fields in Chromium style.
Chromium follows the Android style guide for Java code, and that doesn't make
the distinction between fields and non-fields that the Google Java style guide
makes:
https://source.android.com/source/code-style.html#use-standard-java-annotations
https://google.github.io/styleguide/javaguide.html#s4.8.5-annotations
llvm-svn: 250422
Diffstat (limited to 'clang/lib/Format')
| -rw-r--r-- | clang/lib/Format/Format.cpp | 4 | ||||
| -rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 2 |
2 files changed, 4 insertions, 2 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index 0afa9aa9ce2..56c4d43aa15 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -447,6 +447,7 @@ FormatStyle getLLVMStyle() { LLVMStyle.BraceWrapping = {false, false, false, false, false, false, false, false, false, false, false}; LLVMStyle.BreakConstructorInitializersBeforeComma = false; + LLVMStyle.BreakAfterJavaFieldAnnotations = false; LLVMStyle.ColumnLimit = 80; LLVMStyle.CommentPragmas = "^ IWYU pragma:"; LLVMStyle.ConstructorInitializerAllOnOneLineOrOnePerLine = false; @@ -550,8 +551,9 @@ FormatStyle getChromiumStyle(FormatStyle::LanguageKind Language) { FormatStyle ChromiumStyle = getGoogleStyle(Language); if (Language == FormatStyle::LK_Java) { ChromiumStyle.AllowShortIfStatementsOnASingleLine = true; - ChromiumStyle.IndentWidth = 4; + ChromiumStyle.BreakAfterJavaFieldAnnotations = true; ChromiumStyle.ContinuationIndentWidth = 8; + ChromiumStyle.IndentWidth = 4; } else { ChromiumStyle.AllowAllParametersOfDeclarationOnNextLine = false; ChromiumStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Inline; diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index fc89d2bafff..fbd7fe4f6f4 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -2176,7 +2176,7 @@ bool TokenAnnotator::mustBreakBefore(const AnnotatedLine &Line, Style.Language == FormatStyle::LK_JavaScript) && Left.is(TT_LeadingJavaAnnotation) && Right.isNot(TT_LeadingJavaAnnotation) && Right.isNot(tok::l_paren) && - Line.Last->is(tok::l_brace)) + (Line.Last->is(tok::l_brace) || Style.BreakAfterJavaFieldAnnotations)) return true; return false; |

