/// <summary>
 ///     Builds the explanation of the element
 /// </summary>
 /// <param name="explanation"></param>
 /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
 public override void GetExplain(TextualExplanation explanation, bool explainSubElements = true)
 {
     if (Term != null)
     {
         explanation.Write(Term);
     }
     else
     {
         if (UnaryOp != null)
         {
             explanation.Write(UnaryOp);
             if (Expression != null)
             {
                 explanation.Write(" ");
                 explanation.Write(Expression);
             }
         }
         else if (Expression != null)
         {
             explanation.Write(" (");
             explanation.Write(Expression);
             explanation.Write(" )");
         }
     }
 }
Beispiel #2
0
        /// <summary>
        ///     Builds the explanation of the element
        /// </summary>
        /// <param name="explanation"></param>
        /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
        public override void GetExplain(TextualExplanation explanation, bool explainSubElements = true)
        {
            explanation.Write(Called);
            explanation.Write("(");
            explanation.ExplainList(ActualParameters, explainSubElements, ", ",
                                    element => element.GetExplain(explanation));

            if (NamedActualParameters.Count > 0)
            {
                explanation.Indent(2, () =>
                {
                    if (ActualParameters.Count > 0)
                    {
                        explanation.Write(", ");
                    }
                    explanation.ExplainList(NamedActualParameters, explainSubElements, ", ", pair =>
                    {
                        if (AllParameters.Count > 1)
                        {
                            explanation.WriteLine();
                        }
                        explanation.Write(pair.Key);
                        explanation.Write(" => ");
                        explanation.Write(pair.Value);
                    });
                });
            }
            explanation.Write(")");
        }
        /// <summary>
        ///     Builds the explanation of the element
        /// </summary>
        /// <param name="explanation"></param>
        /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
        public override void GetExplain(TextualExplanation explanation, bool explainSubElements = true)
        {
            explanation.Write("REMOVE ");

            switch (Position)
            {
            case PositionEnum.First:
                explanation.Write("FIRST ");
                break;

            case PositionEnum.Last:
                explanation.Write("LAST ");
                break;

            case PositionEnum.All:
                explanation.Write("ALL ");
                break;
            }

            if (Condition != null)
            {
                explanation.Write(Condition);
            }

            explanation.Write(" IN ");
            explanation.Write(ListExpression);
        }
Beispiel #4
0
        public override string ToString()
        {
            TextualExplanation explanation = new TextualExplanation();

            GetExplain(explanation);
            return(explanation.Text);
        }
Beispiel #5
0
        private void Editor_KeyPress(object sender, KeyPressEventArgs e)
        {
            try
            {
                if (AutoComplete)
                {
                    switch (e.KeyChar)
                    {
                    case '.':
                        EditionTextBox.SelectedText = e.KeyChar.ToString(CultureInfo.InvariantCulture);
                        e.Handled = true;
                        DisplayComboBox();
                        break;

                    case '{':
                        Structure structure = GetInstance(EditionTextBox.SelectionStart - 1) as Structure;
                        if (structure != null)
                        {
                            TextualExplanation text = new TextualExplanation();
                            text.WriteLine("{");
                            CreateDefaultStructureValue(text, structure, false);
                            EditionTextBox.SelectedText = text.Text;
                            EditionTextBox.ProcessAllLines(true);
                            e.Handled = true;
                        }
                        break;

                    case '(':
                        ICallable callable = GetInstance(EditionTextBox.SelectionStart - 1) as ICallable;
                        if (callable != null)
                        {
                            TextualExplanation text = new TextualExplanation();
                            CreateCallableParameters(text, callable);
                            EditionTextBox.SelectedText = text.Text;
                            EditionTextBox.ProcessAllLines(true);
                            e.Handled = true;
                        }
                        break;

                    case '>':
                    case '-':
                        char prev = EditionTextBox.Text[EditionTextBox.SelectionStart - 1];
                        if ((prev == '<' && e.KeyChar == '-') || (prev == '=' && e.KeyChar == '>'))
                        {
                            ITypedElement typedElement =
                                GetInstance(EditionTextBox.SelectionStart - 2) as ITypedElement;
                            if (typedElement != null)
                            {
                                EditionTextBox.SelectedText = e.KeyChar + " " + typedElement.Type.FullName;
                                e.Handled = true;
                            }
                        }
                        break;
                    }
                }
            }
            catch (Exception)
            {
            }
        }
Beispiel #6
0
        /// <summary>
        ///     Builds the explanation of the element
        /// </summary>
        /// <param name="explanation"></param>
        /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
        public virtual void GetExplain(TextualExplanation explanation, bool explainSubElements)
        {
            explanation.Write("FOLDER ");
            explanation.WriteLine(Name);

            if (explainSubElements)
            {
                explanation.Indent(2, () =>
                {
                    foreach (Folder folder in Folders)
                    {
                        folder.GetExplain(explanation, explainSubElements);
                    }
                });
            }

            explanation.Indent(2, () =>
            {
                foreach (Translation translation in Translations)
                {
                    translation.GetExplain(explanation, explainSubElements);
                }
            });
            explanation.Write("END FOLDER ");
            explanation.WriteLine(Name);
        }
