mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-09 03:52:19 +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);
|
std::stable_sort(nodeQueue.begin(), nodeQueue.end(), CompareNodeStart);
|
||||||
|
|
||||||
for (auto& node : nodeQueue)
|
ChildQueueState childQueueState;
|
||||||
{
|
childQueueState.mQueue = &nodeQueue;
|
||||||
mNextStateModify = node;
|
mActiveChildQueues.Add(&childQueueState);
|
||||||
|
|
||||||
VisitChild(node.mQueuedNode);
|
auto _HandleStateNotify = [&](StateModify node)
|
||||||
if (mVirtualNewLineIdx == mNextStateModify.mWantNewLineIdx)
|
{
|
||||||
mVirtualNewLineIdx = node.mWantNewLineIdx;
|
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)
|
void BfPrinter::VisitChildWithPrecedingSpace(BfAstNode* bfAstNode)
|
||||||
|
|
|
@ -49,6 +49,18 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct ChildQueueState
|
||||||
|
{
|
||||||
|
Array<StateModify>* mQueue;
|
||||||
|
int mIdx;
|
||||||
|
|
||||||
|
ChildQueueState()
|
||||||
|
{
|
||||||
|
mQueue = NULL;
|
||||||
|
mIdx = 0;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
BfSourceData* mSource;
|
BfSourceData* mSource;
|
||||||
BfParserData* mParser;
|
BfParserData* mParser;
|
||||||
|
|
||||||
|
@ -62,6 +74,7 @@ public:
|
||||||
|
|
||||||
int mTriviaIdx;
|
int mTriviaIdx;
|
||||||
int mCurSrcIdx;
|
int mCurSrcIdx;
|
||||||
|
Array<ChildQueueState*> mActiveChildQueues;
|
||||||
Array<StateModify> mChildNodeQueue;
|
Array<StateModify> mChildNodeQueue;
|
||||||
int mFormatStart;
|
int mFormatStart;
|
||||||
int mFormatEnd;
|
int mFormatEnd;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue