public override ExpressionKind Eat(ISnapshot snapshot, IReferenceExpression expression) { var parentKind = expression.QualifierExpression != null ? Eater.Eat(snapshot, expression.QualifierExpression) : ExpressionKind.None; if (parentKind == ExpressionKind.None) { var declaredElement = _eatExpressionHelper.GetReferenceElement(expression); // TODO: declared element can be method: case: event += obj.Method; // TODO: declared element can be parameter // TODO: Property(Field) can be Stub, Mock or Target if (declaredElement is IProperty) { return(_typeEater.EatVariableType(snapshot, (declaredElement as IProperty).Type)); } if (declaredElement is IField) { return(_typeEater.EatVariableType(snapshot, (declaredElement as IField).Type)); } if (declaredElement is IEvent) { return(ExpressionKind.Stub); } if (declaredElement is ILocalConstantDeclaration) { return(ExpressionKind.Stub); } if (declaredElement is IVariableDeclaration) { return(snapshot.GetVariableKind(declaredElement as IVariableDeclaration)); } if (declaredElement is IClass) { return(ExpressionKind.None); } throw new UnexpectedReferenceTypeException(declaredElement, this, expression); } else { return(_kindHelper.ReferenceKindByParentReferenceKind(parentKind)); } }
public override ExpressionKind Eat(ISnapshot snapshot, IAssignmentExpression expression) { var sourceKind = Eater.Eat(snapshot, expression.Source); if (expression.Dest is IReferenceExpression) { var assignmentKind = _expressionKindHelper.KindOfAssignment(sourceKind); var declaredElement = _eatExpressionHelper.GetReferenceElement(expression.Dest as IReferenceExpression); if (declaredElement is IVariableDeclaration) { return(EatVariableDeclaration(snapshot, declaredElement as IVariableDeclaration, assignmentKind)); } } throw new UnexpectedAssignDestinationException(expression.Dest, this, expression); }