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)
commit496c1999593d9aee2f4ea991561851ba8e712aca
tree8112d19e5af966cbe7a8e2b4fc0779bb3810c2fa
parent9b40f983571ae1c0fe8dd83e698060538f5cc845
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.

llvm-svn: 280874
clang/lib/Format/Format.cpp
clang/unittests/Format/FormatTestJS.cpp