Beispiel #7
0
        /// <summary>
        ///     Builds the explanation of the element
        /// </summary>
        /// <param name="explanation"></param>
        /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
        public virtual void GetExplain(TextualExplanation explanation, bool explainSubElements)
        {
            explanation.Comment(this);

            if (!string.IsNullOrEmpty(getCondition()))
            {
                explanation.Write("IF ");
                if (ConditionTree != null)
                {
                    ConditionTree.GetExplain(explanation);
                }
                else
                {
                    explanation.Write(getCondition());
                }
                explanation.WriteLine(" THEN");
                explanation.Indent(2, () => explanation.Expression(this));
                explanation.WriteLine("END IF");
            }
            else
            {
                explanation.Expression(this);
                explanation.WriteLine();
            }
        }
Beispiel #8
0
        /// <summary>
        ///     Builds the explanation of the element
        /// </summary>
        /// <param name="explanation"></param>
        /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
        public override void GetExplain(TextualExplanation explanation, bool explainSubElements)
        {
            explanation.Comment(this);

            if (!IsAbstract)
            {
                explanation.Write("STRUCTURE ");
            }
            else
            {
                explanation.Write("INTERFACE ");
            }
            explanation.WriteLine(Name);

            explanation.Indent(2, () =>
            {
                foreach (Structure structure in Interfaces)
                {
                    if (structure != null)
                    {
                        explanation.Write("IMPLEMENTS ");
                        explanation.WriteLine(structure.Name);
                    }
                }

                foreach (StructureElement element in Elements)
                {
                    explanation.Write(element, explainSubElements);
                }

                if (!IsAbstract)
                {
                    foreach (Procedure procedure in Procedures)
                    {
                        explanation.Write(procedure, explainSubElements);
                    }

                    foreach (StateMachine stateMachine in StateMachines)
                    {
                        explanation.Write(stateMachine, explainSubElements);
                    }

                    foreach (Rule rule in Rules)
                    {
                        explanation.Write(rule, explainSubElements);
                    }
                }
            });

            if (!IsAbstract)
            {
                explanation.WriteLine("END STRUCTURE");
            }
            else
            {
                explanation.WriteLine("END INTERFACE");
            }
        }
 /// <summary>
 ///     Builds the explanation of the element
 /// </summary>
 /// <param name="explanation"></param>
 /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
 public override void GetExplain(TextualExplanation explanation, bool explainSubElements = true)
 {
     explanation.Write("STABILIZE ");
     explanation.Write(Expression);
     explanation.Write(" INITIAL_VALUE ");
     explanation.Write(InitialValue);
     explanation.Write(" STOP_CONDITION ");
     explanation.Write(Condition);
 }
Beispiel #10
0
 /// <summary>
 ///     Builds the explanation of the element
 /// </summary>
 /// <param name="explanation"></param>
 /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
 public override void GetExplain(TextualExplanation explanation, bool explainSubElements = true)
 {
     explanation.Write("LET ");
     explanation.Write(BoundVariable.Name);
     explanation.Write(" <- ");
     explanation.Write(BindingExpression);
     explanation.Write(" IN ");
     explanation.Write(Expression);
 }
 /// <summary>
 ///     Builds the explanation of the element
 /// </summary>
 /// <param name="explanation"></param>
 /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
 public override void GetExplain(TextualExplanation explanation, bool explainSubElements = true)
 {
     explanation.Write("REPLACE ");
     explanation.Write(Condition);
     explanation.Write(" IN ");
     explanation.Write(ListExpression);
     explanation.Write(" BY ");
     explanation.Write(Value);
 }
Beispiel #12
0
        /// <summary>
        ///     Builds the explanation of the element
        /// </summary>
        /// <param name="explanation"></param>
        /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
        public override void GetExplain(TextualExplanation explanation, bool explainSubElements)
        {
            base.GetExplain(explanation, explainSubElements);

            explanation.Write("COLLECTION ");
            explanation.Write(Name);
            explanation.Write(" OF ");
            explanation.WriteLine(getTypeName());
        }
        /// <summary>
        ///     Builds the explanation of the element
        /// </summary>
        /// <param name="explanation"></param>
        /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
        public virtual void GetExplain(TextualExplanation explanation, bool explainSubElements)
        {
            int indent = 0;

            if (PreConditions.Count > 0)
            {
                indent = 2;
                explanation.Write("IF ");
                if (PreConditions.Count > 1)
                {
                    // Prepare the space for the following ANDs
                    explanation.Write("   ");
                }

                bool first = true;
                foreach (PreCondition preCondition in PreConditions)
                {
                    if (!first)
                    {
                        explanation.WriteLine();
                        explanation.Write("   AND ");
                    }
                    preCondition.GetExplain(explanation, explainSubElements);
                    first = false;
                }
                explanation.WriteLine();
                explanation.WriteLine("THEN");
            }
            else
            {
                explanation.WriteLine();
            }

            explanation.Indent(indent, () =>
            {
                if (Name.CompareTo(EnclosingRule.Name) != 0)
                {
                    explanation.Comment(Name);
                }

                foreach (Action action in Actions)
                {
                    explanation.Write();
                    action.GetExplain(explanation, explainSubElements);
                    explanation.WriteLine();
                }

                if (explainSubElements)
                {
                    foreach (Rule subRule in SubRules)
                    {
                        subRule.GetExplain(explanation, explainSubElements);
                    }
                }
            });
        }
