|
|
|
@ -23,7 +23,7 @@ using System.Globalization;
@@ -23,7 +23,7 @@ using System.Globalization;
|
|
|
|
|
using System.IO; |
|
|
|
|
using System.Linq; |
|
|
|
|
using System.Text; |
|
|
|
|
|
|
|
|
|
using System.Threading.Tasks; |
|
|
|
|
using ICSharpCode.NRefactory.PatternMatching; |
|
|
|
|
using ICSharpCode.NRefactory.TypeSystem; |
|
|
|
|
|
|
|
|
@ -414,13 +414,21 @@ namespace ICSharpCode.NRefactory.CSharp
@@ -414,13 +414,21 @@ namespace ICSharpCode.NRefactory.CSharp
|
|
|
|
|
{ |
|
|
|
|
if (unconditionalKeywords.Contains (identifier)) |
|
|
|
|
return true; |
|
|
|
|
if (context.Ancestors.Any (a => a is QueryExpression)) { |
|
|
|
|
if (queryKeywords.Contains (identifier)) |
|
|
|
|
foreach (AstNode ancestor in context.Ancestors) { |
|
|
|
|
if (ancestor is QueryExpression && queryKeywords.Contains (identifier)) |
|
|
|
|
return true; |
|
|
|
|
if (identifier == "await") { |
|
|
|
|
// with lambdas/anonymous methods,
|
|
|
|
|
if (ancestor is LambdaExpression) |
|
|
|
|
return ((LambdaExpression)ancestor).IsAsync; |
|
|
|
|
if (ancestor is AnonymousMethodExpression) |
|
|
|
|
return ((AnonymousMethodExpression)ancestor).IsAsync; |
|
|
|
|
if (ancestor is AttributedNode) |
|
|
|
|
return (((AttributedNode)ancestor).Modifiers & Modifiers.Async) == Modifiers.Async; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Write constructs
|
|
|
|
@ -512,6 +520,10 @@ namespace ICSharpCode.NRefactory.CSharp
@@ -512,6 +520,10 @@ namespace ICSharpCode.NRefactory.CSharp
|
|
|
|
|
public object VisitAnonymousMethodExpression (AnonymousMethodExpression anonymousMethodExpression, object data) |
|
|
|
|
{ |
|
|
|
|
StartNode (anonymousMethodExpression); |
|
|
|
|
if (anonymousMethodExpression.IsAsync) { |
|
|
|
|
WriteKeyword ("async", AnonymousMethodExpression.AsyncModifierRole); |
|
|
|
|
Space (); |
|
|
|
|
} |
|
|
|
|
WriteKeyword ("delegate"); |
|
|
|
|
if (anonymousMethodExpression.HasParameterList) { |
|
|
|
|
Space (policy.SpaceBeforeMethodDeclarationParentheses); |
|
|
|
@ -786,6 +798,10 @@ namespace ICSharpCode.NRefactory.CSharp
@@ -786,6 +798,10 @@ namespace ICSharpCode.NRefactory.CSharp
|
|
|
|
|
public object VisitLambdaExpression (LambdaExpression lambdaExpression, object data) |
|
|
|
|
{ |
|
|
|
|
StartNode (lambdaExpression); |
|
|
|
|
if (lambdaExpression.IsAsync) { |
|
|
|
|
WriteKeyword ("async", LambdaExpression.AsyncModifierRole); |
|
|
|
|
Space (); |
|
|
|
|
} |
|
|
|
|
if (LambdaNeedsParenthesis (lambdaExpression)) { |
|
|
|
|
WriteCommaSeparatedListInParenthesis (lambdaExpression.Parameters, policy.SpaceWithinMethodDeclarationParentheses); |
|
|
|
|
} else { |
|
|
|
@ -1112,8 +1128,11 @@ namespace ICSharpCode.NRefactory.CSharp
@@ -1112,8 +1128,11 @@ namespace ICSharpCode.NRefactory.CSharp
|
|
|
|
|
StartNode (unaryOperatorExpression); |
|
|
|
|
UnaryOperatorType opType = unaryOperatorExpression.Operator; |
|
|
|
|
string opSymbol = UnaryOperatorExpression.GetOperatorSymbol (opType); |
|
|
|
|
if (!(opType == UnaryOperatorType.PostIncrement || opType == UnaryOperatorType.PostDecrement)) |
|
|
|
|
if (opType == UnaryOperatorType.Await) { |
|
|
|
|
WriteKeyword (opSymbol, UnaryOperatorExpression.OperatorRole); |
|
|
|
|
} else if (!(opType == UnaryOperatorType.PostIncrement || opType == UnaryOperatorType.PostDecrement)) { |
|
|
|
|
WriteToken (opSymbol, UnaryOperatorExpression.OperatorRole); |
|
|
|
|
} |
|
|
|
|
unaryOperatorExpression.Expression.AcceptVisitor (this, data); |
|
|
|
|
if (opType == UnaryOperatorType.PostIncrement || opType == UnaryOperatorType.PostDecrement) |
|
|
|
|
WriteToken (opSymbol, UnaryOperatorExpression.OperatorRole); |
|
|
|
|