clang-format: [JS] support optional methods.
authorDaniel Jasper <djasper@google.com>
Tue, 5 May 2015 08:40:32 +0000 (08:40 +0000)
committerDaniel Jasper <djasper@google.com>
Tue, 5 May 2015 08:40:32 +0000 (08:40 +0000)
commit9326f919225688c87e75fca90f496d7f326e942d
tree1403f4f5d7a7a926f56256bccf1da9f168f74503
parentfc80e26fe6e24ae4e21ccf55f8172106f2233a64
clang-format: [JS] support optional methods.

Optional methods use ? tokens like this:

  interface X { y?(): z; }

It seems easiest to detect and disambiguate these from ternary
expressions by checking if the code is in a declaration context. Turns
out that that didn't quite work properly for interfaces in Java and JS,
and for JS file root contexts.

Patch by Martin Probst, thank you.

llvm-svn: 236488
clang/lib/Format/TokenAnnotator.cpp
clang/lib/Format/UnwrappedLineParser.cpp
clang/unittests/Format/FormatTestJS.cpp