Beispiel #14
0
        /// <summary>
        ///     Explains a list of namables and shows the associated textbox
        /// </summary>
        /// <param name="namable">The namable to explain</param>
        /// <param name="location">
        ///     The location where the explain box should be displayed. If empty is displayed, the location is
        ///     computed based on the combo box location
        /// </param>
        /// <param name="sensibleToMouseMove">Indicates that the explain box should be closed when the mouse moves</param>
        private void ExplainAndShow(INamable namable, Point location, bool sensibleToMouseMove)
        {
            explainRichTextBox.Text = "";
            if (namable != null)
            {
                TextualExplanation explanation    = new TextualExplanation();
                ITextualExplain    textualExplain = namable as ITextualExplain;
                if (textualExplain != null)
                {
                    textualExplain.GetExplain(explanation, false);
                }

                explainRichTextBox.Text = explanation.Text;
                explainRichTextBox.ProcessAllLines();

                if (location == Point.Empty)
                {
                    if (SelectionComboBox.DroppedDown)
                    {
                        explainRichTextBox.Location = new Point(
                            SelectionComboBox.Location.X + SelectionComboBox.Size.Width,
                            SelectionComboBox.Location.Y + SelectionComboBox.Size.Height
                            );
                    }
                    else
                    {
                        explainRichTextBox.Location = new Point(
                            SelectionComboBox.Location.X,
                            SelectionComboBox.Location.Y + SelectionComboBox.Size.Height
                            );
                    }
                }
                else
                {
                    explainRichTextBox.Location = new Point(
                        Math.Min(location.X, EditionTextBox.Size.Width - explainRichTextBox.Size.Width),
                        Math.Min(location.Y, EditionTextBox.Size.Height - explainRichTextBox.Size.Height));
                }

                ConsiderMouseMoveToCloseExplanation = sensibleToMouseMove;

                explainRichTextBox.Size = new Size(400, 200);
                if (explainRichTextBox.Size.Width >= Size.Width * 0.8)
                {
                    explainRichTextBox.Size = new Size((int)(Size.Width * 0.8), explainRichTextBox.Size.Height);
                }
                if (explainRichTextBox.Size.Height >= Size.Height * 0.8)
                {
                    explainRichTextBox.Size = new Size(explainRichTextBox.Size.Width, (int)(Size.Height * 0.8));
                }

                explainRichTextBox.Show();
                EditionTextBox.SendToBack();
            }
        }
Beispiel #15
0
 /// <summary>
 ///     Builds the explanation of the element
 /// </summary>
 /// <param name="explanation"></param>
 /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
 public override void GetExplain(TextualExplanation explanation, bool explainSubElements = true)
 {
     if (Designator != null)
     {
         explanation.Write(Designator);
     }
     else if (LiteralValue != null)
     {
         explanation.Write(LiteralValue);
     }
 }
Beispiel #16
0
 /// <summary>
 ///     Builds the explanation of the element
 /// </summary>
 /// <param name="explanation"></param>
 /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
 public override void GetExplain(TextualExplanation explanation, bool explainSubElements = true)
 {
     explanation.Write("FUNCTION ");
     explanation.ExplainList(Parameters, explainSubElements, ", ", parameter =>
     {
         explanation.Write(parameter.Name);
         explanation.Write(" : ");
         explanation.Write(parameter.TypeName);
     });
     explanation.Write(" => ");
     explanation.Write(Expression);
 }
Beispiel #17
0
 /// <summary>
 ///     Builds the explanation of the element
 /// </summary>
 /// <param name="explanation"></param>
 /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
 public override void GetExplain(TextualExplanation explanation, bool explainSubElements = true)
 {
     explanation.Write("APPLY ");
     explanation.Write(AppliedStatement);
     explanation.Write(" ON ");
     explanation.Write(ListExpression);
     if (ConditionExpression != null)
     {
         explanation.Write(" | ");
         explanation.Write(ConditionExpression);
     }
 }
Beispiel #18
0
        /// <summary>
        ///     Builds the explanation of the element
        /// </summary>
        /// <param name="explanation"></param>
        /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
        public virtual void GetExplain(TextualExplanation explanation, bool explainSubElements)
        {
            explanation.Comment(this);

            explanation.Indent(2, () =>
            {
                foreach (Step step in Steps)
                {
                    step.GetExplain(explanation, explainSubElements);
                    explanation.WriteLine();
                }
            });
        }
Beispiel #19
0
 /// <summary>
 ///     Builds the explanation of the element
 /// </summary>
 /// <param name="explanation"></param>
 /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
 public virtual void GetExplain(TextualExplanation explanation, bool explainSubElements)
 {
     explanation.Comment(this);
     explanation.Write(Name);
     if (!String.IsNullOrEmpty(getValue()))
     {
         explanation.WriteLine(" : " + getValue());
     }
     else
     {
         explanation.WriteLine();
     }
 }
