| 1019 | // | unaryOperator exp; |
| 1020 | |
| 1021 | antlrcpp::Any FormatVisitor::visitExp(LuaParser::ExpContext* ctx) { |
| 1022 | LOG_FUNCTION_BEGIN(); |
| 1023 | if (ctx->linkOperator() != nullptr) { |
| 1024 | visitExp(ctx->exp()[0]); |
| 1025 | bool hasIncIndent = false; |
| 1026 | if (config_.get<bool>("break_after_operator")) { |
| 1027 | cur_writer() << commentAfter(ctx->exp()[0], " "); |
| 1028 | cur_writer() << ctx->linkOperator()->getText(); |
| 1029 | bool beyondLimit = false; |
| 1030 | pushWriter(); |
| 1031 | visitExp(ctx->exp()[1]); |
| 1032 | int length = cur_writer().firstLineColumn(); |
| 1033 | length++; // calc the white space after operator |
| 1034 | popWriter(); |
| 1035 | beyondLimit = cur_columns() + length > config_.get<int>("column_limit"); |
| 1036 | if (beyondLimit) { |
| 1037 | cur_writer() << commentAfterNewLine(ctx->linkOperator(), INC_CONTINUATION_INDENT); |
| 1038 | cur_writer() << indentWithAlign(); |
| 1039 | hasIncIndent = true; |
| 1040 | } else { |
| 1041 | cur_writer() << commentAfter(ctx->linkOperator(), " "); |
| 1042 | } |
| 1043 | visitExp(ctx->exp()[1]); |
| 1044 | } else { |
| 1045 | bool beyondLimit = false; |
| 1046 | pushWriter(); |
| 1047 | cur_writer() << ctx->linkOperator()->getText(); |
| 1048 | cur_writer() << commentAfter(ctx->linkOperator(), " "); |
| 1049 | visitExp(ctx->exp()[1]); |
| 1050 | int length = cur_writer().firstLineColumn(); |
| 1051 | popWriter(); |
| 1052 | beyondLimit = cur_columns() + length > config_.get<int>("column_limit"); |
| 1053 | if (beyondLimit) { |
| 1054 | cur_writer() << commentAfterNewLine(ctx->exp()[0], INC_CONTINUATION_INDENT); |
| 1055 | cur_writer() << indentWithAlign(); |
| 1056 | hasIncIndent = true; |
| 1057 | } else { |
| 1058 | cur_writer() << commentAfter(ctx->exp()[0], " "); |
| 1059 | } |
| 1060 | cur_writer() << ctx->linkOperator()->getText(); |
| 1061 | cur_writer() << commentAfter(ctx->linkOperator(), " "); |
| 1062 | visitExp(ctx->exp()[1]); |
| 1063 | } |
| 1064 | if (hasIncIndent) { |
| 1065 | decContinuationIndent(); |
| 1066 | } |
| 1067 | } else if (ctx->unaryOperator() != nullptr) { |
| 1068 | cur_writer() << ctx->unaryOperator()->getText(); |
| 1069 | if (ctx->unaryOperator()->getText() == "not") { |
| 1070 | cur_writer() << commentAfter(ctx->unaryOperator(), " "); |
| 1071 | } else { |
| 1072 | if (ctx->unaryOperator()->getText() == "-" && ctx->exp().front()->getText()[0] == '-') { |
| 1073 | cur_writer() << commentAfter(ctx->unaryOperator(), " "); |
| 1074 | } else { |
| 1075 | cur_writer() << commentAfter(ctx->unaryOperator(), ""); |
| 1076 | } |
| 1077 | } |
| 1078 | visitExp(ctx->exp().front()); |
nothing calls this directly
no test coverage detected