r302523 - clang-format: [JS] keep triple slash directives intact.
Martin Probst via cfe-commits
cfe-commits at lists.llvm.org
Tue May 9 05:45:49 PDT 2017
Author: mprobst
Date: Tue May 9 07:45:48 2017
New Revision: 302523
URL: http://llvm.org/viewvc/llvm-project?rev=302523&view=rev
Log:
clang-format: [JS] keep triple slash directives intact.
Summary:
TypeScript uses triple slash directives of the form:
/// <reference path="..."/>
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
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=302523&r1=302522&r2=302523&view=diff
==============================================================================
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Tue May 9 07:45:48 2017
@@ -637,9 +637,10 @@ FormatStyle getGoogleStyle(FormatStyle::
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;
Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=302523&r1=302522&r2=302523&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Tue May 9 07:45:48 2017
@@ -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("/// <reference path=\"some/location\" />", getGoogleJSStyleWithColumns(10));
}
TEST_F(FormatTestJS, Exponentiation) {
More information about the cfe-commits
mailing list