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

Method visitNameAndArgs

src/FormatVisitor.cpp:1358–1396  ·  view source on GitHub ↗

(COLON NAME)? args;

Source from the content-addressed store, hash-verified

1356
1357// (COLON NAME)? args;
1358antlrcpp::Any FormatVisitor::visitNameAndArgs(LuaParser::NameAndArgsContext* ctx) {
1359 LOG_FUNCTION_BEGIN();
1360 if (ctx->COLON() != nullptr) {
1361 bool beyondLimit = false;
1362 LuaParser::StringContext* stringContext = ctx->args()->string();
1363 bool needWhiteSpace = stringContext != nullptr;
1364 if (!chainedMethodCallIsFirst_.back()) {
1365 chainedMethodCallIsFirst_[chainedMethodCallIsFirst_.size() - 1] = true;
1366 } else {
1367 int length = calcASTLengthAndLines(ctx->args(), [=]() {
1368 cur_writer() << ctx->COLON()->getText();
1369 cur_writer() << commentAfter(ctx->COLON(), "");
1370 cur_writer() << ctx->NAME()->getText();
1371 cur_writer() << commentAfter(ctx->NAME(), needWhiteSpace ? " " : "");
1372 visitArgs(ctx->args());
1373 }).first;
1374 beyondLimit = cur_columns() + length > config_.get<int>("column_limit");
1375 }
1376 if (beyondLimit) {
1377 cur_writer() << "\n";
1378 if (chainedMethodCallHasIncIndent_.back()) {
1379 cur_writer() << indentWithAlign();
1380 } else {
1381 incContinuationIndent();
1382 cur_writer() << indentWithAlign();
1383 chainedMethodCallHasIncIndent_[chainedMethodCallHasIncIndent_.size() - 1] = true;
1384 }
1385 }
1386 cur_writer() << ctx->COLON()->getText();
1387 cur_writer() << commentAfter(ctx->COLON(), "");
1388 cur_writer() << ctx->NAME()->getText();
1389 cur_writer() << commentAfter(ctx->NAME(), needWhiteSpace ? " " : "");
1390 visitArgs(ctx->args());
1391 } else {
1392 visitArgs(ctx->args());
1393 }
1394 LOG_FUNCTION_END();
1395 return nullptr;
1396}
1397
1398// LP explist? RP | tableconstructor | string;
1399antlrcpp::Any FormatVisitor::visitArgs(LuaParser::ArgsContext* ctx) {

Callers

nothing calls this directly

Calls 4

COLONMethod · 0.80
stringMethod · 0.80
argsMethod · 0.80
NAMEMethod · 0.80

Tested by

no test coverage detected