| 4505 | } |
| 4506 | |
| 4507 | void StyledWriter::writeArrayValue(const Value& value) { |
| 4508 | unsigned size = value.size(); |
| 4509 | if (size == 0) |
| 4510 | pushValue("[]"); |
| 4511 | else { |
| 4512 | bool isArrayMultiLine = isMultineArray(value); |
| 4513 | if (isArrayMultiLine) { |
| 4514 | writeWithIndent("["); |
| 4515 | indent(); |
| 4516 | bool hasChildValue = !childValues_.empty(); |
| 4517 | unsigned index = 0; |
| 4518 | for (;;) { |
| 4519 | const Value& childValue = value[index]; |
| 4520 | writeCommentBeforeValue(childValue); |
| 4521 | if (hasChildValue) |
| 4522 | writeWithIndent(childValues_[index]); |
| 4523 | else { |
| 4524 | writeIndent(); |
| 4525 | writeValue(childValue); |
| 4526 | } |
| 4527 | if (++index == size) { |
| 4528 | writeCommentAfterValueOnSameLine(childValue); |
| 4529 | break; |
| 4530 | } |
| 4531 | document_ += ','; |
| 4532 | writeCommentAfterValueOnSameLine(childValue); |
| 4533 | } |
| 4534 | unindent(); |
| 4535 | writeWithIndent("]"); |
| 4536 | } else // output on a single line |
| 4537 | { |
| 4538 | assert(childValues_.size() == size); |
| 4539 | document_ += "[ "; |
| 4540 | for (unsigned index = 0; index < size; ++index) { |
| 4541 | if (index > 0) |
| 4542 | document_ += ", "; |
| 4543 | document_ += childValues_[index]; |
| 4544 | } |
| 4545 | document_ += " ]"; |
| 4546 | } |
| 4547 | } |
| 4548 | } |
| 4549 | |
| 4550 | bool StyledWriter::isMultineArray(const Value& value) { |
| 4551 | int size = value.size(); |