r272559 - clang-format: [JS] Indent namespaces in JavaScript/TS by default.
Martin Probst via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 13 09:41:29 PDT 2016
Author: mprobst
Date: Mon Jun 13 11:41:28 2016
New Revision: 272559
URL: http://llvm.org/viewvc/llvm-project?rev=272559&view=rev
Log:
clang-format: [JS] Indent namespaces in JavaScript/TS by default.
Summary: There's no convention of avoiding the nested indentation.
Reviewers: djasper
Subscribers: klimek, alexeagle, cfe-commits
Differential Revision: http://reviews.llvm.org/D21275
Modified:
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/unittests/Format/FormatTestJS.cpp
Modified: cfe/trunk/lib/Format/Format.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=272559&r1=272558&r2=272559&view=diff
==============================================================================
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Mon Jun 13 11:41:28 2016
@@ -612,6 +612,7 @@ FormatStyle getGoogleStyle(FormatStyle::
GoogleStyle.BreakBeforeTernaryOperators = false;
GoogleStyle.CommentPragmas = "@(export|return|see|visibility) ";
GoogleStyle.MaxEmptyLinesToKeep = 3;
+ GoogleStyle.NamespaceIndentation = FormatStyle::NI_All;
GoogleStyle.SpacesInContainerLiterals = false;
GoogleStyle.JavaScriptQuotes = FormatStyle::JSQS_Single;
GoogleStyle.JavaScriptWrapImports = false;
Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=272559&r1=272558&r2=272559&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Mon Jun 13 11:41:28 2016
@@ -315,6 +315,15 @@ TEST_F(FormatTestJS, GoogModules) {
" goog.module.get('my.long.module.name.followedBy.MyLongClassName');");
}
+TEST_F(FormatTestJS, FormatsNamespaces) {
+ verifyFormat("namespace Foo {\n"
+ " export let x = 1;\n"
+ "}\n");
+ verifyFormat("declare namespace Foo {\n"
+ " export let x: number;\n"
+ "}\n");
+}
+
TEST_F(FormatTestJS, FormatsFreestandingFunctions) {
verifyFormat("function outer1(a, b) {\n"
" function inner1(a, b) { return a; }\n"
More information about the cfe-commits
mailing list