Beispiel #20
0
 /// <summary>
 ///     Builds the explanation of the element
 /// </summary>
 /// <param name="explanation"></param>
 /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
 public virtual void GetExplain(TextualExplanation explanation, bool explainSubElements)
 {
     explanation.WriteLine("SOURCE TEXT ");
     explanation.WriteLine(Name);
     explanation.Indent(2, () =>
     {
         foreach (SourceTextComment comment in Comments)
         {
             explanation.Write("COMMENT");
             explanation.WriteLine(comment.Name);
         }
     });
 }
Beispiel #21
0
        /// <summary>
        ///     Builds the explanation of the element
        /// </summary>
        /// <param name="explanation"></param>
        /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
        public override void GetExplain(TextualExplanation explanation, bool explainSubElements = true)
        {
            explanation.Write("INSERT ");
            explanation.Write(Value);
            explanation.Write(" IN ");
            explanation.Write(ListExpression);

            if (ReplaceElement != null)
            {
                explanation.Write(" WHEN FULL REPLACE");
                explanation.Write(ReplaceElement);
            }
        }
        /// <summary>
        ///     Builds the explanation of the element
        /// </summary>
        /// <param name="explanation"></param>
        /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
        public override void GetExplain(TextualExplanation explanation, bool explainSubElements = true)
        {
            explanation.Write(Operator);
            explanation.Write(" ");
            explanation.Write(IteratorVariable.Name);
            explanation.Write(" IN ");
            explanation.Write(ListExpression);

            if (Condition != null)
            {
                explanation.Write(" | ");
                explanation.Write(Condition);
            }
        }
Beispiel #23
0
        protected void InsertElement(ITypedElement element, TextualExplanation text)
        {
            text.Write(element.Name);
            text.Write(" => ");
            Structure structure = element.Type as Structure;

            if (structure != null)
            {
                text.WriteLine(StripUseless(structure.FullName, WritingContext()) + "{");
                text.Indent(4, () =>
                {
                    bool first = true;
                    foreach (StructureElement subElement in structure.Elements)
                    {
                        if (!first)
                        {
                            text.WriteLine(",");
                        }
                        InsertElement(subElement, text);
                        first = false;
                    }
                });
                text.WriteLine();
                text.Write("}");
            }
            else
            {
                IValue value = null;
                if (string.IsNullOrEmpty(element.Default))
                {
                    // No default value for element, get the one of the type
                    if (element.Type != null && element.Type.DefaultValue != null)
                    {
                        value = element.Type.DefaultValue;
                    }
                }
                else
                {
                    if (element.Type != null)
                    {
                        value = element.Type.getValue(element.Default);
                    }
                }

                if (value != null)
                {
                    text.Write(StripUseless(value.FullName, WritingContext()));
                }
            }
        }
        /// <summary>
        ///     Builds the explanation of the element
        /// </summary>
        /// <param name="explanation"></param>
        /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
        public override void GetExplain(TextualExplanation explanation, bool explainSubElements = true)
        {
            explanation.Write(Operator);
            explanation.Write(" ");
            explanation.Write(IteratorVariable.Name);
            explanation.Write(" IN ");
            explanation.Write(ListExpression);

            if (Condition != null)
            {
                explanation.Write(" | ");
                explanation.Write(Condition);
            }
        }
Beispiel #25
0
        /// <summary>
        ///     Builds the explanation of the element
        /// </summary>
        /// <param name="explanation"></param>
        /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
        public override void GetExplain(TextualExplanation explanation, bool explainSubElements)
        {
            base.GetExplain(explanation, explainSubElements);

            explanation.Write("ENUMERATION ");
            explanation.WriteLine(Name);

            explanation.Indent(2, () =>
            {
                foreach (EnumValue enumValue in Values)
                {
                    explanation.Write(enumValue, explainSubElements);
                }
            });
        }
Beispiel #26
0
 /// <summary>
 ///     Builds the explanation of the element
 /// </summary>
 /// <param name="explanation"></param>
 /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
 public override void GetExplain(TextualExplanation explanation, bool explainSubElements = true)
 {
     explanation.Write(Structure);
     explanation.WriteLine();
     explanation.Write("{");
     explanation.Indent(2, () => explanation.ExplainList(Associations, explainSubElements, ", ", element =>
     {
         explanation.WriteLine();
         explanation.Write(element.Key);
         explanation.Write(" => ");
         explanation.Write(element.Value);
     }));
     explanation.WriteLine();
     explanation.Write("}");
 }
Beispiel #27
0
        /// <summary>
        ///     Builds the explanation of the element
        /// </summary>
        /// <param name="explanation"></param>
        /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
        public virtual void GetExplain(TextualExplanation explanation, bool explainSubElements)
        {
            explanation.Write("STATE ");
            explanation.WriteLine(Name);

            if (explainSubElements)
            {
                foreach (Rule rule in StateMachine.Rules)
                {
                    // ReSharper disable once ConditionIsAlwaysTrueOrFalse
                    rule.GetExplain(explanation, explainSubElements);
                    explanation.WriteLine();
                }
            }
        }
 /// <summary>
 ///     Builds the explanation of the element
 /// </summary>
 /// <param name="explanation"></param>
 /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
 public override void GetExplain(TextualExplanation explanation, bool explainSubElements = true)
 {
     if (ListElements.Count > 0)
     {
         explanation.Write("[");
         explanation.Indent(2,
                            () => explanation.ExplainList(ListElements, explainSubElements, ", ",
                                                          element => element.GetExplain(explanation, explainSubElements)));
         explanation.Write("]");
     }
     else
     {
         explanation.Write("[]");
     }
 }
