DataDictionary.Interpreter.BinaryExpression.CheckExpression C# (CSharp) Method

CheckExpression() public method

Checks the expression and appends errors to the root tree node when inconsistencies are found
public CheckExpression ( ) : void
return void
        public override void CheckExpression()
        {
            base.CheckExpression();

            Left.CheckExpression();
            Right.CheckExpression();

            Type leftType = Left.GetExpressionType();
            if (leftType != null)
            {
                if (Operation == Operator.Is || (Operation == Operator.As))
                {
                    Structure leftStructure = leftType as Structure;
                    if (leftStructure != null)
                    {
                        Structure rightStructure = Right.Ref as Structure;
                        if (rightStructure != null)
                        {
                            if (!rightStructure.ImplementedStructures.Contains(leftStructure))
                            {
                                AddError("No inheritance from " + Right + " to " + Left, RuleChecksEnum.SyntaxError);
                            }
                        }
                        else
                        {
                            AddError("Right part of " + Operation + " operation should be a structure, found " +
                                     Right.Ref, RuleChecksEnum.SyntaxError);
                        }
                    }
                    else
                    {
                        AddError("Left expression type of " + Operation + " operation should be a structure, found " +
                                 leftType, RuleChecksEnum.SyntaxError);
                    }
                }
                else
                {
                    Type rightType = Right.GetExpressionType();
                    if (rightType != null)
                    {
                        if (!leftType.ValidBinaryOperation(Operation, rightType)
                            && !rightType.ValidBinaryOperation(Operation, leftType))
                        {
                            AddError("Cannot perform " + Operation + " operation between " + Left + "(" + leftType.Name +
                                     ") and " + Right + "(" + rightType.Name + ")", RuleChecksEnum.SyntaxError);
                        }

                        if (Operation == Operator.Equal)
                        {
                            if (leftType is StateMachine && rightType is StateMachine)
                            {
                                AddWarning("IN operator should be used instead of == between " + Left + " and " + Right);
                            }

                            if (Right.Ref == EfsSystem.Instance.EmptyValue)
                            {
                                if (leftType is Collection)
                                {
                                    AddError("Cannot compare collections with " + Right.Ref.Name + ". Use [] instead", RuleChecksEnum.SyntaxError);
                                }
                            }
                        }
                    }
                }
            }
        }