clang-format: [JS] Optionally re-quote string literals.
authorDaniel Jasper <djasper@google.com>
Wed, 2 Mar 2016 22:44:03 +0000 (22:44 +0000)
committerDaniel Jasper <djasper@google.com>
Wed, 2 Mar 2016 22:44:03 +0000 (22:44 +0000)
commitabd1f574535fd57d2099daff486afb0ded29138a
tree3f8f70a7022cbcbf9f2b0d0899258e38daa28d23
parenta0d7a2cd3f878f8fa9624006998558057bed9081
clang-format: [JS] Optionally re-quote string literals.

Turns "foo" into 'foo' (or vice versa, depending on configuration).
This makes it more convenient to follow the Google JavaScript style
guide:
https://google.github.io/styleguide/javascriptguide.xml?showone=Strings#Strings

This functionality is behind the option "JavaScriptQuotes", which can be:

  * "leave" (no re-quoting)
  * "single" (change to single quotes)
  * "double" (change to double quotes)

This also changes single quoted JavaScript string literals to be treated
as tok::string_literal, not tok::char_literal, which fixes two unrelated
tests.

Patch by Martin Probst. Thank you.

llvm-svn: 262534
clang/include/clang/Format/Format.h
clang/lib/Format/Format.cpp
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/FormatTest.cpp
clang/unittests/Format/FormatTestJS.cpp