Beispiel #29
0
        /// <summary>
        ///     Builds the explanation of the element
        /// </summary>
        /// <param name="explanation"></param>
        /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
        public virtual void GetExplain(TextualExplanation explanation, bool explainSubElements)
        {
            explanation.Comment(this);

            string typeName = TypeName;

            if (Type != null)
            {
                typeName = Type.FullName;
            }

            explanation.Write("FIELD ");
            explanation.Write(Name);
            explanation.Write(" : ");
            explanation.WriteLine(typeName);
        }
Beispiel #30
0
        /// <summary>
        ///     Builds the explanation of the element
        /// </summary>
        /// <param name="explanation"></param>
        /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
        public virtual void GetExplain(TextualExplanation explanation, bool explainSubElements)
        {
            explanation.Comment(this);
            explanation.Write("PROCEDURE ");
            explanation.Write(Name);

            if (FormalParameters.Count > 0)
            {
                bool first = true;
                explanation.Write("(");
                if (FormalParameters.Count > 1)
                {
                    explanation.WriteLine();
                }

                explanation.Indent(4, () =>
                {
                    foreach (Parameter parameter in FormalParameters)
                    {
                        if (!first)
                        {
                            explanation.WriteLine(",");
                        }
                        explanation.Write(parameter.Name);
                        explanation.Write(" : ");
                        explanation.Write(parameter.TypeName);
                        first = false;
                    }
                });
                explanation.WriteLine(")");
            }
            else
            {
                explanation.WriteLine("()");
            }

            explanation.Indent(2, () =>
            {
                foreach (Rule rule in Rules)
                {
                    rule.GetExplain(explanation, explainSubElements);
                    explanation.WriteLine();
                }
            });

            explanation.WriteLine("END PROCEDURE ");
        }
        /// <summary>
        ///     Builds the explanation of the element
        /// </summary>
        /// <param name="explanation"></param>
        /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
        public override void GetExplain(TextualExplanation explanation, bool explainSubElements = true)
        {
            explanation.Write(OPERATOR);
            explanation.Write(" ");
            ListExpression.GetExplain(explanation);

            if (Condition != null)
            {
                explanation.Write(" | ");
                Condition.GetExplain(explanation);
            }

            explanation.Write(" USING ");
            explanation.Write(IteratorVariable.Name);
            explanation.Write(" IN ");
            IteratorExpression.GetExplain(explanation);
        }
Beispiel #32
0
        /// <summary>
        ///     Builds the explanation of the element
        /// </summary>
        /// <param name="explanation"></param>
        /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
        public override void GetExplain(TextualExplanation explanation, bool explainSubElements)
        {
            base.GetExplain(explanation, explainSubElements);

            explanation.Write("STATE MACHINE ");
            explanation.WriteLine(Name);
            explanation.Indent(2, () =>
            {
                foreach (State state in States)
                {
                    explanation.Write(state, false);
                }
                foreach (Rule rule in Rules)
                {
                    explanation.Write(rule, explainSubElements);
                }
            });
        }
