diff options
| author | Daniel Jasper <djasper@google.com> | 2015-03-30 09:56:50 +0000 |
|---|---|---|
| committer | Daniel Jasper <djasper@google.com> | 2015-03-30 09:56:50 +0000 |
| commit | 02c7bca5d1eef84f41f80267614baafc970f4aae (patch) | |
| tree | 5e2856e4613d7b6a8742ea1d95b9e5d58dea3f01 | |
| parent | 87e848c7dccb65d6fe74f1ac93a859f01c7889e6 (diff) | |
| download | bcm5719-llvm-02c7bca5d1eef84f41f80267614baafc970f4aae.tar.gz bcm5719-llvm-02c7bca5d1eef84f41f80267614baafc970f4aae.zip | |
clang-format: [JS] Fix comment formatting in goog.scopes.
Before:
goog.scope(function() {
// test
var x = 0;
// test
});
After:
goog.scope(function() {
// test
var x = 0;
// test
});
llvm-svn: 233530
| -rw-r--r-- | clang/lib/Format/UnwrappedLineParser.cpp | 5 | ||||
| -rw-r--r-- | clang/unittests/Format/FormatTestJS.cpp | 5 |
2 files changed, 8 insertions, 2 deletions
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index 10ce0e9bee2..a036fb29da3 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -420,7 +420,7 @@ void UnwrappedLineParser::parseBlock(bool MustBeDeclaration, bool AddLevel, Line->Level = InitialLevel; } -static bool IsGoogScope(const UnwrappedLine &Line) { +static bool isGoogScope(const UnwrappedLine &Line) { // FIXME: Closure-library specific stuff should not be hard-coded but be // configurable. if (Line.Tokens.size() < 4) @@ -456,12 +456,13 @@ void UnwrappedLineParser::parseChildBlock() { nextToken(); { bool GoogScope = - Style.Language == FormatStyle::LK_JavaScript && IsGoogScope(*Line); + Style.Language == FormatStyle::LK_JavaScript && isGoogScope(*Line); ScopedLineState LineState(*this); ScopedDeclarationState DeclarationState(*Line, DeclarationScopeStack, /*MustBeDeclaration=*/false); Line->Level += GoogScope ? 0 : 1; parseLevel(/*HasOpeningBrace=*/true); + flushComments(isOnNewLine(*FormatTok)); Line->Level -= GoogScope ? 0 : 1; } nextToken(); diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp index 57070245447..4378ded5c36 100644 --- a/clang/unittests/Format/FormatTestJS.cpp +++ b/clang/unittests/Format/FormatTestJS.cpp @@ -167,6 +167,11 @@ TEST_F(FormatTestJS, GoogScopes) { "var x = a.b;\n" "var y = c.d;\n" "}); // goog.scope"); + verifyFormat("goog.scope(function() {\n" + "// test\n" + "var x = 0;\n" + "// test\n" + "});"); } TEST_F(FormatTestJS, GoogModules) { |

