diff options
author | Alan McGovern <alan@xamarin.com> | 2015-09-14 19:24:38 +0300 |
---|---|---|
committer | Alan McGovern <alan@xamarin.com> | 2015-09-14 19:24:38 +0300 |
commit | 9f5b2d0d2f98c28a0ae0db507449b5385ae5e8cb (patch) | |
tree | 24b56c17c698866b3f68f71deed4fbdf299c7496 | |
parent | 87931b9cc9a34b8819add1d5338b0397c6949df6 (diff) | |
parent | 6c5fd21f3c99a01b37ce00a3e7981b268621eb8b (diff) |
Merge branch 'roslyn' of github.com:mono/monodevelop into roslyn
-rw-r--r-- | main/src/addins/CSharpBinding/Util/ExpressionSyntaxExtensions.cs | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/main/src/addins/CSharpBinding/Util/ExpressionSyntaxExtensions.cs b/main/src/addins/CSharpBinding/Util/ExpressionSyntaxExtensions.cs index fbc41e9d7d..e916ed1e00 100644 --- a/main/src/addins/CSharpBinding/Util/ExpressionSyntaxExtensions.cs +++ b/main/src/addins/CSharpBinding/Util/ExpressionSyntaxExtensions.cs @@ -121,12 +121,24 @@ namespace ICSharpCode.NRefactory6.CSharp public static bool IsMemberAccessExpressionName(this ExpressionSyntax expression) { return (expression.IsParentKind(SyntaxKind.SimpleMemberAccessExpression) && ((MemberAccessExpressionSyntax)expression.Parent).Name == expression) || - (expression.IsParentKind(SyntaxKind.MemberBindingExpression) && expression.Parent.Parent.IsParentKind(SyntaxKind.ConditionalAccessExpression) && ((MemberBindingExpressionSyntax)expression.Parent).Name == expression); + (IsMemberBindingExpressionName(expression)); } public static bool IsAnyMemberAccessExpressionName(this ExpressionSyntax expression) { - return expression != null && expression.Parent is MemberAccessExpressionSyntax && ((MemberAccessExpressionSyntax)expression.Parent).Name == expression; + if (expression == null) + { + return false; + } + + return expression == (expression.Parent as MemberAccessExpressionSyntax)?.Name || + expression.IsMemberBindingExpressionName(); + } + + private static bool IsMemberBindingExpressionName(this ExpressionSyntax expression) + { + return expression.IsParentKind(SyntaxKind.MemberBindingExpression) && + ((MemberBindingExpressionSyntax)expression.Parent).Name == expression; } public static bool IsRightSideOfQualifiedName(this ExpressionSyntax expression) |