return;
case tok::identifier: {
StringRef Text = FormatTok->TokenText;
+ if (Style.Language == FormatStyle::LK_JavaScript && Text == "function") {
+ tryToParseJSFunction();
+ break;
+ }
nextToken();
if (Line->Tokens.size() == 1) {
if (FormatTok->Tok.is(tok::colon)) {
return Result;
}
- static std::string format(llvm::StringRef Code, const FormatStyle &Style) {
+ static std::string format(
+ llvm::StringRef Code,
+ const FormatStyle &Style = getGoogleStyle(FormatStyle::LK_JavaScript)) {
return format(Code, 0, Code.size(), Style);
}
" style: {direction: ''}\n"
" }\n"
"};");
+ EXPECT_EQ("abc = xyz ? function() { return 1; } : function() { return -1; };",
+ format("abc=xyz?function(){return 1;}:function(){return -1;};"));
}
TEST_F(FormatTestJS, ReturnStatements) {