feat: add 4 transformations
- dfmt_space_before_function_parameters - dfmt_space_after_cast - dfmt_align_switch_statements - dfmt_space_before_aa_colon Signed-off-by: Prajwal S N <prajwalnadig21@gmail.com>
This commit is contained in:
parent
ded6e8d37b
commit
90c9040898
|
@ -113,7 +113,7 @@ dfmt_align_switch_statements | **`true`**, `false` | Align labels, cases, and de
|
|||
dfmt_outdent_attributes (Not yet implemented) | **`true`**, `false`| Decrease the indentation level of attributes.
|
||||
dfmt_split_operator_at_line_end | `true`, **`false`** | Place operators on the end of the previous line when splitting lines.
|
||||
dfmt_space_after_cast | **`true`**, `false` | Insert space after the closing paren of a `cast` expression.
|
||||
dfmt_space_after_keywords (Not yet implemented) | **`true`**, `false` | Insert space after `if`, `while`, `foreach`, etc, and before the `(`.
|
||||
dfmt_space_after_keywords | **`true`**, `false` | Insert space after `if`, `while`, `foreach`, etc, and before the `(`.
|
||||
dfmt_space_before_function_parameters | `true`, **`false`** | Insert space before the opening paren of a function parameter list.
|
||||
dfmt_selective_import_space | **`true`**, `false` | Insert space after the module name and before the `:` for selective imports.
|
||||
dfmt_compact_labeled_statements | **`true`**, `false` | Place labels on the same line as the labeled `switch`, `for`, `foreach`, or `while` statement.
|
||||
|
@ -124,7 +124,6 @@ dfmt_space_before_named_arg_colon | `true`, **`false`** | Adds a space after a n
|
|||
dfmt_keep_line_breaks | `true`, **`false`** | Keep existing line breaks if these don't violate other formatting rules.
|
||||
dfmt_single_indent | `true`, **`false`** | Set if the code in parens is indented by a single tab instead of two.
|
||||
dfmt_reflow_property_chains | **`true`**, `false` | Recalculate the splitting of property chains into multiple lines.
|
||||
dfmt_space_after_keywords | **`true`**, `false` | Insert space after keywords (if,while,foreach,for, etc.).
|
||||
|
||||
## Terminology
|
||||
* Braces - `{` and `}`
|
||||
|
|
|
@ -385,6 +385,8 @@ extern (C++) class FormatVisitor : SemanticTimeTransitiveVisitor
|
|||
if (i)
|
||||
write(", ");
|
||||
writeExprWithPrecedence(key, PREC.assign);
|
||||
if (config.dfmt_space_before_aa_colon == OptionalBoolean.t)
|
||||
write(' ');
|
||||
write(": ");
|
||||
auto value = (*e.values)[i];
|
||||
writeExprWithPrecedence(value, PREC.assign);
|
||||
|
@ -792,6 +794,10 @@ extern (C++) class FormatVisitor : SemanticTimeTransitiveVisitor
|
|||
write(MODtoString(e.mod));
|
||||
}
|
||||
write(')');
|
||||
if (config.dfmt_space_after_cast)
|
||||
{
|
||||
write(' ');
|
||||
}
|
||||
writeExprWithPrecedence(e.e1, precedence[e.op]);
|
||||
}
|
||||
|
||||
|
@ -1589,6 +1595,8 @@ extern (C++) class FormatVisitor : SemanticTimeTransitiveVisitor
|
|||
|
||||
void visitCase(ASTCodegen.CaseStatement s)
|
||||
{
|
||||
if (config.dfmt_align_switch_statements)
|
||||
depth--;
|
||||
write("case ");
|
||||
writeExpr(s.exp);
|
||||
write(':');
|
||||
|
@ -1596,6 +1604,8 @@ extern (C++) class FormatVisitor : SemanticTimeTransitiveVisitor
|
|||
insideCase = true;
|
||||
writeStatement(s.statement);
|
||||
insideCase = false;
|
||||
if (config.dfmt_align_switch_statements)
|
||||
depth++;
|
||||
}
|
||||
|
||||
void visitCaseRange(ASTCodegen.CaseRangeStatement s)
|
||||
|
@ -1611,9 +1621,13 @@ extern (C++) class FormatVisitor : SemanticTimeTransitiveVisitor
|
|||
|
||||
void visitDefault(ASTCodegen.DefaultStatement s)
|
||||
{
|
||||
if (config.dfmt_align_switch_statements)
|
||||
depth--;
|
||||
write("default:");
|
||||
newline();
|
||||
writeStatement(s.statement);
|
||||
if (config.dfmt_align_switch_statements)
|
||||
depth++;
|
||||
}
|
||||
|
||||
void visitGotoDefault(ASTCodegen.GotoDefaultStatement _)
|
||||
|
@ -1978,7 +1992,9 @@ extern (C++) class FormatVisitor : SemanticTimeTransitiveVisitor
|
|||
if (ex)
|
||||
{
|
||||
writeExpr(ex);
|
||||
write(':');
|
||||
if (config.dfmt_space_before_aa_colon == OptionalBoolean.t)
|
||||
write(' ');
|
||||
write(": ");
|
||||
}
|
||||
if (auto iz = ai.value[i])
|
||||
writeInitializer(iz);
|
||||
|
@ -2602,6 +2618,8 @@ extern (C++) class FormatVisitor : SemanticTimeTransitiveVisitor
|
|||
|
||||
void writeParamList(ParameterList pl)
|
||||
{
|
||||
if (config.dfmt_space_before_function_parameters)
|
||||
write(' ');
|
||||
write('(');
|
||||
foreach (i; 0 .. pl.length)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue