MCPcopy Create free account
hub / github.com/Koihik/LuaFormatter / buildFirstArgumentWs

Method buildFirstArgumentWs

src/FormatVisitor.cpp:368–388  ·  view source on GitHub ↗

Builds first argument whitespace in spaces. local a = f {1, 2, 3} or f "a"

Source from the content-addressed store, hash-verified

366// Builds first argument whitespace in spaces.
367// local a = f<WS>{1, 2, 3} or f<WS>"a"
368std::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"...

Callers

nothing calls this directly

Calls 3

COLONMethod · 0.80
LPMethod · 0.80
argsMethod · 0.80

Tested by

no test coverage detected