From fbbe75b1fe7aa6d2678ba692d945f07fc335e611 Mon Sep 17 00:00:00 2001 From: Martin Probst Date: Sun, 18 Sep 2016 17:33:51 +0000 Subject: [PATCH] clang-format: [JS] Do not wrap taze annotation comments. Summary: `// taze: ... from ...` comments are used help tools where a specific global symbol comes from. Before: // taze: many, different, symbols from // 'some_long_location_here' After: // taze: many, different, symbols from 'some_long_location_here' Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D24477 llvm-svn: 281857 --- clang/lib/Format/Format.cpp | 2 +- clang/unittests/Format/FormatTestJS.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index 388c35a..04bafac 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -613,7 +613,7 @@ FormatStyle getGoogleStyle(FormatStyle::LanguageKind Language) { GoogleStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Empty; GoogleStyle.AlwaysBreakBeforeMultilineStrings = false; GoogleStyle.BreakBeforeTernaryOperators = false; - GoogleStyle.CommentPragmas = "@(export|requirecss|return|see|visibility) "; + GoogleStyle.CommentPragmas = "(taze:|@(export|requirecss|return|see|visibility)) "; GoogleStyle.MaxEmptyLinesToKeep = 3; GoogleStyle.NamespaceIndentation = FormatStyle::NI_All; GoogleStyle.SpacesInContainerLiterals = false; diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp index dd95462..c19c054 100644 --- a/clang/unittests/Format/FormatTestJS.cpp +++ b/clang/unittests/Format/FormatTestJS.cpp @@ -1444,5 +1444,11 @@ TEST_F(FormatTestJS, Conditional) { "}"); } +TEST_F(FormatTestJS, ImportComments) { + verifyFormat("import {x} from 'x'; // from some location", + getGoogleJSStyleWithColumns(25)); + verifyFormat("// taze: x from 'location'", getGoogleJSStyleWithColumns(10)); +} + } // end namespace tooling } // end namespace clang -- 2.7.4