forked from OSchip/llvm-project
clang-format: [JS] recognized named functions in AnnotatingParser.
Summary: This also fixes union type formatting in function parameter types. Before: function x(path: number| string) {} After: function x(path: number|string) {} Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D21206 llvm-svn: 272330
This commit is contained in:
parent
4acea0aa22
commit
2ec2324f3c
|
@ -142,7 +142,10 @@ private:
|
|||
// static_assert, if and while usually contain expressions.
|
||||
Contexts.back().IsExpression = true;
|
||||
} else if (Style.Language == FormatStyle::LK_JavaScript && Left->Previous &&
|
||||
Left->Previous->is(Keywords.kw_function)) {
|
||||
(Left->Previous->is(Keywords.kw_function) ||
|
||||
(Left->Previous->endsSequence(tok::identifier,
|
||||
Keywords.kw_function)))) {
|
||||
// function(...) or function f(...)
|
||||
Contexts.back().IsExpression = false;
|
||||
} else if (Left->Previous && Left->Previous->is(tok::r_square) &&
|
||||
Left->Previous->MatchingParen &&
|
||||
|
|
|
@ -903,6 +903,8 @@ TEST_F(FormatTestJS, UnionIntersectionTypes) {
|
|||
verifyFormat("let x: Foo<A|B> = new Foo<A|B>();");
|
||||
verifyFormat("function(x: A|B): C&D {}");
|
||||
verifyFormat("function(x: A|B = A | B): C&D {}");
|
||||
verifyFormat("function x(path: number|string) {}");
|
||||
verifyFormat("function x(): string|number {}");
|
||||
}
|
||||
|
||||
TEST_F(FormatTestJS, ClassDeclarations) {
|
||||
|
|
Loading…
Reference in New Issue