Builds first argument whitespace in spaces. local a = f {1, 2, 3} or f "a"
| 366 | // Builds first argument whitespace in spaces. |
| 367 | // local a = f<WS>{1, 2, 3} or f<WS>"a" |
| 368 | std::string FormatVisitor::buildFirstArgumentWs(std::vector<LuaParser::NameAndArgsContext*> v) { |
| 369 | bool needWhiteSpace = false; |
| 370 | |
| 371 | if (!v.empty()) { |
| 372 | LuaParser::NameAndArgsContext* ctx = v.front(); |
| 373 | if (ctx->COLON() == nullptr && ctx->args()->LP() == nullptr) { |
| 374 | needWhiteSpace = true; |
| 375 | } |
| 376 | } |
| 377 | |
| 378 | // Build whitespace |
| 379 | std::string ws; |
| 380 | if (needWhiteSpace) { |
| 381 | int sz = config_.get<int>("spaces_before_call"); |
| 382 | while ((sz--) != 0) { |
| 383 | ws.append(" "); |
| 384 | } |
| 385 | } |
| 386 | |
| 387 | return ws; |
| 388 | } |
| 389 | |
| 390 | // Builds arguments whitespaces in spaces. |
| 391 | // local a = f"a"<WS>"b"<WS>"c"... |