Beispiel #33
0
 /// <summary>
 ///     Builds the explanation of the element
 /// </summary>
 /// <param name="explanation"></param>
 /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
 public virtual void GetExplain(TextualExplanation explanation, bool explainSubElements)
 {
     explanation.Comment(this);
     explanation.Expression(this);
 }
        /// <summary>
        ///     Builds the explanation of the element
        /// </summary>
        /// <param name="explanation"></param>
        /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
        public override void GetExplain(TextualExplanation explanation, bool explainSubElements)
        {
            explanation.Comment(this);
            explanation.Write("FUNCTION ");
            explanation.Write(Name);
            explanation.Write(" (");
            if (FormalParameters.Count > 0)
            {
                explanation.Indent(2, () =>
                {
                    bool first = true;
                    foreach (Parameter parameter in FormalParameters)
                    {
                        if (first)
                        {
                            explanation.WriteLine();
                            first = false;
                        }
                        else
                        {
                            explanation.WriteLine(",");
                        }
                        parameter.GetExplain(explanation, true);
                    }
                });
            }
            explanation.WriteLine(")");
            explanation.Write("RETURNS ");
            explanation.WriteLine(TypeName);

            {
                bool first = true;
                foreach (Case cas in Cases)
                {
                    if (!first)
                    {
                        explanation.Write("ELSE ");
                    }
                    cas.GetExplain(explanation, explainSubElements);
                    explanation.WriteLine();
                    first = false;
                }
            }
            explanation.Write("END FUNCTION");
        }
 /// <summary>
 ///     Builds the explanation of the element
 /// </summary>
 /// <param name="explanation"></param>
 /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
 public override void GetExplain(TextualExplanation explanation, bool explainSubElements)
 {
     explanation.WriteLine(Changes.ToString());
 }
        /// <summary>
        ///     Builds the explanation of the element
        /// </summary>
        /// <param name="explanation"></param>
        /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
        public virtual void GetExplain(TextualExplanation explanation, bool explainSubElements)
        {
            if (string.IsNullOrEmpty(Comment))
            {
                if (Type != null)
                {
                    explanation.Comment(Type);
                }
            }
            else
            {
                explanation.Comment(this);
            }

            explanation.Write(Name);
            explanation.Write(" : ");
            explanation.Write(TypeName);
            if (Value != null)
            {
                explanation.Write(" = ");
                explanation.Write(Value.LiteralName);
            }
            explanation.WriteLine();
        }
        /// <summary>
        ///     Builds the explanation of the element
        /// </summary>
        /// <param name="explanation"></param>
        /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
        public override void GetExplain(TextualExplanation explanation, bool explainSubElements)
        {
            explanation.Comment(this);

            if (!IsAbstract)
            {
                explanation.Write("STRUCTURE ");
            }
            else
            {
                explanation.Write("INTERFACE ");
            }
            explanation.WriteLine(Name);

            explanation.Indent(2, () =>
            {
                foreach (Structure structure in Interfaces)
                {
                    if (structure != null)
                    {
                        explanation.Write("IMPLEMENTS ");
                        explanation.WriteLine(structure.Name);
                    }
                }

                foreach (StructureElement element in Elements)
                {
                    element.GetExplain(explanation, explainSubElements);
                }

                if (!IsAbstract)
                {
                    foreach (Procedure procedure in Procedures)
                    {
                        procedure.GetExplain(explanation, explainSubElements);
                    }

                    foreach (StateMachine stateMachine in StateMachines)
                    {
                        stateMachine.GetExplain(explanation, explainSubElements);
                    }

                    foreach (Rule rule in Rules)
                    {
                        rule.GetExplain(explanation, explainSubElements);
                    }
                }
            });

            if (!IsAbstract)
            {
                explanation.WriteLine("END STRUCTURE");
            }
            else
            {
                explanation.WriteLine("END INTERFACE");
            }
        }
Beispiel #38
0
        /// <summary>
        ///     Builds the explanation of the element
        /// </summary>
        /// <param name="explanation"></param>
        /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
        public virtual void GetExplain(TextualExplanation explanation, bool explainSubElements)
        {
            explanation.Comment(Name);

            explanation.Indent(2, () =>
            {
                foreach (Action action in Actions)
                {
                    action.GetExplain(explanation, explainSubElements);
                    explanation.WriteLine();
                }
            });

            explanation.WriteLine("IMPLIES");

            explanation.Indent(2, () =>
            {
                foreach (Expectation expectation in Expectations)
                {
                    expectation.GetExplain(explanation, explainSubElements);
                    explanation.WriteLine();
                }
            });
        }
        /// <summary>
        ///     Builds the explanation of the element
        /// </summary>
        /// <param name="explanation"></param>
        /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
        public virtual void GetExplain(TextualExplanation explanation, bool explainSubElements)
        {
            int indent = 0;

            if (PreConditions.Count > 0)
            {
                indent = 2;
                explanation.Write("IF ");
                if (PreConditions.Count > 1)
                {
                    // Prepare the space for the following ANDs
                    explanation.Write("   ");
                }

                bool first = true;
                foreach (PreCondition preCondition in PreConditions)
                {
                    if (!first)
                    {
                        explanation.WriteLine();
                        explanation.Write("   AND ");
                    }
                    preCondition.GetExplain(explanation, explainSubElements);
                    first = false;
                }
                explanation.WriteLine();
                explanation.WriteLine("THEN");
            }
            else
            {
                explanation.WriteLine();
            }

            explanation.Indent(indent, () =>
            {
                if (Name.CompareTo(EnclosingRule.Name) != 0)
                {
                    explanation.Comment(Name);
                }

                foreach (Action action in Actions)
                {
                    explanation.Write();
                    action.GetExplain(explanation, explainSubElements);
                    explanation.WriteLine();
                }

                if (explainSubElements)
                {
                    foreach (Rule subRule in SubRules)
                    {
                        subRule.GetExplain(explanation, explainSubElements);
                    }
                }
            });
        }
 /// <summary>
 ///     Builds the explanation of the element
 /// </summary>
 /// <param name="explanation"></param>
 /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
 public override void GetExplain(TextualExplanation explanation, bool explainSubElements = true)
 {
     Call.GetExplain(explanation);
 }
        /// <summary>
        ///     Builds the explanation of the element
        /// </summary>
        /// <param name="explanation"></param>
        /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
        public override void GetExplain(TextualExplanation explanation, bool explainSubElements = true)
        {
            explanation.Write("INSERT ");
            Value.GetExplain(explanation);
            explanation.Write(" IN ");
            ListExpression.GetExplain(explanation);

            if (ReplaceElement != null)
            {
                explanation.Write(" WHEN FULL REPLACE");
                ReplaceElement.GetExplain(explanation);
            }
        }
Beispiel #42
0
        /// <summary>
        ///     Builds the explanation of the element
        /// </summary>
        /// <param name="explanation"></param>
        /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
        public virtual void GetExplain(TextualExplanation explanation, bool explainSubElements)
        {
            explanation.Write("STATE ");
            explanation.WriteLine(Name);

            if (explainSubElements)
            {
                foreach (Rule rule in StateMachine.Rules)
                {
                    // ReSharper disable once ConditionIsAlwaysTrueOrFalse
                    rule.GetExplain(explanation, explainSubElements);
                    explanation.WriteLine();
                }
            }
        }
 /// <summary>
 ///     Builds the explanation of the element
 /// </summary>
 /// <param name="explanation"></param>
 /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
 public override void GetExplain(TextualExplanation explanation, bool explainSubElements = true)
 {
     explanation.ExplainList(Arguments, true, ".", expression => expression.GetExplain(explanation));
 }
        /// <summary>
        ///     Builds the explanation of the element
        /// </summary>
        /// <param name="explanation"></param>
        /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
        public override void GetExplain(TextualExplanation explanation, bool explainSubElements = true)
        {
            explanation.Write("REMOVE ");

            switch (Position)
            {
                case PositionEnum.First:
                    explanation.Write("FIRST ");
                    break;

                case PositionEnum.Last:
                    explanation.Write("LAST ");
                    break;

                case PositionEnum.All:
                    explanation.Write("ALL ");
                    break;
            }

            if (Condition != null)
            {
                explanation.Write(Condition);
            }

            explanation.Write(" IN ");
            explanation.Write(ListExpression);
        }
Beispiel #45
0
        /// <summary>
        ///     Builds the explanation of the element
        /// </summary>
        /// <param name="explanation"></param>
        /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
        public override void GetExplain(TextualExplanation explanation, bool explainSubElements)
        {
            base.GetExplain(explanation, explainSubElements);
            explanation.Write("RANGE ");
            explanation.Write(Name);
            explanation.Write(" FROM ");
            explanation.Write(MinValue);
            explanation.Write(" TO ");
            explanation.WriteLine(MaxValue);

            explanation.Indent(2, () =>
            {
                foreach (EnumValue enumValue in SpecialValues)
                {
                    enumValue.GetExplain(explanation, explainSubElements);
                }
            });
        }
 /// <summary>
 ///     Builds the explanation of the element
 /// </summary>
 /// <param name="explanation"></param>
 /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
 public virtual void GetExplain(TextualExplanation explanation, bool explainSubElements)
 {
     explanation.Comment(this);
     explanation.Write(Name);
     if (!String.IsNullOrEmpty(getValue()))
     {
         explanation.WriteLine(" : " + getValue());
     }
     else
     {
         explanation.WriteLine();
     }
 }
Beispiel #47
0
        /// <summary>
        ///     Builds the explanation of the element
        /// </summary>
        /// <param name="explanation"></param>
        /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
        public virtual void GetExplain(TextualExplanation explanation, bool explainSubElements)
        {
            explanation.Write("FOLDER ");
            explanation.WriteLine(Name);

            if (explainSubElements)
            {
                explanation.Indent(2, () =>
                {
                    foreach (Folder folder in Folders)
                    {
                        folder.GetExplain(explanation, explainSubElements);
                    }
                });
            }

            explanation.Indent(2, () =>
            {
                foreach (Translation translation in Translations)
                {
                    translation.GetExplain(explanation, explainSubElements);
                }
            });
            explanation.Write("END FOLDER ");
            explanation.WriteLine(Name);
        }
 /// <summary>
 ///     Builds the explanation of the element
 /// </summary>
 /// <param name="explanation"></param>
 /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
 public void GetExplain(TextualExplanation explanation, bool explainSubElements)
 {
     explanation.Write(Name);
     explanation.Write(" : ");
     explanation.Write(TypeName);
 }
 /// <summary>
 ///     Builds the explanation of the element
 /// </summary>
 /// <param name="explanation"></param>
 /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
 public override void GetExplain(TextualExplanation explanation, bool explainSubElements = true)
 {
     if (Term != null)
     {
         explanation.Write(Term);
     }
     else
     {
         if (UnaryOp != null)
         {
             explanation.Write(UnaryOp);
             if (Expression != null)
             {
                 explanation.Write(" ");
                 explanation.Write(Expression);
             }
         }
         else if (Expression != null)
         {
             explanation.Write(" (");
             explanation.Write(Expression);
             explanation.Write(" )");
         }
     }
 }
