mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 03:28:20 +02:00
Formatting fix for inline types with interleaved member access/attribute
This commit is contained in:
parent
958a1630aa
commit
2c48f26536
2 changed files with 44 additions and 6 deletions
|
@ -209,14 +209,39 @@ void BfPrinter::FlushVisitChild()
|
|||
|
||||
std::stable_sort(nodeQueue.begin(), nodeQueue.end(), CompareNodeStart);
|
||||
|
||||
for (auto& node : nodeQueue)
|
||||
{
|
||||
mNextStateModify = node;
|
||||
ChildQueueState childQueueState;
|
||||
childQueueState.mQueue = &nodeQueue;
|
||||
mActiveChildQueues.Add(&childQueueState);
|
||||
|
||||
VisitChild(node.mQueuedNode);
|
||||
if (mVirtualNewLineIdx == mNextStateModify.mWantNewLineIdx)
|
||||
mVirtualNewLineIdx = node.mWantNewLineIdx;
|
||||
auto _HandleStateNotify = [&](StateModify node)
|
||||
{
|
||||
mNextStateModify = node;
|
||||
|
||||
VisitChild(node.mQueuedNode);
|
||||
if (mVirtualNewLineIdx == mNextStateModify.mWantNewLineIdx)
|
||||
mVirtualNewLineIdx = node.mWantNewLineIdx;
|
||||
};
|
||||
|
||||
while (childQueueState.mIdx < childQueueState.mQueue->mSize)
|
||||
{
|
||||
auto node = (*childQueueState.mQueue)[childQueueState.mIdx++];
|
||||
if (mActiveChildQueues.mSize > 1)
|
||||
{
|
||||
// Check for nodes in the prev queue that are actual inside the new queue (can happen with inline type declarations)
|
||||
auto prevQueue = mActiveChildQueues[mActiveChildQueues.mSize - 2];
|
||||
while (true)
|
||||
{
|
||||
auto prevQueueNode = (*prevQueue->mQueue)[prevQueue->mIdx];
|
||||
if (prevQueueNode.mQueuedNode->mSrcStart >= node.mQueuedNode->mSrcStart)
|
||||
break;
|
||||
prevQueue->mIdx++;
|
||||
_HandleStateNotify(prevQueueNode);
|
||||
}
|
||||
}
|
||||
_HandleStateNotify(node);
|
||||
}
|
||||
|
||||
mActiveChildQueues.pop_back();
|
||||
}
|
||||
|
||||
void BfPrinter::VisitChildWithPrecedingSpace(BfAstNode* bfAstNode)
|
||||
|
|
|
@ -49,6 +49,18 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
struct ChildQueueState
|
||||
{
|
||||
Array<StateModify>* mQueue;
|
||||
int mIdx;
|
||||
|
||||
ChildQueueState()
|
||||
{
|
||||
mQueue = NULL;
|
||||
mIdx = 0;
|
||||
}
|
||||
};
|
||||
|
||||
BfSourceData* mSource;
|
||||
BfParserData* mParser;
|
||||
|
||||
|
@ -62,6 +74,7 @@ public:
|
|||
|
||||
int mTriviaIdx;
|
||||
int mCurSrcIdx;
|
||||
Array<ChildQueueState*> mActiveChildQueues;
|
||||
Array<StateModify> mChildNodeQueue;
|
||||
int mFormatStart;
|
||||
int mFormatEnd;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue