Browse Source

Fixed indent break statement formatting.

newNRvisualizers
mike 14 years ago
parent
commit
f68f9907c8
  1. 6
      ICSharpCode.NRefactory.CSharp/Formatter/AstFormattingVisitor.cs
  2. 75
      ICSharpCode.NRefactory.Tests/FormattingTests/TestStatementIndentation.cs

6
ICSharpCode.NRefactory.CSharp/Formatter/AstFormattingVisitor.cs

@ -1158,6 +1158,12 @@ namespace ICSharpCode.NRefactory.CSharp @@ -1158,6 +1158,12 @@ namespace ICSharpCode.NRefactory.CSharp
curIndent.Level++;
foreach (var stmt in switchSection.Statements) {
if (stmt is BreakStatement && !policy.IndentBreakStatements && policy.IndentCaseBody) {
curIndent.Level--;
stmt.AcceptVisitor (this, null);
curIndent.Level++;
continue;
}
stmt.AcceptVisitor (this, null);
}
if (policy.IndentCaseBody)

75
ICSharpCode.NRefactory.Tests/FormattingTests/TestStatementIndentation.cs

@ -1561,6 +1561,81 @@ if (b) { @@ -1561,6 +1561,81 @@ if (b) {
}
}");
}
[Test()]
public void TestSwitchIndentBreak ()
{
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.IndentSwitchBody = true;
policy.IndentBreakStatements = true;
Test (policy, @"class Test
{
Test TestMethod ()
{
switch (a) {
case 1:
case 2:
DoSomething ();
break;
default:
Foo ();
break;
}
}
}",
@"class Test
{
Test TestMethod ()
{
switch (a) {
case 1:
case 2:
DoSomething ();
break;
default:
Foo ();
break;
}
}
}");
policy.IndentSwitchBody = true;
policy.IndentBreakStatements = false;
Test (policy, @"class Test
{
Test TestMethod ()
{
switch (a) {
case 1:
case 2:
DoSomething ();
break;
default:
Foo ();
break;
}
}
}",
@"class Test
{
Test TestMethod ()
{
switch (a) {
case 1:
case 2:
DoSomething ();
break;
default:
Foo ();
break;
}
}
}");
}
[Test()]
public void TestTryCatchBracketPlacement ()

Loading…
Cancel
Save