Beispiel #50
0
 /// <summary>
 ///     Builds the explanation of the element
 /// </summary>
 /// <param name="explanation"></param>
 /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
 public override void GetExplain(TextualExplanation explanation, bool explainSubElements = true)
 {
     if (Designator != null)
     {
         explanation.Write(Designator);
     }
     else if (LiteralValue != null)
     {
         explanation.Write(LiteralValue);
     }
 }
 /// <summary>
 ///     Builds the explanation of the element
 /// </summary>
 /// <param name="explanation"></param>
 /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
 public virtual void GetExplain(TextualExplanation explanation, bool explainSubElements)
 {
     explanation.Write("REQUIREMENT SET ");
     explanation.WriteLine(Name);
 }
 /// <summary>
 ///     Builds the explanation of the element
 /// </summary>
 /// <param name="explanation"></param>
 /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
 public override void GetExplain(TextualExplanation explanation, bool explainSubElements)
 {
     base.GetExplain(explanation, explainSubElements);
     explanation.Write("COLLECTION ");
     explanation.Write(Name);
     explanation.Write(" OF ");
     explanation.WriteLine(getTypeName());
 }
 /// <summary>
 ///     Builds the explanation of the element
 /// </summary>
 /// <param name="explanation"></param>
 /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
 public override void GetExplain(TextualExplanation explanation, bool explainSubElements = true)
 {
     Structure.GetExplain(explanation);
     explanation.Write("{");
     explanation.Indent(2, () => explanation.ExplainList(Associations, explainSubElements, ", ", element =>
     {
         explanation.WriteLine();
         element.Key.GetExplain(explanation);
         explanation.Write(" => ");
         element.Value.GetExplain(explanation);
     }));
     explanation.WriteLine();
     explanation.Write("}");
 }
 /// <summary>
 ///     Builds the explanation of the element
 /// </summary>
 /// <param name="explanation"></param>
 /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
 public override void GetExplain(TextualExplanation explanation, bool explainSubElements = true)
 {
     explanation.Write("STABILIZE ");
     explanation.Write(Expression);
     explanation.Write(" INITIAL_VALUE ");
     explanation.Write(InitialValue);
     explanation.Write(" STOP_CONDITION ");
     explanation.Write(Condition);
 }
 /// <summary>
 ///     Builds the explanation of the element
 /// </summary>
 /// <param name="explanation"></param>
 /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
 public override void GetExplain(TextualExplanation explanation, bool explainSubElements = true)
 {
     explanation.Write(Image);
 }
        /// <summary>
        ///     Builds the explanation of the element
        /// </summary>
        /// <param name="explanation"></param>
        /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
        public virtual void GetExplain(TextualExplanation explanation, bool explainSubElements)
        {
            explanation.Comment(this);

            if (!string.IsNullOrEmpty(getCondition()))
            {
                explanation.Write("IF ");
                if (ConditionTree != null)
                {
                    ConditionTree.GetExplain(explanation);
                }
                else
                {
                    explanation.Write(getCondition());
                }
                explanation.WriteLine(" THEN");
                explanation.Indent(2, () => explanation.Expression(this));
                explanation.WriteLine("END IF");

            }
            else
            {
                explanation.Expression(this);
                explanation.WriteLine();
            }
        }
        /// <summary>
        ///     Builds the explanation of the element
        /// </summary>
        /// <param name="explanation"></param>
        /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
        public virtual void GetExplain(TextualExplanation explanation, bool explainSubElements)
        {
            explanation.Comment(this);

            explanation.Indent(2, () =>
            {
                foreach (Step step in Steps)
                {
                    step.GetExplain(explanation, explainSubElements);
                    explanation.WriteLine();
                }
            });
        }
 /// <summary>
 ///     Builds the explanation of the element
 /// </summary>
 /// <param name="explanation"></param>
 /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
 public override void GetExplain(TextualExplanation explanation, bool explainSubElements = true)
 {
     explanation.Write("FUNCTION ");
     explanation.ExplainList(Parameters, explainSubElements, ", ", parameter =>
     {
         explanation.Write(parameter.Name);
         explanation.Write(" : ");
         explanation.Write(parameter.TypeName);
     });
     explanation.Write(" => ");
     explanation.Write(Expression);
 }
        /// <summary>
        ///     Called when the drop operation is performed on this text box
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Editor_DragDropHandler(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent("WindowsForms10PersistentObject", false))
            {
                object data = e.Data.GetData("WindowsForms10PersistentObject");
                BaseTreeNode sourceNode = data as BaseTreeNode;
                if (sourceNode != null)
                {
                    VariableTreeNode variableNode = sourceNode as VariableTreeNode;
                    if (variableNode != null)
                    {
                        EditionTextBox.SelectedText = SetVariable(variableNode.Item);
                    }
                    else
                    {
                        StructureTreeNode structureTreeNode = sourceNode as StructureTreeNode;
                        if (structureTreeNode != null)
                        {
                            TextualExplanation text = new TextualExplanation();

                            Structure structure = structureTreeNode.Item;
                            CreateDefaultStructureValue(text, structure);
                            EditionTextBox.SelectedText = text.Text;
                        }
                        else
                        {
                            EditionTextBox.SelectedText = StripUseless(sourceNode.Model.FullName, WritingContext());
                        }
                    }
                }

                OLVListItem item = data as OLVListItem;
                if (item != null)
                {
                    IVariable variable = item.RowObject as IVariable;
                    if (variable != null)
                    {
                        EditionTextBox.SelectedText = SetVariable(variable);
                    }
                }
            }
        }
 /// <summary>
 ///     Builds the explanation of the element
 /// </summary>
 /// <param name="explanation"></param>
 /// <param name="explainSubElements">Precises if we need to explain the sub elements (if any)</param>
 public override void GetExplain(TextualExplanation explanation, bool explainSubElements)
 {
     base.GetExplain(explanation, explainSubElements);
     explanation.Write("STATE MACHINE ");
     explanation.WriteLine(Name);
     explanation.Indent(2, () =>
     {
         foreach (State state in States)
         {
             state.GetExplain(explanation, false);
         }
         foreach (Rule rule in Rules)
         {
             rule.GetExplain(explanation, explainSubElements);
         }
     });
 }