Browse Source

Merge pull request #58 from mono-soc-2012/simonl-newline-fix

[Formatter] Avoid newlines between multiline arguments and the ending parenthesis...
newNRvisualizers
Mike Krüger 13 years ago
parent
commit
6c36d6e665
  1. 2
      ICSharpCode.NRefactory.CSharp/Formatter/AstFormattingVisitor.cs
  2. 34
      ICSharpCode.NRefactory.Tests/FormattingTests/TestWrapping.cs

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

@ -1822,7 +1822,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -1822,7 +1822,7 @@ namespace ICSharpCode.NRefactory.CSharp
if (methodCallArgumentWrapping == Wrapping.DoNotWrap) {
ForceSpacesBeforeRemoveNewLines(rParToken, spaceWithinMethodCallParentheses);
} else {
bool sameLine = rParToken.GetPrevNode().StartLocation.Line == rParToken.StartLocation.Line;
bool sameLine = rParToken.GetPrevNode().EndLocation.Line == rParToken.StartLocation.Line;
if (sameLine) {
ForceSpacesBeforeRemoveNewLines(rParToken, spaceWithinMethodCallParentheses);
} else {

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

@ -579,6 +579,40 @@ namespace ICSharpCode.NRefactory.CSharp.FormattingTests @@ -579,6 +579,40 @@ namespace ICSharpCode.NRefactory.CSharp.FormattingTests
}
}");
}
[Test()]
public void TestNoBlankLinesBetweenEndBraceAndEndParenthesis ()
{
CSharpFormattingOptions policy = FormattingOptionsFactory.CreateMono ();
policy.BlankLinesBetweenMembers = 1;
var adapter = Test (policy, @"class Test
{
int Foo (int i, double d, Action a)
{
a ();
}
void Bar ()
{
Foo (1, 2, () => {
});
}
}",
@"class Test
{
int Foo (int i, double d, Action a)
{
a ();
}
void Bar ()
{
Foo (1, 2, () => {
});
}
}", FormattingMode.Intrusive);
}
}
}

Loading…
Cancel
Save