forked from OSchip/llvm-project
clang-format: [JS] Always add space after fat arrow.
Before: return () =>[]; After: return () => []; llvm-svn: 238875
This commit is contained in:
parent
b1f5879f3a
commit
e497beddb5
|
@ -1878,7 +1878,7 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line,
|
||||||
Left.isOneOf(Keywords.kw_returns, Keywords.kw_option))
|
Left.isOneOf(Keywords.kw_returns, Keywords.kw_option))
|
||||||
return true;
|
return true;
|
||||||
} else if (Style.Language == FormatStyle::LK_JavaScript) {
|
} else if (Style.Language == FormatStyle::LK_JavaScript) {
|
||||||
if (Left.is(Keywords.kw_var))
|
if (Left.isOneOf(Keywords.kw_var, TT_JsFatArrow))
|
||||||
return true;
|
return true;
|
||||||
if (Right.isOneOf(TT_JsTypeColon, TT_JsTypeOptionalQuestion))
|
if (Right.isOneOf(TT_JsTypeColon, TT_JsTypeOptionalQuestion))
|
||||||
return false;
|
return false;
|
||||||
|
@ -1958,10 +1958,9 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line,
|
||||||
return Style.SpaceAfterCStyleCast ||
|
return Style.SpaceAfterCStyleCast ||
|
||||||
Right.isOneOf(TT_BinaryOperator, TT_SelectorName);
|
Right.isOneOf(TT_BinaryOperator, TT_SelectorName);
|
||||||
|
|
||||||
if (Left.is(tok::greater) && Right.is(tok::greater)) {
|
if (Left.is(tok::greater) && Right.is(tok::greater))
|
||||||
return Right.is(TT_TemplateCloser) && Left.is(TT_TemplateCloser) &&
|
return Right.is(TT_TemplateCloser) && Left.is(TT_TemplateCloser) &&
|
||||||
(Style.Standard != FormatStyle::LS_Cpp11 || Style.SpacesInAngles);
|
(Style.Standard != FormatStyle::LS_Cpp11 || Style.SpacesInAngles);
|
||||||
}
|
|
||||||
if (Right.isOneOf(tok::arrow, tok::period, tok::arrowstar, tok::periodstar) ||
|
if (Right.isOneOf(tok::arrow, tok::period, tok::arrowstar, tok::periodstar) ||
|
||||||
Left.isOneOf(tok::arrow, tok::period, tok::arrowstar, tok::periodstar))
|
Left.isOneOf(tok::arrow, tok::period, tok::arrowstar, tok::periodstar))
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -484,6 +484,7 @@ TEST_F(FormatTestJS, ArrowFunctions) {
|
||||||
" return a;\n"
|
" return a;\n"
|
||||||
"};");
|
"};");
|
||||||
verifyFormat("var x = (a) => a;");
|
verifyFormat("var x = (a) => a;");
|
||||||
|
verifyFormat("return () => [];");
|
||||||
|
|
||||||
// FIXME: This is bad, we should be wrapping before "() => {".
|
// FIXME: This is bad, we should be wrapping before "() => {".
|
||||||
verifyFormat("someFunction(() => {\n"
|
verifyFormat("someFunction(() => {\n"
|
||||||
|
|
Loading…
Reference in New Issue