Inheritance: Utils.ModelElement
        /// <summary>
        ///     Refactors all IExpressionables
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="visitSubNodes"></param>
        public override void visit(BaseModelElement obj, bool visitSubNodes)
        {
            IExpressionable expressionable = obj as IExpressionable;
            if (expressionable != null)
            {
                Compiler.RefactorIExpressionable(null, expressionable);
            }

            base.visit(obj, visitSubNodes);
        }
        public override void visit(BaseModelElement obj, bool visitSubNodes)
        {
            ModelElement element = (ModelElement) obj;

            if (AutomaticallyGenerateGuid)
            {
                // Side effect : creates the guid of the element
                // ReSharper disable once UnusedVariable
                string guid = element.Guid;
            }

            base.visit(obj, visitSubNodes);
        }
Esempio n. 3
0
            /// <summary>
            ///     Walk through all elements
            /// </summary>
            /// <param name="obj"></param>
            /// <param name="visitSubNodes"></param>
            public override void visit(BaseModelElement obj, bool visitSubNodes)
            {
                IExpressionable expressionable = obj as IExpressionable;
                if (expressionable != null)
                {
                    ConsiderInterpreterTreeNode(expressionable.Tree);
                }

                ITypedElement element = obj as ITypedElement;
                if (element != null)
                {
                    ConsiderTypeOfElement(element);
                }

                Function function = obj as Function;
                if (function != null)
                {
                    Type current = function.ReturnType;
                    while (current != null)
                    {
                        if (current == Model && function != Model)
                        {
                            Usages.Add(new Usage(Model, function, Usage.ModeEnum.Type));
                        }
                        current = EnclosingFinder<Type>.find(current);
                    }
                }

                /* searching for the implementation of interfaces */
                Structure structure = obj as Structure;
                Structure modelStructure = Model as Structure;
                if (structure != null && modelStructure != null && structure != modelStructure)
                {
                    if (modelStructure.IsAbstract && structure.ImplementedStructures.Contains(modelStructure))
                    {
                        Usages.Add(new Usage(Model, structure, Usage.ModeEnum.Interface));
                    }
                }

                /* searching for the redefinition of structure elements */
                StructureElement currentStructureElement = Model as StructureElement;
                StructureElement parameterStructureElement = obj as StructureElement;
                if (currentStructureElement != null && parameterStructureElement != null)
                {
                    Structure enclosingStructure = currentStructureElement.Enclosing as Structure;
                    Structure enclosingParameterStructure = parameterStructureElement.Enclosing as Structure;
                    if (enclosingStructure != null &&
                        enclosingParameterStructure != null &&
                        enclosingParameterStructure.IsAbstract &&
                        enclosingStructure.StructureElementIsInherited(currentStructureElement) &&
                        enclosingStructure.InterfaceIsInherited(enclosingParameterStructure))
                    {
                        if (currentStructureElement.Name == parameterStructureElement.Name &&
                            currentStructureElement.Type == parameterStructureElement.Type)
                        {
                            Usages.Add(new Usage(currentStructureElement, parameterStructureElement,
                                Usage.ModeEnum.Redefines));
                        }
                    }
                }

                base.visit(obj, visitSubNodes);
            }
            /// <summary>
            ///     PropagatesDependancy all elements
            /// </summary>
            /// <param name="obj"></param>
            /// <param name="visitSubNodes"></param>
            public override void visit(BaseModelElement obj, bool visitSubNodes)
            {
                if (obj.CacheDependancy != null)
                {
                    BrowsedElements = new HashSet<Utils.ModelElement> {obj};

                    HashSet<Utils.ModelElement> dependingElements = obj.CacheDependancy;
                    obj.CacheDependancy = null;
                    foreach (Utils.ModelElement depending in dependingElements)
                    {
                        object current = depending;
                        while (current != null)
                        {
                            Utils.ModelElement currentElement = current as Utils.ModelElement;
                            if (currentElement != null)
                            {
                                PropagatesDependancy(currentElement, obj);
                            }

                            IEnclosed enclosed = current as IEnclosed;
                            if (enclosed != null)
                            {
                                current = enclosed.Enclosing;
                            }
                            else
                            {
                                current = null;
                            }
                        }
                    }
                }

                base.visit(obj, visitSubNodes);
            }
