From: Nico Weber Date: Wed, 4 Jan 2017 02:33:36 +0000 (+0000) Subject: Change clang-format's Chromium JavaScript defaults X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ac00eadce00243bf8734da8d156b8ed19dc37fd3;p=clang Change clang-format's Chromium JavaScript defaults Chromium is starting to use clang-format on more JavaScript. In doing this, we discovered that our defaults were not doing a good job differentiating between JS and C++. This change moves some defaults to only apply to C++. https://reviews.llvm.org/D28165 Patch from Dan Beam ! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@290930 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp index 70b90d6fa1..389761d482 100644 --- a/lib/Format/Format.cpp +++ b/lib/Format/Format.cpp @@ -638,6 +638,9 @@ FormatStyle getChromiumStyle(FormatStyle::LanguageKind Language) { ChromiumStyle.BreakAfterJavaFieldAnnotations = true; ChromiumStyle.ContinuationIndentWidth = 8; ChromiumStyle.IndentWidth = 4; + } else if (Language == FormatStyle::LK_JavaScript) { + ChromiumStyle.AllowShortIfStatementsOnASingleLine = false; + ChromiumStyle.AllowShortLoopsOnASingleLine = false; } else { ChromiumStyle.AllowAllParametersOfDeclarationOnNextLine = false; ChromiumStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Inline;