llvm-project/clang/lib/Format
Martin Probst 325ff7c5e0 clang-format: [JS] wrap optional properties in type aliases.
Summary:
clang-format wraps object literal keys in an object literal if they are
marked as `TT_SelectorName`s and/or the colon is marked as
`TT_DictLiteral`. Previously, clang-format would accidentally work
because colons in type aliases were marked as `TT_DictLiteral`. r310367
fixed this to assing `TT_JsTypeColon`, which broke wrapping in certain
situations. However the root cause was that clang-format incorrectly
didn't skip questionmarks when detecting selector name.

This change fixes both locations to (1) assign `TT_SelectorName` and (2)
treat `TT_JsTypeColon` like `TT_DictLiteral`.

Previously:

    type X = {
      a: string, b?: string,
    };

Now:

    type X = {
      a: string,
      b?: string,
    };

Reviewers: djasper, sammccall

Subscribers: cfe-commits, klimek

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

llvm-svn: 310852
2017-08-14 16:09:08 +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] Put '/**' and '*/' on own lines in jsdocs ending in comment pragmas 2017-08-09 09:42:32 +00:00
BreakableToken.h [clang-format] Put '/**' and '*/' on own lines in jsdocs ending in comment pragmas 2017-08-09 09:42:32 +00:00
CMakeLists.txt [clang-format] Support sorting using declarations 2017-06-21 12:03:12 +00:00
ContinuationIndenter.cpp [clang-format] Put '/**' and '*/' on own lines in jsdocs ending in comment pragmas 2017-08-09 09:42:32 +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] Support text proto messages 2017-07-03 15:05:14 +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] no whitespace between typeof operator and l_paren. 2017-08-01 17:42:16 +00:00
FormatTokenLexer.cpp clang-format: [JS] handle single lines comments ending in `\\`. 2017-08-08 14:52:42 +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 a clang-tidy warning, NFC 2017-06-27 14:07:45 +00:00
NamespaceEndCommentsFixer.h [clang-format] Add a NamespaceEndCommentsFixer 2017-02-27 13:28:36 +00:00
SortJavaScriptImports.cpp clang-format: [JS] support default imports. 2017-08-01 15:54:43 +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: [JS] wrap optional properties in type aliases. 2017-08-14 16:09:08 +00:00
TokenAnnotator.h [clang-format] Add a NamespaceEndCommentsFixer 2017-02-27 13:28:36 +00:00
UnwrappedLineFormatter.cpp clang-format: merge short case labels with trailing comments 2017-07-28 07:56:18 +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] detect ASI after closing parens. 2017-08-09 15:19:16 +00:00
UnwrappedLineParser.h clang-format: fix block OpeningLineIndex around preprocessor 2017-07-28 07:56:14 +00:00
UsingDeclarationsSorter.cpp [clang-format] Support sorting using declarations 2017-06-21 12:03:12 +00:00
UsingDeclarationsSorter.h [clang-format] Support sorting using declarations 2017-06-21 12:03:12 +00:00
WhitespaceManager.cpp clang-format: Fix bug with ENAS_DontAlign and empty lines 2017-08-10 00:15:31 +00:00
WhitespaceManager.h clang-format: Fix bug with ENAS_DontAlign and empty lines 2017-08-10 00:15:31 +00:00