diff options
| author | Daniel Jasper <djasper@google.com> | 2014-05-22 09:10:04 +0000 |
|---|---|---|
| committer | Daniel Jasper <djasper@google.com> | 2014-05-22 09:10:04 +0000 |
| commit | 49802ef93b56cd6dea2ec50262becdd5c01304f3 (patch) | |
| tree | 8ec417afba6c746d6c7915e78e1f425f3c8e60a9 /clang/lib/Format/TokenAnnotator.cpp | |
| parent | 3948516a03ba3405e2578d27fcaf898e58dc88b5 (diff) | |
| download | bcm5719-llvm-49802ef93b56cd6dea2ec50262becdd5c01304f3.tar.gz bcm5719-llvm-49802ef93b56cd6dea2ec50262becdd5c01304f3.zip | |
clang-format: [JS] Understand line breaks in concatenated strings.
Before:
var literal = 'hello ' + 'world';
After:
var literal = 'hello ' +
'world';
There is no reason to concatenated two string literals with a '+' unless
the line break is intended.
llvm-svn: 209413
Diffstat (limited to 'clang/lib/Format/TokenAnnotator.cpp')
| -rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index f3d655ace5b..ce847d6427e 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -1622,6 +1622,13 @@ bool TokenAnnotator::mustBreakBefore(const AnnotatedLine &Line, BeforeClosingBrace->isOneOf(tok::comma, tok::comment)) return true; + if (Style.Language == FormatStyle::LK_JavaScript) { + // FIXME: This might apply to other languages and token kinds. + if (Right.is(tok::char_constant) && Left.is(tok::plus) && Left.Previous && + Left.Previous->is(tok::char_constant)) + return true; + } + return false; } |

