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
This commit is contained in:
Daniel Jasper 2015-03-30 09:56:50 +00:00
parent 87e848c7dc
commit 02c7bca5d1
2 changed files with 8 additions and 2 deletions

View File

@ -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();

View File

@ -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) {