Esempio n. 5
0
        public override void visit(BaseModelElement obj, bool visitSubNodes)
        {
            IExpressionable expressionnable = obj as IExpressionable;
            if (expressionnable != null)
            {
                // In case of rebuild, cleans the previously constructed tree
                if (CurrentCompile.Rebuild)
                {
                    expressionnable.CleanCompilation();
                }
                // Ensures that the expressionable is compiled
                expressionnable.Compile();
            }

            ITypedElement typedElement = obj as ITypedElement;
            if (typedElement != null)
            {
                // Ensures that the type of the corresponding element is cached
                Type type = typedElement.Type;
            }

            base.visit(obj, visitSubNodes);
        }
            public override void visit(BaseModelElement obj, bool visitSubNodes)
            {
                ModelElement element = (ModelElement) obj;

                string guid = element.Guid;
                if (guid != null)
                {
                    ModelElement cachedElement;
                    if (_dictionary.TryGetValue(guid, out cachedElement))
                    {
                        if (cachedElement != null && element != cachedElement)
                        {
                            throw new Exception("Model element collision found");
                        }
                    }
                    else
                    {
                        _dictionary[element.Guid] = element;
                    }
                }

                base.visit(obj, visitSubNodes);
            }
 public virtual void visit(BaseModelElement obj, bool visitSubNodes)
 {
     visit ((IXmlBBase)obj, false);
     if (visitSubNodes){
     IXmlBBase[] Subs  = acceptor.subElements((IXmlBBase)obj);
     if (Subs != null){
     for (int i=0; i<Subs.Length; i++) {
       dispatch(Subs[i], true);
     } // If
     } // If
     }
 }
        /// <summary>
        ///     Actually counts the messages
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="visitSubNodes"></param>
        public override void visit(BaseModelElement obj, bool visitSubNodes)
        {
            Count(obj);

            base.visit(obj, visitSubNodes);
        }
            public override void visit(BaseModelElement obj, bool visitSubNodes)
            {
                IFinder finder = obj as IFinder;

                if (finder != null)
                {
                    FinderRepository.INSTANCE.UnRegister(finder);
                }

                base.visit(obj, visitSubNodes);
            }
Esempio n. 10
0
        public override void visit(BaseModelElement obj, bool visitSubNodes)
        {
            checkUsage(obj as ModelElement);

            base.visit(obj, visitSubNodes);
        }
            /// <summary>
            ///     Ensure that empty comments are not stored in the XML file
            /// </summary>
            /// <param name="obj"></param>
            /// <param name="visitSubNodes"></param>
            public override void visit(BaseModelElement obj, bool visitSubNodes)
            {
                ICommentable commentable = obj as ICommentable;
                if (commentable != null)
                {
                    if (commentable.Comment == "")
                    {
                        commentable.Comment = null;
                    }
                }

                base.visit(obj, visitSubNodes);
            }
            /// <summary>
            ///     Override for visiting a model element. If the model element is not a namespace,
            ///     but its direct enclosing is a namespace, the element is imported and the visitor does
            ///     not go further down the subnodes.
            /// </summary>
            /// <param name="obj"></param>
            /// <param name="visitSubNodes"></param>
            public override void visit(BaseModelElement obj, bool visitSubNodes)
            {
                ModelElement element = obj as ModelElement;
                if (element != null && !(element is NameSpace))
                {
                    element.Merge();
                }

                base.visit(obj, visitSubNodes);
            }
        public override void visit(BaseModelElement obj, bool visitSubNodes)
        {
            checkComment(obj as ICommentable);

            ModelElement model = obj as ModelElement;
            if (model != null)
            {
                checkUpdate(model);
            }

            base.visit(obj, visitSubNodes);
        }
        /// <summary>
        ///     Clears the cache dependancy when a full rebuilt is asked
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="visitSubNodes"></param>
        public override void visit(BaseModelElement obj, bool visitSubNodes)
        {
            // Clear the update information, to be built later
            ModelElement modelElement = obj as ModelElement;
            if (modelElement != null)
            {
                modelElement.UpdatedBy.Clear();
            }

            if (Options.Rebuild)
            {
                obj.CacheDependancy = null;
            }

            base.visit(obj, visitSubNodes);
        }
Esempio n. 15
0
            public override void visit(BaseModelElement obj, bool visitSubNodes)
            {
                RefactorIExpressionable(NameSpace, obj as IExpressionable);
                RefactorTypedElement(NameSpace, obj as ITypedElement);

                base.visit(obj, visitSubNodes);
            }
 /// <summary>
 ///     Actually counts
 /// </summary>
 /// <param name="obj"></param>
 private void Count(BaseModelElement obj)
 {
     foreach (ElementLog log in obj.Messages)
     {
         switch (log.Level)
         {
             case ElementLog.LevelEnum.Error:
                 Error += 1;
                 break;
             case ElementLog.LevelEnum.Warning:
                 Warning += 1;
                 break;
             case ElementLog.LevelEnum.Info:
                 Info += 1;
                 break;
         }
     }
 }
