From e503002a06e7f271d59aef44079d55eedb7df7cf Mon Sep 17 00:00:00 2001 From: Martin Probst Date: Tue, 9 May 2017 12:45:48 +0000 Subject: [PATCH] clang-format: [JS] keep triple slash directives intact. Summary: TypeScript uses triple slash directives of the form: /// For various non-source instructions that should not be wrapped. Reference: https://www.typescriptlang.org/docs/handbook/triple-slash-directives.html Reviewers: djasper Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D32997 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@302523 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Format/Format.cpp | 7 ++++--- unittests/Format/FormatTestJS.cpp | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp index e961e5536e..c8677e8051 100644 --- a/lib/Format/Format.cpp +++ b/lib/Format/Format.cpp @@ -637,9 +637,10 @@ FormatStyle getGoogleStyle(FormatStyle::LanguageKind Language) { GoogleStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Empty; GoogleStyle.AlwaysBreakBeforeMultilineStrings = false; GoogleStyle.BreakBeforeTernaryOperators = false; - // taze:, @tag followed by { for a lot of JSDoc tags, and @see, which is - // commonly followed by overlong URLs. - GoogleStyle.CommentPragmas = "(taze:|(@[A-Za-z_0-9-]+[ \\t]*{)|@see)"; + // taze:, triple slash directives (`/// <...`), @tag followed by { for a lot + // of JSDoc tags, and @see, which is commonly followed by overlong URLs. + GoogleStyle.CommentPragmas = + "(taze:|^/[ \t]*<|(@[A-Za-z_0-9-]+[ \\t]*{)|@see)"; GoogleStyle.MaxEmptyLinesToKeep = 3; GoogleStyle.NamespaceIndentation = FormatStyle::NI_All; GoogleStyle.SpacesInContainerLiterals = false; diff --git a/unittests/Format/FormatTestJS.cpp b/unittests/Format/FormatTestJS.cpp index 9144fe17e9..288975374d 100644 --- a/unittests/Format/FormatTestJS.cpp +++ b/unittests/Format/FormatTestJS.cpp @@ -1785,6 +1785,7 @@ TEST_F(FormatTestJS, ImportComments) { verifyFormat("import {x} from 'x'; // from some location", getGoogleJSStyleWithColumns(25)); verifyFormat("// taze: x from 'location'", getGoogleJSStyleWithColumns(10)); + verifyFormat("/// ", getGoogleJSStyleWithColumns(10)); } TEST_F(FormatTestJS, Exponentiation) { -- 2.40.0