]> granicus.if.org Git - clang/commit
clang-format: [JS] disable ASI on decorators.
authorMartin Probst <martin@probst.io>
Sat, 25 Nov 2017 09:19:42 +0000 (09:19 +0000)
committerMartin Probst <martin@probst.io>
Sat, 25 Nov 2017 09:19:42 +0000 (09:19 +0000)
commit47e4a29e874ca493876a9cfbf6eea8c457eb919e
tree24ef057a61745a2f6ad7c205d4b7bf5d808733d9
parent2aaf2c944d6c06d42df47ae4fa107a0bc8259fd7
clang-format: [JS] disable ASI on decorators.

Summary:
Automatic Semicolon Insertion in clang-format tries to guess if a line
wrap should insert an implicit semicolong. The previous heuristic would
not trigger ASI if a token was immediately preceded by an `@` sign:

    function foo(@Bar  // <-- does not trigger due to preceding @
                baz) {}

However decorators can have arbitrary parameters:

    function foo(@Bar(param, param, param)  // <-- precending @ missed
                baz) {}

While it would be possible to precisely find the matching `@`, just
conversatively disabling ASI for the entire line is simpler, while also
not regressing ASI substatially.

Reviewers: djasper

Subscribers: klimek, cfe-commits

Differential Revision: https://reviews.llvm.org/D40410

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@318973 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Format/UnwrappedLineParser.cpp
unittests/Format/FormatTestJS.cpp