/// <summary> /// Checks the statement for semantical errors /// </summary> public override void CheckStatement() { if (ListExpression != null) { ListExpression.CheckExpression(); Collection listExpressionType = ListExpression.GetExpressionType() as Collection; if (listExpressionType == null) { Root.AddError("Target does not references a list"); } } else { Root.AddError("List should be specified"); } if (ConditionExpression != null) { ConditionExpression.CheckExpression(); } if (AppliedStatement != null) { AppliedStatement.CheckStatement(); } else { Root.AddError("Procedure should be specified in the APPLY statement"); } }
/// <summary> /// Checks the expression and appends errors to the root tree node when inconsistencies are found /// </summary> public override void CheckExpression() { base.CheckExpression(); if (ListExpression != null) { ListExpression.CheckExpression(); Type listExpressionType = ListExpression.GetExpressionType(); if (!(listExpressionType is Collection)) { AddError("List expression " + ListExpression + " should hold a collection", RuleChecksEnum.SyntaxError); } } else { AddError("List expression should be provided", RuleChecksEnum.SyntaxError); } }
/// <summary> /// Checks the statement for semantical errors /// </summary> public override void CheckStatement() { if (ListExpression != null) { ListExpression.CheckExpression(); if (ListExpression.Ref is Parameter) { Root.AddError("Cannot change the list value which is a parameter (" + ListExpression + ")"); } Collection targetListType = ListExpression.GetExpressionType() as Collection; if (targetListType != null) { if (Value != null) { Type elementType = Value.GetExpressionType(); if (elementType != targetListType.Type) { Root.AddError("Inserted element type does not corresponds to list type"); } } if (ReplaceElement != null) { ReplaceElement.CheckExpression(); Type replaceElementType = ReplaceElement.GetExpressionType(); if (replaceElementType != null) { if (targetListType.Type != null) { if (replaceElementType != targetListType.Type) { Root.AddError("The replace element type (" + replaceElementType.FullName + ") does not correspond to the list type (" + targetListType.Type.FullName + ")"); } } else { Root.AddError("Cannot determine list element's type for " + targetListType.FullName); } } else { Root.AddError("Cannot determine replacement element type"); } } } else { Root.AddError("Cannot determine collection type of " + ListExpression); } } else { Root.AddError("List should be specified"); } if (Value != null) { Value.CheckExpression(); } else { Root.AddError("Value should be specified"); } }