forked from OSchip/llvm-project
clang-format: [JS] Assign proper penalties when breaking a type annotation
Before: class Test { aaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaa: aaaaaaaaaaaaaaaaaaaaaaaa): aaaaaaaaaaaaaaaaaaaaaa {} } After: class Test { aaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaa: aaaaaaaaaaaaaaaaaaaaaaaa): aaaaaaaaaaaaaaaaaaaaaa {} } llvm-svn: 241908
This commit is contained in:
parent
4f8d26230c
commit
b9a52814bf
|
@ -1628,6 +1628,8 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line,
|
|||
} else if (Style.Language == FormatStyle::LK_JavaScript) {
|
||||
if (Right.is(Keywords.kw_function) && Left.isNot(tok::comma))
|
||||
return 100;
|
||||
if (Left.is(TT_JsTypeColon))
|
||||
return 100;
|
||||
}
|
||||
|
||||
if (Left.is(tok::comma) || (Right.is(tok::identifier) && Right.Next &&
|
||||
|
|
|
@ -687,6 +687,10 @@ TEST_F(FormatTestJS, ClassDeclarations) {
|
|||
verifyFormat("class C {\n static x(): string { return 'asd'; }\n}");
|
||||
verifyFormat("class C extends P implements I {}");
|
||||
verifyFormat("class C extends p.P implements i.I {}");
|
||||
verifyFormat("class Test {\n"
|
||||
" aaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaa: aaaaaaaaaaaaaaaaaaaa):\n"
|
||||
" aaaaaaaaaaaaaaaaaaaaaa {}\n"
|
||||
"}");
|
||||
|
||||
// ':' is not a type declaration here.
|
||||
verifyFormat("class X {\n"
|
||||
|
|
Loading…
Reference in New Issue