clang-format: [JS] more precisely detect enums.
authorDaniel Jasper <djasper@google.com>
Sun, 15 Mar 2015 13:55:54 +0000 (13:55 +0000)
committerDaniel Jasper <djasper@google.com>
Sun, 15 Mar 2015 13:55:54 +0000 (13:55 +0000)
commit60948b12bb91dc38750d3a75c81d79edb86eda86
treea289a37b8e5d9c227e2dda9126261b5587973c1b
parent482284a8853c56ebd61dc9a7906be0fbd02b255d
clang-format: [JS] more precisely detect enums.

The current enum detection is overly aggressive. As NestingLevel only
applies per line (?) it classifies many if not most object literals as
enum declarations and adds superfluous line breaks into them. This
change narrows the heuristic by requiring an assignment just before the
open brace and requiring the line to start with an identifier.

Patch by Martin Probst. Thank you.

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