Implement #130
This commit is contained in:
parent
959405eda5
commit
bef02a3b55
|
|
@ -36,7 +36,6 @@ found in .editorconfig files.
|
||||||
* **--max_line_length**: See **max_line_length** below
|
* **--max_line_length**: See **max_line_length** below
|
||||||
* **--soft_max_line_length**: See **dfmt_soft_max_line_length** below
|
* **--soft_max_line_length**: See **dfmt_soft_max_line_length** below
|
||||||
* **--outdent_attributes**: See **dfmt_outdent_attributes** below
|
* **--outdent_attributes**: See **dfmt_outdent_attributes** below
|
||||||
* **--outdent_labels**: See **dfmt_outdent_labels** below
|
|
||||||
* **--space_after_cast**: See **dfmt_space_after_cast** below
|
* **--space_after_cast**: See **dfmt_space_after_cast** below
|
||||||
* **--split_operator_at_line_end**: See **dfmt_split_operator_at_line_end** below
|
* **--split_operator_at_line_end**: See **dfmt_split_operator_at_line_end** below
|
||||||
* **--tab_width**: See **tab_width** below
|
* **--tab_width**: See **tab_width** below
|
||||||
|
|
@ -90,7 +89,6 @@ Property Name | Allowed Values | Default Value | Description
|
||||||
--------------|----------------|---------------|------------
|
--------------|----------------|---------------|------------
|
||||||
dfmt_brace_style | `allman`, `otbs`, or `stroustrup` | `allman` | [See Wikipedia](https://en.wikipedia.org/wiki/Brace_style)
|
dfmt_brace_style | `allman`, `otbs`, or `stroustrup` | `allman` | [See Wikipedia](https://en.wikipedia.org/wiki/Brace_style)
|
||||||
dfmt_soft_max_line_length | positive integers | `80` | The formatting process will usually keep lines below this length, but they may be up to max_line_length columns long.
|
dfmt_soft_max_line_length | positive integers | `80` | The formatting process will usually keep lines below this length, but they may be up to max_line_length columns long.
|
||||||
dfmt_outdent_labels (Not yet implemented) | `true`, `false` | `true` | Decrease the indentation of labels
|
|
||||||
dfmt_align_switch_statements (Not yet implemented) | `true`, `false` | `true` | Align labels, cases, and defaults with their enclosing switch
|
dfmt_align_switch_statements (Not yet implemented) | `true`, `false` | `true` | Align labels, cases, and defaults with their enclosing switch
|
||||||
dfmt_outdent_attributes (Not yet implemented) | `true`, `false` | `true` | Decrease the indentation level of attributes
|
dfmt_outdent_attributes (Not yet implemented) | `true`, `false` | `true` | Decrease the indentation level of attributes
|
||||||
dfmt_split_operator_at_line_end | `true`, `false` | `false` | Place operators on the end of the previous line when splitting lines
|
dfmt_split_operator_at_line_end | `true`, `false` | `false` | Place operators on the end of the previous line when splitting lines
|
||||||
|
|
|
||||||
|
|
@ -29,8 +29,6 @@ struct Config
|
||||||
///
|
///
|
||||||
OptionalBoolean dfmt_outdent_attributes;
|
OptionalBoolean dfmt_outdent_attributes;
|
||||||
///
|
///
|
||||||
OptionalBoolean dfmt_outdent_labels;
|
|
||||||
///
|
|
||||||
int dfmt_soft_max_line_length = -1;
|
int dfmt_soft_max_line_length = -1;
|
||||||
///
|
///
|
||||||
OptionalBoolean dfmt_space_after_cast;
|
OptionalBoolean dfmt_space_after_cast;
|
||||||
|
|
|
||||||
|
|
@ -475,6 +475,8 @@ private:
|
||||||
{
|
{
|
||||||
if (isCase && !indents.topIs(tok!"case") && config.dfmt_align_switch_statements == OptionalBoolean.f)
|
if (isCase && !indents.topIs(tok!"case") && config.dfmt_align_switch_statements == OptionalBoolean.f)
|
||||||
indents.push(tok!"case");
|
indents.push(tok!"case");
|
||||||
|
else if (isAttribute && !indents.topIs(tok!"@") && config.dfmt_outdent_attributes == OptionalBoolean.f)
|
||||||
|
indents.push(tok!"@");
|
||||||
newline();
|
newline();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1120,7 +1122,7 @@ private:
|
||||||
else if (currentIs(tok!"}"))
|
else if (currentIs(tok!"}"))
|
||||||
{
|
{
|
||||||
indents.popTempIndents();
|
indents.popTempIndents();
|
||||||
if (indents.topIs(tok!"case"))
|
while (indents.topIs(tok!"case") || indents.topIs(tok!"@"))
|
||||||
indents.pop();
|
indents.pop();
|
||||||
if (indents.topIs(tok!"{"))
|
if (indents.topIs(tok!"{"))
|
||||||
{
|
{
|
||||||
|
|
@ -1143,6 +1145,8 @@ private:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (astInformation.attributeDeclarationLines.canFindIndex(current.line))
|
else if (astInformation.attributeDeclarationLines.canFindIndex(current.line))
|
||||||
|
{
|
||||||
|
if (config.dfmt_outdent_attributes == OptionalBoolean.t)
|
||||||
{
|
{
|
||||||
immutable l = indents.indentToMostRecent(tok!"{");
|
immutable l = indents.indentToMostRecent(tok!"{");
|
||||||
if (l != -1)
|
if (l != -1)
|
||||||
|
|
@ -1150,10 +1154,16 @@ private:
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
while (indents.topIsTemp() && (peekBackIsOneOf(true, tok!"}", tok!";") && indents.top != tok!";"))
|
if (indents.topIs(tok!"@"))
|
||||||
{
|
|
||||||
indents.pop();
|
indents.pop();
|
||||||
|
indentLevel = indents.indentLevel;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
while (indents.topIsTemp() && (peekBackIsOneOf(true, tok!"}", tok!";")
|
||||||
|
&& indents.top != tok!";"))
|
||||||
|
indents.pop();
|
||||||
indentLevel = indents.indentLevel;
|
indentLevel = indents.indentLevel;
|
||||||
}
|
}
|
||||||
indent();
|
indent();
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,8 @@ import std.d.lexer;
|
||||||
*/
|
*/
|
||||||
bool isWrapIndent(IdType type) pure nothrow @nogc @safe
|
bool isWrapIndent(IdType type) pure nothrow @nogc @safe
|
||||||
{
|
{
|
||||||
return type != tok!"{" && type != tok!"case" && type != tok!"]" && isOperator(type);
|
return type != tok!"{" && type != tok!"case" && type != tok!"@"
|
||||||
|
&& type != tok!"]" && isOperator(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -20,7 +21,7 @@ bool isWrapIndent(IdType type) pure nothrow @nogc @safe
|
||||||
*/
|
*/
|
||||||
bool isTempIndent(IdType type) pure nothrow @nogc @safe
|
bool isTempIndent(IdType type) pure nothrow @nogc @safe
|
||||||
{
|
{
|
||||||
return type != tok!"{" && type != tok!"case";
|
return type != tok!"{" && type != tok!"case" && type != tok!"@";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
class SomeClass
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
|
private:
|
||||||
|
int z;
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
void doStuff();
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
--outdent_attributes=false
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
class SomeClass
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
|
private:
|
||||||
|
int z;
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
void doStuff();
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
class SomeClass {
|
||||||
|
public:
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
|
private:
|
||||||
|
int z;
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
void doStuff();
|
||||||
Loading…
Reference in New Issue