diff options
author | Daniel Jasper <djasper@google.com> | 2015-05-05 08:40:32 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2015-05-05 08:40:32 +0000 |
commit | 9326f919225688c87e75fca90f496d7f326e942d (patch) | |
tree | 1403f4f5d7a7a926f56256bccf1da9f168f74503 /clang/unittests/Format/FormatTestJS.cpp | |
parent | fc80e26fe6e24ae4e21ccf55f8172106f2233a64 (diff) | |
download | bcm5719-llvm-9326f919225688c87e75fca90f496d7f326e942d.tar.gz bcm5719-llvm-9326f919225688c87e75fca90f496d7f326e942d.zip |
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
Diffstat (limited to 'clang/unittests/Format/FormatTestJS.cpp')
-rw-r--r-- | clang/unittests/Format/FormatTestJS.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp index 0c36dce93dd..43fc4b47284 100644 --- a/clang/unittests/Format/FormatTestJS.cpp +++ b/clang/unittests/Format/FormatTestJS.cpp @@ -709,6 +709,10 @@ TEST_F(FormatTestJS, OptionalTypes) { " y?: z;\n" " z?;\n" "}"); + verifyFormat("interface X {\n" + " y?(): z;\n" + "}"); + verifyFormat("x ? 1 : 2;"); } TEST_F(FormatTestJS, IndexSignature) { |