Browse Source

C# parser: added support for method invocations with named arguments.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@5585 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Daniel Grunwald 16 years ago
parent
commit
b58f8075bb
  1. 1390
      src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs
  2. 13
      src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG
  3. 13
      src/Libraries/NRefactory/Test/Parser/Expressions/InvocationExpressionTests.cs

1390
src/Libraries/NRefactory/Project/Src/Parser/CSharp/Parser.cs

File diff suppressed because it is too large Load Diff

13
src/Libraries/NRefactory/Project/Src/Parser/CSharp/cs.ATG

@ -1363,6 +1363,19 @@ OverloadableOperator<out OverloadableOperatorType op> @@ -1363,6 +1363,19 @@ OverloadableOperator<out OverloadableOperatorType op>
.
Argument<out Expression argumentexpr>
(. argumentexpr = null; .)
=
IF (IdentAndColon())
(. Token ident; Expression expr; .)
Identifier (. ident = t; .)
":"
ArgumentValue<out expr>
(. argumentexpr = new NamedArgumentExpression(ident.val, expr) { StartLocation = ident.Location, EndLocation = t.EndLocation }; .)
| ArgumentValue<out argumentexpr>
.
ArgumentValue<out Expression argumentexpr>
(.
Expression expr;
FieldDirection fd = FieldDirection.None;

13
src/Libraries/NRefactory/Test/Parser/Expressions/InvocationExpressionTests.cs

@ -158,6 +158,19 @@ namespace ICSharpCode.NRefactory.Tests.Ast @@ -158,6 +158,19 @@ namespace ICSharpCode.NRefactory.Tests.Ast
Assert.AreEqual(1, ictr.BaseType.GenericTypes.Count);
Assert.AreEqual("T", ictr.BaseType.GenericTypes[0].Type);
}
[Test]
public void InvocationWithNamedArgument()
{
InvocationExpression expr = ParseUtilCSharp.ParseExpression<InvocationExpression>("a(arg: ref v)");
Assert.AreEqual(1, expr.Arguments.Count);
NamedArgumentExpression nae = (NamedArgumentExpression)expr.Arguments[0];
Assert.AreEqual("arg", nae.Name);
DirectionExpression dir = (DirectionExpression)nae.Expression;
Assert.AreEqual(FieldDirection.Ref, dir.FieldDirection);
Assert.IsInstanceOf<IdentifierExpression>(dir.Expression);
}
#endregion
#region VB.NET

Loading…
Cancel
Save