| 4626 | } |
| 4627 | |
| 4628 | void StyledWriter::writeArrayValue(const Value& value) { |
| 4629 | unsigned size = value.size(); |
| 4630 | if (size == 0) |
| 4631 | pushValue("[]"); |
| 4632 | else { |
| 4633 | bool isArrayMultiLine = isMultilineArray(value); |
| 4634 | if (isArrayMultiLine) { |
| 4635 | writeWithIndent("["); |
| 4636 | indent(); |
| 4637 | bool hasChildValue = !childValues_.empty(); |
| 4638 | unsigned index = 0; |
| 4639 | for (;;) { |
| 4640 | const Value& childValue = value[index]; |
| 4641 | writeCommentBeforeValue(childValue); |
| 4642 | if (hasChildValue) |
| 4643 | writeWithIndent(childValues_[index]); |
| 4644 | else { |
| 4645 | writeIndent(); |
| 4646 | writeValue(childValue); |
| 4647 | } |
| 4648 | if (++index == size) { |
| 4649 | writeCommentAfterValueOnSameLine(childValue); |
| 4650 | break; |
| 4651 | } |
| 4652 | document_ += ','; |
| 4653 | writeCommentAfterValueOnSameLine(childValue); |
| 4654 | } |
| 4655 | unindent(); |
| 4656 | writeWithIndent("]"); |
| 4657 | } else // output on a single line |
| 4658 | { |
| 4659 | assert(childValues_.size() == size); |
| 4660 | document_ += "[ "; |
| 4661 | for (unsigned index = 0; index < size; ++index) { |
| 4662 | if (index > 0) |
| 4663 | document_ += ", "; |
| 4664 | document_ += childValues_[index]; |
| 4665 | } |
| 4666 | document_ += " ]"; |
| 4667 | } |
| 4668 | } |
| 4669 | } |
| 4670 | |
| 4671 | bool StyledWriter::isMultilineArray(const Value& value) { |
| 4672 | ArrayIndex const size = value.size(); |