clang-format: [JS] respect clang-format off when requoting strings.

Reviewers: djasper

Subscribers: klimek, cfe-commits

Differential Revision: http://reviews.llvm.org/D20200

llvm-svn: 269282
This commit is contained in:
Martin Probst 2016-05-12 11:20:32 +00:00
parent 194357c509
commit a166979e45
2 changed files with 9 additions and 1 deletions

View File

@ -1652,7 +1652,7 @@ private:
for (FormatToken *FormatTok = Line->First; FormatTok;
FormatTok = FormatTok->Next) {
StringRef Input = FormatTok->TokenText;
if (!FormatTok->isStringLiteral() ||
if (FormatTok->Finalized || !FormatTok->isStringLiteral() ||
// NB: testing for not starting with a double quote to avoid
// breaking
// `template strings`.

View File

@ -1236,6 +1236,14 @@ TEST_F(FormatTestJS, RequoteStringsSingle) {
// Code below fits into 15 chars *after* removing the \ escape.
verifyFormat("var x = 'fo\"o';", "var x = \"fo\\\"o\";",
getGoogleJSStyleWithColumns(15));
verifyFormat("// clang-format off\n"
"let x = \"double\";\n"
"// clang-format on\n"
"let x = 'single';\n",
"// clang-format off\n"
"let x = \"double\";\n"
"// clang-format on\n"
"let x = \"single\";\n");
}
TEST_F(FormatTestJS, RequoteStringsDouble) {