Esempio n. 17
0
            public override void visit(BaseModelElement obj, bool visitSubNodes)
            {
                IExpressionable expressionable = obj as IExpressionable;
                if (expressionable != null)
                {
                    try
                    {
                        RelocateTree refactorer = new RelocateTree(BaseLocation);
                        refactorer.PerformUpdate(expressionable);
                    }
                    catch (Exception e)
                    {
                        obj.AddWarning("Cannot refactor this element, reason = " + e.Message);
                    }
                }

                base.visit(obj, visitSubNodes);
            }
 public virtual void visit(BaseModelElement obj)
 {
     visit(obj, true);
 }
Esempio n. 19
0
        public override void visit(BaseModelElement obj, bool visitSubNodes)
        {
            IExpressionable expressionable = obj as IExpressionable;
            if (expressionable != null)
            {
                // In case of rebuild, cleans the previously constructed tree
                if (CurrentCompile.Rebuild)
                {
                    expressionable.CleanCompilation();
                }
                // Ensures that the expressionable is compiled
                expressionable.Compile();

                Structure structure = expressionable as Structure;
                if (structure != null)
                {
                    if (structure != structure.UnifiedStructure)
                    {
                        visit(structure.UnifiedStructure, visitSubNodes);
                    }
                }

                StateMachine stateMachine = expressionable as StateMachine;
                if (stateMachine != null)
                {
                    if (stateMachine != stateMachine.UnifiedStateMachine)
                    {
                        visit(stateMachine.UnifiedStateMachine, visitSubNodes);
                    }
                }
            }

            ITypedElement typedElement = obj as ITypedElement;
            if (typedElement != null)
            {
                // Ensures that the type of the corresponding element is cached
                Type type = typedElement.Type;
            }

            Function function = obj as Function;
            if (function != null)
            {
                Type returnType = function.ReturnType;
            }

            base.visit(obj, visitSubNodes);
        }
 public void copyTo(BaseModelElement other)
 {
     other.aGuid = aGuid;
     other.aUpdates = aUpdates;
     other.aIsRemoved = aIsRemoved;
 }
Esempio n. 21
0
            /// <summary>
            ///     Cleans up the declared elements dictionaries
            /// </summary>
            /// <param name="obj"></param>
            /// <param name="visitSubNodes"></param>
            public override void visit(BaseModelElement obj, bool visitSubNodes)
            {
                ModelElement modelElement = obj as ModelElement;
                if (modelElement != null)
                {
                    if (modelElement.getUpdates() != null)
                    {
                        // find the model element updated by obj and add to its list of updates
                        ModelElement baseElement = GuidCache.Instance.GetModel(modelElement.getUpdates());
                        if (baseElement != null)
                        {
                            baseElement.UpdatedBy.Add(modelElement);
                        }

                        base.visit(obj, visitSubNodes);
                    }
                }
            }
Esempio n. 22
0
            public override void visit(BaseModelElement obj, bool visitSubNodes)
            {
                ModelElement element = (ModelElement) obj;

                if (element.Messages.Count > 0)
                {
                    List<ElementLog> messages = new List<ElementLog>();
                    messages.AddRange(element.Messages);
                    Markings[element] = messages;
                }

                base.visit(obj, visitSubNodes);
            }
Esempio n. 23
0
            public override void visit(BaseModelElement obj, bool visitSubNodes)
            {
                IExpressionable expressionnable = obj as IExpressionable;
                if (expressionnable != null)
                {
                    Function enclosingFunction = EnclosingFinder<Function>.find(obj, true);
                    if (enclosingFunction != null)
                    {
                        // The value of the function depends on this.
                        TheReferenceVisitor.UpdateReferences(enclosingFunction, expressionnable.Tree);
                    }
                }

                base.visit(obj, visitSubNodes);
            }
            public override void visit(BaseModelElement obj, bool visitSubNodes)
            {
                foreach (ElementLog log in obj.Messages)
                {
                    if (log.Level == ElementLog.LevelEnum.Error)
                    {
                        ErrorMessageFound = log;
                        break;
                    }
                }

                if (ErrorMessageFound == null)
                {
                    base.visit(obj, visitSubNodes);
                }
            }
Esempio n. 25
0
            public override void visit(BaseModelElement obj, bool visitSubNodes)
            {
                foreach (ElementLog log in obj.Messages)
                {
                    if (log.Level == ElementLog.LevelEnum.Error)
                    {
                        ErrorsFound.Add(log);
                    }
                }

                base.visit(obj, visitSubNodes);
            }