Example #1
0
        /// <summary>
        /// Cleans all text fields in this element
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="visitSubNodes"></param>
        public override void visit(Generated.PreCondition obj, bool visitSubNodes)
        {
            if (obj.getCondition() != null)
            {
                obj.setCondition(obj.getCondition().Trim());
            }
            if (obj.getComment() != null)
            {
                obj.setComment(obj.getComment().Trim());
            }

            base.visit(obj, visitSubNodes);
        }
Example #2
0
        public override void visit(Generated.PreCondition obj, bool visitSubNodes)
        {
            Rules.PreCondition preCondition = (Rules.PreCondition)obj;

            if (Rebuild)
            {
                preCondition.ExpressionTree = null;
            }

            // Side effect : compiles or recompiles the expression
            DataDictionary.Interpreter.Expression expression = preCondition.ExpressionTree;

            base.visit(obj, visitSubNodes);
        }
        public override void visit(Generated.PreCondition obj, bool subNodes)
        {
            Rules.PreCondition preCondition = obj as Rules.PreCondition;

            if (preCondition != null)
            {
                try
                {
                    // Check whether the expression is valid
                    Interpreter.Expression expression = checkExpression(preCondition, preCondition.Condition);
                    if (!preCondition.Dictionary.EFSSystem.BoolType.Match(expression.GetExpressionType()))
                    {
                        preCondition.AddError("Expression type should be Boolean");
                    }

                    Types.ITypedElement element = OverallTypedElementFinder.INSTANCE.findByName(preCondition, preCondition.findVariable());
                    if (element != null)
                    {
                        if (element.Type is Types.StateMachine)
                        {
                            if (preCondition.findOperator() != null)
                            {
                                if (preCondition.findOperator().CompareTo("==") == 0)
                                {
                                    preCondition.AddWarning("Operator == should not be used for state machines");
                                }
                                else if (preCondition.findOperator().CompareTo("!=") == 0)
                                {
                                    preCondition.AddWarning("Operator != should not be used for state machines");
                                }
                            }
                        }
                    }
                }
                catch (Exception exception)
                {
                    preCondition.AddException(exception);
                }
            }

            base.visit(obj, subNodes);
        }