Skip to content
This repository has been archived by the owner on Sep 24, 2020. It is now read-only.

Commit

Permalink
Fixed Issue #44: The ending TextLocation of an ArrayCreateExpression
Browse files Browse the repository at this point in the history
is incorrect when the array is initialized with zero elements
  • Loading branch information
Mike Krüger committed Apr 24, 2012
1 parent 6a45cef commit 6f1325d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ICSharpCode.NRefactory.CSharp/Parser/CSharpParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2850,7 +2850,7 @@ public override object Visit (ArrayCreation arrayCreationExpression)
next = next.Next;
}

if (arrayCreationExpression.Initializers != null && arrayCreationExpression.Initializers.Count != 0) {
if (arrayCreationExpression.Initializers != null) {
var initLocation = LocationsBag.GetLocations (arrayCreationExpression.Initializers);
ArrayInitializerExpression initializer = new ArrayInitializerExpression ();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,18 @@ public void AssignmentInArrayInitializer()
}
}});
}


[Test]
public void EmptyArrayCreation()
{
var ace = ParseUtilCSharp.ParseExpression<ArrayCreateExpression>("new [] { }");
Assert.AreEqual(new Role[] {
Roles.LBrace,
Roles.RBrace
}, ace.Initializer.Children.Select(c => c.Role).ToArray());
}


[Test, Ignore("Parser bug")]
public void ArrayInitializerWithCommaAtEnd()
{
Expand Down

0 comments on commit 6f1325d

Please sign in to comment.