feat: non-conditional template constraints styles
The non-conditional styles for `dfmt_template_constraint_style` are supported for now. The conditional ones will require line length tracking, which is yet to be implmented. Signed-off-by: Prajwal S N <prajwalnadig21@gmail.com>
This commit is contained in:
parent
0259887791
commit
0897c83e86
|
@ -3224,12 +3224,38 @@ extern (C++) class FormatVisitor : SemanticTimeTransitiveVisitor
|
||||||
{
|
{
|
||||||
if (!constraint)
|
if (!constraint)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
final switch (config.dfmt_template_constraint_style)
|
||||||
|
{
|
||||||
|
case TemplateConstraintStyle._unspecified:
|
||||||
|
// Fallthrough to the default case
|
||||||
|
case TemplateConstraintStyle.conditional_newline_indent:
|
||||||
|
// This will be updated later on
|
||||||
|
goto case;
|
||||||
|
case TemplateConstraintStyle.always_newline_indent:
|
||||||
|
newline();
|
||||||
|
depth++;
|
||||||
|
break;
|
||||||
|
case TemplateConstraintStyle.conditional_newline:
|
||||||
|
// This will be updated later on
|
||||||
|
goto case;
|
||||||
|
case TemplateConstraintStyle.always_newline:
|
||||||
|
newline();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
write(" if");
|
write(" if");
|
||||||
if (config.dfmt_space_after_keywords)
|
if (config.dfmt_space_after_keywords)
|
||||||
write(' ');
|
write(' ');
|
||||||
write('(');
|
write('(');
|
||||||
writeExpr(constraint);
|
writeExpr(constraint);
|
||||||
write(')');
|
write(')');
|
||||||
|
|
||||||
|
if (config.dfmt_template_constraint_style == TemplateConstraintStyle.always_newline_indent ||
|
||||||
|
// This condition will be updated later on
|
||||||
|
config.dfmt_template_constraint_style == TemplateConstraintStyle
|
||||||
|
.conditional_newline_indent)
|
||||||
|
depth--;
|
||||||
}
|
}
|
||||||
|
|
||||||
override void visitBaseClasses(ASTCodegen.ClassDeclaration d)
|
override void visitBaseClasses(ASTCodegen.ClassDeclaration d)
|
||||||
|
|
Loading…
Reference in New Issue