Browse Source

[Formatting] Fixed some formatting bugs.

newNRvisualizers
Mike Krüger 13 years ago
parent
commit
6126d9bd77
  1. 15
      ICSharpCode.NRefactory.CSharp/Formatter/AstFormattingVisitor.cs
  2. 90
      ICSharpCode.NRefactory.Tests/FormattingTests/TestWrapping.cs

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

@ -1763,8 +1763,12 @@ namespace ICSharpCode.NRefactory.CSharp @@ -1763,8 +1763,12 @@ namespace ICSharpCode.NRefactory.CSharp
}
curIndent.ExtraSpaces -= extraSpaces;
}
if (!rParToken.IsNull) {
if (methodClosingParenthesesOnNewLine) {
FixStatementIndentation(rParToken.StartLocation);
} else {
ForceSpacesBeforeRemoveNewLines(rParToken, spaceWithinMethodCallParentheses);
}
}
} else {
foreach (var arg in arguments) {
@ -1777,7 +1781,18 @@ namespace ICSharpCode.NRefactory.CSharp @@ -1777,7 +1781,18 @@ namespace ICSharpCode.NRefactory.CSharp
}
arg.AcceptVisitor(this);
}
if (!rParToken.IsNull) {
if (methodCallArgumentWrapping == Wrapping.DoNotWrap) {
ForceSpacesBeforeRemoveNewLines(rParToken, spaceWithinMethodCallParentheses);
} else {
bool sameLine = rParToken.GetPrevNode().StartLocation.Line == rParToken.StartLocation.Line;
if (sameLine) {
ForceSpacesBeforeRemoveNewLines(rParToken, spaceWithinMethodCallParentheses);
} else {
FixStatementIndentation(rParToken.StartLocation);
}
}
}
}
if (!rParToken.IsNull) {
foreach (CSharpTokenNode comma in rParToken.Parent.Children.Where(n => n.Role == Roles.Comma)) {

90
ICSharpCode.NRefactory.Tests/FormattingTests/TestWrapping.cs

@ -412,5 +412,95 @@ namespace ICSharpCode.NRefactory.CSharp.FormattingTests @@ -412,5 +412,95 @@ namespace ICSharpCode.NRefactory.CSharp.FormattingTests
}
[Test()]
public void TestMethodCallArgumentWrappingDoNotChangeCase1()
{
var policy = FormattingOptionsFactory.CreateMono();
policy.MethodCallArgumentWrapping = Wrapping.DoNotChange;
policy.NewLineAferMethodCallOpenParentheses = true;
policy.MethodCallClosingParenthesesOnNewLine = true;
Test(policy, @"class Test
{
void TestMe ()
{
Foo (
1,
2,
3
);
}
}",
@"class Test
{
void TestMe ()
{
Foo (
1,
2,
3
);
}
}");
}
[Test()]
public void TestMethodCallArgumentWrappingDoNotChangeCase2()
{
var policy = FormattingOptionsFactory.CreateMono();
policy.MethodCallArgumentWrapping = Wrapping.DoNotChange;
policy.NewLineAferMethodCallOpenParentheses = true;
policy.MethodCallClosingParenthesesOnNewLine = true;
Test(policy, @"class Test
{
void TestMe ()
{
Foo (1,
2,
3
);
}
}",
@"class Test
{
void TestMe ()
{
Foo (1,
2,
3
);
}
}");
}
[Test()]
public void TestMethodCallArgumentWrappingDoNotChangeCase3()
{
var policy = FormattingOptionsFactory.CreateMono();
policy.MethodCallArgumentWrapping = Wrapping.DoNotChange;
policy.NewLineAferMethodCallOpenParentheses = true;
policy.MethodCallClosingParenthesesOnNewLine = true;
Test(policy, @"class Test
{
void TestMe ()
{
Foo (1,
2,
3 );
}
}",
@"class Test
{
void TestMe ()
{
Foo (1,
2,
3);
}
}");
}
}
}

Loading…
Cancel
Save