public static ExpressionSyntax GetLeftSideOfDot(this SimpleNameSyntax name) { Contract.Requires(name.IsMemberAccessExpressionName() || name.IsRightSideOfQualifiedName() || name.IsParentKind(SyntaxKind.NameMemberCref)); if (name.IsMemberAccessExpressionName()) { return(((MemberAccessExpressionSyntax)name.Parent).Expression); } else if (name.IsRightSideOfQualifiedName()) { return(((QualifiedNameSyntax)name.Parent).Left); } else { return(((QualifiedCrefSyntax)name.Parent.Parent).Container); } }
public static ExpressionSyntax GetLeftSideOfDot(this SimpleNameSyntax name) { Debug.Assert(name.IsMemberAccessExpressionName() || name.IsRightSideOfQualifiedName() || name.IsParentKind(SyntaxKind.NameMemberCref)); if (name.IsMemberAccessExpressionName()) { var conditionalAccess = name.GetParentConditionalAccessExpression(); if (conditionalAccess != null) { return(conditionalAccess.Expression); } else { return(((MemberAccessExpressionSyntax)name.Parent).Expression); } } else if (name.IsRightSideOfQualifiedName()) { return(((QualifiedNameSyntax)name.Parent).Left); } else { return(((QualifiedCrefSyntax)name.Parent.Parent).Container); } }
public static ExpressionSyntax GetLeftSideOfDot(this SimpleNameSyntax name) { if (name.IsMemberAccessExpressionName()) { return(((MemberAccessExpressionSyntax)name.Parent).Expression); } else if (name.IsRightSideOfQualifiedName()) { return(((QualifiedNameSyntax)name.Parent).Left); } else { return(((QualifiedCrefSyntax)name.Parent.Parent).Container); } }