Skip to content

Commit

Permalink
Rework indentation system. Fix #91. Fix #86. Fix #54.
Browse files Browse the repository at this point in the history
  • Loading branch information
Hackerpilot committed Mar 11, 2015
1 parent 52eabd4 commit 1ef17c5
Show file tree
Hide file tree
Showing 13 changed files with 401 additions and 206 deletions.
426 changes: 223 additions & 203 deletions src/dfmt.d

Large diffs are not rendered by default.

29 changes: 29 additions & 0 deletions tests/issue0054.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
struct ClassFlags
{
alias Type = uint;
enum Enum : int
{
isCOMclass = 0x1,
noPointers = 0x2,
hasOffTi = 0x4,
hasCtor = 0x8,
hasGetMembers = 0x10,
hasTypeInfo = 0x20,
isAbstract = 0x40,
isCPPclass = 0x80,
hasDtor = 0x100,

}

alias isCOMclass = Enum.isCOMclass;
alias noPointers = Enum.noPointers;
alias hasOffTi = Enum.hasOffTi;
alias hasCtor = Enum.hasCtor;
alias hasGetMembers = Enum.hasGetMembers;
alias hasTypeInfo = Enum.hasTypeInfo;
alias isAbstract = Enum.isAbstract;
alias isCPPclass = Enum.isCPPclass;
alias hasDtor = Enum.hasDtor;


}
21 changes: 21 additions & 0 deletions tests/issue0054.d.ref
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
struct ClassFlags
{
alias Type = uint;
enum Enum : int
{
isCOMclass = 0x1, noPointers = 0x2, hasOffTi = 0x4, hasCtor = 0x8,
hasGetMembers = 0x10, hasTypeInfo = 0x20, isAbstract = 0x40,
isCPPclass = 0x80, hasDtor = 0x100,

}

alias isCOMclass = Enum.isCOMclass;
alias noPointers = Enum.noPointers;
alias hasOffTi = Enum.hasOffTi;
alias hasCtor = Enum.hasCtor;
alias hasGetMembers = Enum.hasGetMembers;
alias hasTypeInfo = Enum.hasTypeInfo;
alias isAbstract = Enum.isAbstract;
alias isCPPclass = Enum.isCPPclass;
alias hasDtor = Enum.hasDtor;
}
2 changes: 1 addition & 1 deletion tests/issue0056.d
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{{{}}{}}
unittest{{{}}{}{{{{}}}}}
9 changes: 9 additions & 0 deletions tests/issue0056.d.ref
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
unittest
{
{
{
}
}
{
}
{
{
{
{
}
}
}
}
}
2 changes: 1 addition & 1 deletion tests/issue0080.d.ref
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ unittest
version (A)
{
case b:
return;
return;
}
}
}
2 changes: 1 addition & 1 deletion tests/issue0082.d.ref
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ Label:
// comment
statement();
}
}
}
26 changes: 26 additions & 0 deletions tests/issue0086.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
unittest
{
if (a)
if (b)
doSomething();
doSomethingElse();
}

void indent()
{
import std.range : repeat, take;

if (config.useTabs)
foreach (i; 0 .. indentLevel + tempIndent)
{
currentLineLength += config.tabSize;
output.put("\t");
}
else
foreach (i; 0 .. indentLevel + tempIndent)
foreach (j; 0 .. config.indentSize)
{
output.put(" ");
currentLineLength++;
}
}
26 changes: 26 additions & 0 deletions tests/issue0086.d.ref
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
unittest
{
if (a)
if (b)
doSomething();
doSomethingElse();
}

void indent()
{
import std.range : repeat, take;

if (config.useTabs)
foreach (i; 0 .. indentLevel + tempIndent)
{
currentLineLength += config.tabSize;
output.put("\t");
}
else
foreach (i; 0 .. indentLevel + tempIndent)
foreach (j; 0 .. config.indentSize)
{
output.put(" ");
currentLineLength++;
}
}
13 changes: 13 additions & 0 deletions tests/issue0091.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
unittest
{
switch (x)
{
version (none)
{
x();
case Case:
doSomething();
doSomethingElse();
}
}
}
13 changes: 13 additions & 0 deletions tests/issue0091.d.ref
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
unittest
{
switch (x)
{
version (none)
{
x();
case Case:
doSomething();
doSomethingElse();
}
}
}
14 changes: 14 additions & 0 deletions tests/longParamList.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version (AArch64)
{
class SomeLongClassName
{
public:

double javaStyleFunctionName(double alpha, double bravo, double charlie, double delta, double echo, double foxtrot, double golf, double hotel)
{
if (alpha < beta && alpha > golf && hotel < alpha && bravo >= charlie && echo < delta)
{
if (alpha < beta && alpha > golf && hotel < alpha && bravo >= charlie && echo < delta)
{
if (alpha < beta && alpha > golf && hotel < alpha && bravo >= charlie && echo < delta)
{}}}}}}
24 changes: 24 additions & 0 deletions tests/longParamList.d.ref
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
version (AArch64)
{
class SomeLongClassName
{
public:

double javaStyleFunctionName(double alpha, double bravo, double charlie,
double delta, double echo, double foxtrot, double golf, double hotel)
{
if (alpha < beta && alpha > golf && hotel < alpha && bravo >= charlie
&& echo < delta)
{
if (alpha < beta && alpha > golf && hotel < alpha && bravo >= charlie
&& echo < delta)
{
if (alpha < beta && alpha > golf && hotel < alpha && bravo >= charlie
&& echo < delta)
{
}
}
}
}
}
}

0 comments on commit 1ef17c5

Please sign in to comment.