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

Method visitBlockAndComment

src/FormatVisitor.cpp:1829–1852  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1827}
1828
1829void FormatVisitor::visitBlockAndComment(tree::ParseTree* previousNode, LuaParser::BlockContext* ctx,
1830 BlockType blockType) {
1831 LOG_FUNCTION_BEGIN();
1832 bool oneline = needKeepBlockOneLine(previousNode, ctx, blockType);
1833 if (oneline) {
1834 cur_writer() << commentAfter(previousNode, " ");
1835 bool temp = chop_down_block_;
1836 chop_down_block_ = false;
1837 visitBlock(ctx);
1838 chop_down_block_ = temp;
1839 if (!isBlockEmpty(ctx)) {
1840 cur_writer() << commentAfter(ctx, " ");
1841 }
1842 } else {
1843 cur_writer() << commentAfterNewLine(previousNode, INC_INDENT);
1844 bool temp = chop_down_block_;
1845 chop_down_block_ = true;
1846 visitBlock(ctx);
1847 chop_down_block_ = temp;
1848 cur_writer() << commentAfterNewLine(ctx, DEC_INDENT);
1849 cur_writer() << indent();
1850 }
1851 LOG_FUNCTION_END();
1852}
1853
1854std::string FormatVisitor::indent() {
1855 std::stringstream ss;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected