llvm-project/clang/lib/Format
Martin Probst 95ed8e7928 clang-format: [JS] improve calculateBraceType heuristic
Summary:

calculateBraceTypes decides for braced init for empty brace pairs ({}).
In context of a function declaration, this incorrectly classifies empty
function or method bodies as braced inits, leading to missing wraps:

    class C {
      foo() {}[bar]() {}
    }

Where code should have wrapped after "}", before "[". This change adds
another piece of contextual information in that braces following closing
parentheses must always be the opening braces of function blocks. This
fixes brace detection for methods immediately followed by brackets
(computed property declarations), but also curlies.

Reviewers: djasper

Subscribers: klimek, cfe-commits

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

llvm-svn: 304290
2017-05-31 09:29:40 +00:00
..
AffectedRangeManager.cpp Added Fixer implementation and fix() interface in clang-format for removing redundant code. 2016-04-25 15:09:22 +00:00
AffectedRangeManager.h removed redundant '#' 2016-04-28 07:52:06 +00:00
BreakableToken.cpp clang-format: do not reflow bullet lists 2017-05-22 14:47:17 +00:00
BreakableToken.h [clang-format] Reformat BreakableToken.h; NFC 2017-03-08 08:58:44 +00:00
CMakeLists.txt [clang-format] Add a NamespaceEndCommentsFixer 2017-02-27 13:28:36 +00:00
ContinuationIndenter.cpp clang-format: [JS] fix indenting bound functions. 2017-05-29 07:50:52 +00:00
ContinuationIndenter.h [clang-format] Refactor WhitespaceManager and friends 2017-01-31 11:25:01 +00:00
Encoding.h [Format] Remove dead code. 2016-12-19 21:10:50 +00:00
Format.cpp clang-format: [JS] do not clean up duplicated commas. 2017-05-29 08:41:11 +00:00
FormatToken.cpp clang-format: Fix bug in handling of single-column lists. 2016-12-21 17:02:06 +00:00
FormatToken.h clang-format: [JS] exponentiation operator 2017-05-04 15:04:04 +00:00
FormatTokenLexer.cpp clang-format: [JS] exponentiation operator 2017-05-04 15:04:04 +00:00
FormatTokenLexer.h [clang-format] Handle NSString literals by merging tokens. 2017-04-11 09:55:00 +00:00
NamespaceEndCommentsFixer.cpp [clang-format] fix crash in NamespaceEndCommentsFixer (PR32438) 2017-04-04 20:11:13 +00:00
NamespaceEndCommentsFixer.h [clang-format] Add a NamespaceEndCommentsFixer 2017-02-27 13:28:36 +00:00
SortJavaScriptImports.cpp Use after move bug fixes 2016-12-23 11:40:44 +00:00
SortJavaScriptImports.h clang-format: [JS] sort ES6 imports. 2016-05-20 11:24:24 +00:00
TokenAnalyzer.cpp Don't copy replacements in for-range loop. NFC. 2016-10-19 13:50:17 +00:00
TokenAnalyzer.h [Format] Remove dead code. 2016-12-19 21:10:50 +00:00
TokenAnnotator.cpp clang-format: Introduce BreakConstructorInitializers option 2017-05-24 11:36:58 +00:00
TokenAnnotator.h [clang-format] Add a NamespaceEndCommentsFixer 2017-02-27 13:28:36 +00:00
UnwrappedLineFormatter.cpp [clang-format] Make NoLineBreakFormatter respect MustBreakBefore 2017-05-18 08:07:52 +00:00
UnwrappedLineFormatter.h [clang-format] Replace IncompleteFormat by a struct with Line 2017-04-21 14:35:20 +00:00
UnwrappedLineParser.cpp clang-format: [JS] improve calculateBraceType heuristic 2017-05-31 09:29:40 +00:00
UnwrappedLineParser.h [clang-format] Add a NamespaceEndCommentsFixer 2017-02-27 13:28:36 +00:00
WhitespaceManager.cpp [clang-format] Convert AlignEscapedNewlinesLeft to an enum, adding 2017-05-08 15:08:00 +00:00
WhitespaceManager.h Fix issues in clang-format's AlignConsecutive modes. 2017-03-23 02:51:25 +00:00