]> granicus.if.org Git - clang/commit
clang-format: [JavaScript] Do requoting in a separate pass
authorDaniel Jasper <djasper@google.com>
Wed, 7 Sep 2016 22:48:53 +0000 (22:48 +0000)
committerDaniel Jasper <djasper@google.com>
Wed, 7 Sep 2016 22:48:53 +0000 (22:48 +0000)
commit1f3b581691d21bdb2ddba0b94273d3781395c1c1
tree91bd30526ca26ee97a60801caa1024a6591f97d3
parent76355613f3428003e0ab14dd2b78dabbb666c550
clang-format: [JavaScript] Do requoting in a separate pass

The attempt to fix requoting behavior in r280487 after changes to
tooling::Replacements are incomplete. We essentially need to add to
replacements at the same position, one to insert a line break and one to
change the quoting and that's incompatible with the new
tooling::Replacement API, which does not allow for order-dependent
Replacements. To make the order clear, Replacements::merge() has to be
used, but that requires the merged Replacement to actually refer to the
changed text, which is hard to reproduce for the requoting.

This change fixes the behavior by moving the requoting to a completely
separate pass. The added benefit is that no weird ColumnWidth
calculations are necessary anymore and this should just work even if we
implement string literal splitting in the future.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@280874 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Format/Format.cpp
unittests/Format/FormatTestJS.cpp