| 753 | } |
| 754 | |
| 755 | void BfPrinter::Visit(BfAstNode* bfAstNode) |
| 756 | { |
| 757 | SetAndRestoreValue<bool> prevForceTrivia(mForceUseTrivia); |
| 758 | |
| 759 | bool newExpectingNewLine = mNextStateModify.mWantNewLineIdx != mVirtualNewLineIdx; |
| 760 | if (newExpectingNewLine) |
| 761 | mExpectingNewLine = true; |
| 762 | bool expectingNewLine = mExpectingNewLine; |
| 763 | |
| 764 | int indentOffset = 0; |
| 765 | if (bfAstNode->GetTriviaStart() != -1) |
| 766 | { |
| 767 | if (newExpectingNewLine) |
| 768 | { |
| 769 | indentOffset = mNextStateModify.mWantVirtualIndent - mVirtualIndentLevel; |
| 770 | mVirtualIndentLevel += indentOffset; |
| 771 | mCurIndentLevel += indentOffset; |
| 772 | } |
| 773 | } |
| 774 | |
| 775 | while (true) |
| 776 | { |
| 777 | int sidechannelDist = -1; |
| 778 | if (mSidechannelNextNode != NULL) |
| 779 | sidechannelDist = bfAstNode->GetSrcStart() - mSidechannelNextNode->GetSrcStart(); |
| 780 | |
| 781 | int errorDist = -1; |
| 782 | if (mErrorNextNode != NULL) |
| 783 | errorDist = bfAstNode->GetSrcStart() - mErrorNextNode->GetSrcStart(); |
| 784 | |
| 785 | if ((sidechannelDist > 0) && (sidechannelDist >= errorDist)) |
| 786 | { |
| 787 | BF_ASSERT(!mInSideChannel); |
| 788 | mInSideChannel = true; |
| 789 | VisitChild(mSidechannelNextNode); |
| 790 | mInSideChannel = false; |
| 791 | ++mSidechannelItr; |
| 792 | mSidechannelNextNode = mSidechannelItr.Get(); |
| 793 | } |
| 794 | else if (errorDist > 0) |
| 795 | { |
| 796 | auto curErrorNode = mErrorNextNode; |
| 797 | ++mErrorItr; |
| 798 | mErrorNextNode = mErrorItr.Get(); |
| 799 | mForceUseTrivia = true; |
| 800 | VisitChild(curErrorNode); |
| 801 | } |
| 802 | else |
| 803 | break; |
| 804 | } |
| 805 | |
| 806 | Update(bfAstNode); |
| 807 | |
| 808 | // When triviaStart == -1, that indicates it's a combined node where the text we want to process is on the inside |
| 809 | if (bfAstNode->GetTriviaStart() != -1) |
| 810 | { |
| 811 | mTriviaIdx = std::max(mTriviaIdx, bfAstNode->GetTriviaStart()); |
| 812 | bool usedTrivia = false; |
nothing calls this directly
no test coverage detected