diff options
| author | Martin Probst <martin@probst.io> | 2017-08-01 17:12:15 +0000 |
|---|---|---|
| committer | Martin Probst <martin@probst.io> | 2017-08-01 17:12:15 +0000 |
| commit | db51cc5745f4634cac1d6cad9ef40663b35f468d (patch) | |
| tree | 7ef1acc28e6d8f6bc11ff6e4abf42dc54ead4018 /clang | |
| parent | 2b89c14b8ced606c4891797ee7cf127bd2ce008b (diff) | |
| download | bcm5719-llvm-db51cc5745f4634cac1d6cad9ef40663b35f468d.tar.gz bcm5719-llvm-db51cc5745f4634cac1d6cad9ef40663b35f468d.zip | |
clang-format: [JS] consistenly format enums.
Summary: Previously, const enums would get formatted differently because the modifier was not recognized.
Reviewers: djasper
Subscribers: klimek, cfe-commits
Differential Revision: https://reviews.llvm.org/D36144
llvm-svn: 309703
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 4 | ||||
| -rw-r--r-- | clang/unittests/Format/FormatTestJS.cpp | 8 |
2 files changed, 11 insertions, 1 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 318bb259509..e7a50aa4329 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -2517,7 +2517,9 @@ bool TokenAnnotator::mustBreakBefore(const AnnotatedLine &Line, return true; if (Left.is(tok::l_brace) && Line.Level == 0 && (Line.startsWith(tok::kw_enum) || - Line.startsWith(tok::kw_export, tok::kw_enum))) + Line.startsWith(tok::kw_const, tok::kw_enum) || + Line.startsWith(tok::kw_export, tok::kw_enum) || + Line.startsWith(tok::kw_export, tok::kw_const, tok::kw_enum))) // JavaScript top-level enum key/value pairs are put on separate lines // instead of bin-packing. return true; diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp index d91df54f3da..54e2c8fbe95 100644 --- a/clang/unittests/Format/FormatTestJS.cpp +++ b/clang/unittests/Format/FormatTestJS.cpp @@ -1425,6 +1425,14 @@ TEST_F(FormatTestJS, EnumDeclarations) { " B\n" "}\n" "var x = 1;"); + verifyFormat("const enum Foo {\n" + " A = 1,\n" + " B\n" + "}"); + verifyFormat("export const enum Foo {\n" + " A = 1,\n" + " B\n" + "}"); } TEST_F(FormatTestJS, MetadataAnnotations) { |

