1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-16 15:24:10 +02:00

Improved auto-ctor formatting

This commit is contained in:
Brian Fiete 2023-12-31 09:20:12 -05:00
parent 7057bcd099
commit 73265d82dd

View file

@ -2459,6 +2459,7 @@ void BfPrinter::Visit(BfConstructorDeclaration* ctorDeclaration)
{ {
//Visit((BfAstNode*)ctorDeclaration); //Visit((BfAstNode*)ctorDeclaration);
if (!ctorDeclaration->IsA<BfAutoConstructorDeclaration>())
ExpectNewLine(); ExpectNewLine();
if (ctorDeclaration->mAttributes != NULL) if (ctorDeclaration->mAttributes != NULL)
{ {
@ -3010,18 +3011,32 @@ void BfPrinter::Visit(BfTypeDeclaration* typeDeclaration)
ExpectSpace(); ExpectSpace();
QueueVisitChild(typeDeclaration->mNameNode); QueueVisitChild(typeDeclaration->mNameNode);
QueueVisitChild(typeDeclaration->mGenericParams); QueueVisitChild(typeDeclaration->mGenericParams);
QueueVisitChild(typeDeclaration->mAutoCtor);
if (typeDeclaration->mColonToken != NULL) if (typeDeclaration->mColonToken != NULL)
{ {
ExpectSpace(); ExpectSpace();
QueueVisitChild(typeDeclaration->mColonToken); QueueVisitChild(typeDeclaration->mColonToken);
}
if (typeDeclaration->mAutoCtor != NULL)
{
ExpectSpace();
QueueVisitChild(typeDeclaration->mAutoCtor);
}
if (typeDeclaration->mColonToken != NULL)
{
int nextCommaIdx = -1;
if (typeDeclaration->mAutoCtor != NULL)
nextCommaIdx++;
for (int i = 0; i < (int)typeDeclaration->mBaseClasses.size(); i++) for (int i = 0; i < (int)typeDeclaration->mBaseClasses.size(); i++)
{ {
ExpectSpace(); ExpectSpace();
QueueVisitChild(typeDeclaration->mBaseClasses[i]); QueueVisitChild(typeDeclaration->mBaseClasses[i]);
if (i > 0) if (nextCommaIdx >= 0)
{ {
QueueVisitChild(typeDeclaration->mBaseClassCommas.GetSafe(i - 1)); QueueVisitChild(typeDeclaration->mBaseClassCommas.GetSafe(nextCommaIdx));
} }
} }
ExpectSpace(); ExpectSpace();