diff options
| author | Martin Probst <martin@probst.io> | 2016-06-13 16:41:28 +0000 |
|---|---|---|
| committer | Martin Probst <martin@probst.io> | 2016-06-13 16:41:28 +0000 |
| commit | ece8c0c65f4d91bf39fd0e3446dc53ea96685838 (patch) | |
| tree | 8d79c1f9f68e1f577318ab69ad54dc8be23fd2e8 /clang | |
| parent | 0cd74ee87557836ca25604c9895c546e0a6e648e (diff) | |
| download | bcm5719-llvm-ece8c0c65f4d91bf39fd0e3446dc53ea96685838.tar.gz bcm5719-llvm-ece8c0c65f4d91bf39fd0e3446dc53ea96685838.zip | |
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
llvm-svn: 272559
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/Format/Format.cpp | 1 | ||||
| -rw-r--r-- | clang/unittests/Format/FormatTestJS.cpp | 9 |
2 files changed, 10 insertions, 0 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index fc93d18ce12..c73ef5061bf 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -612,6 +612,7 @@ FormatStyle getGoogleStyle(FormatStyle::LanguageKind Language) { 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; diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp index 36c3dd08cba..75b53a57879 100644 --- a/clang/unittests/Format/FormatTestJS.cpp +++ b/clang/unittests/Format/FormatTestJS.cpp @@ -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" |

