public override bool Equals(object obj)
        {
            if (!(obj is NamespaceDescription))
            {
                return(false);
            }
            NamespaceDescription other = (NamespaceDescription)obj;

            if (decl.GetName().Text != other.decl.GetName().Text)
            {
                return(false);
            }

            if (Methods.Count != other.Methods.Count ||
                Fields.Count != other.Fields.Count ||
                Structs.Count != other.Structs.Count ||
                Enrichments.Count != other.Enrichments.Count ||
                Usings.Count != other.Usings.Count ||
                Typedefs.Count != other.Typedefs.Count ||
                Namespaces.Count != other.Namespaces.Count)
            {
                return(false);
            }

            return(!(Methods.Where((t, i) => !t.Equals(other.Methods[i])).Any() ||
                     Fields.Where((t, i) => !t.Equals(other.Fields[i])).Any() ||
                     Structs.Where((t, i) => !t.Equals(other.Structs[i])).Any() ||
                     Enrichments.Where((t, i) => !t.Equals(other.Enrichments[i])).Any() ||
                     Usings.Where((t, i) => t != other.Usings[i]).Any() ||
                     Typedefs.Where((t, i) => !t.Equals(other.Typedefs[i])).Any() ||
                     Namespaces.Where((t, i) => !t.Equals(other.Namespaces[i])).Any()));
        }
        public bool Parse(Start ast, GalaxyCompiler compiler)
        {
            this.compiler = compiler;
            Parser parser = new Parser(ast);
            //Includes = parser.Includes;
            //To save time, only update if there has been changes
            //I assume that the Elements are in the same order


            //Check if recouluring is needed
            List <StructDescription> preUpdateStructs = GetAllStructs();

            List <StructDescription> postUpdateStructs = new List <StructDescription>();

            postUpdateStructs.AddRange(parser.Structs);
            List <IDeclContainer> list = new List <IDeclContainer>();

            list.AddRange(parser.Namespaces);
            while (list.Count > 0)
            {
                List <IDeclContainer> nextList = new List <IDeclContainer>();
                foreach (IDeclContainer declContainer in list)
                {
                    postUpdateStructs.AddRange(declContainer.Structs);
                    nextList.AddRange(declContainer.Namespaces);
                }
                list = nextList;
            }

            bool restyle = preUpdateStructs.Count != postUpdateStructs.Count;

            if (!restyle)
            {
                for (int i = 0; i < preUpdateStructs.Count; i++)
                {
                    if (preUpdateStructs[i].Name != postUpdateStructs[i].Name)
                    {
                        restyle = true;
                        break;
                    }
                }
            }


            if (restyle && Form1.Form.CurrentOpenFile != null && Form1.Form.CurrentOpenFile.OpenFile != null)
            {
                Form1.Form.CurrentOpenFile.OpenFile.Editor.Restyle();
            }


            bool needUpdate = Methods.Count != parser.Methods.Count ||
                              Fields.Count != parser.Fields.Count ||
                              Structs.Count != parser.Structs.Count ||
                              Enrichments.Count != parser.Enrichments.Count ||
                              Usings.Count != parser.Usings.Count ||
                              Typedefs.Count != parser.Typedefs.Count ||
                              Namespaces.Count != parser.Namespaces.Count;



            if (!needUpdate)
            {
                needUpdate = Methods.Where((t, i) => !t.Equals(parser.Methods[i])).Any() ||
                             Fields.Where((t, i) => !t.Equals(parser.Fields[i])).Any() ||
                             Structs.Where((t, i) => !t.Equals(parser.Structs[i])).Any() ||
                             Enrichments.Where((t, i) => !t.Equals(parser.Enrichments[i])).Any() ||
                             Usings.Where((t, i) => t != parser.Usings[i]).Any() ||
                             Typedefs.Where((t, i) => !t.Equals(parser.Typedefs[i])).Any() ||
                             Namespaces.Where((t, i) => !t.Equals(parser.Namespaces[i])).Any();
            }

            if (needUpdate)
            {
                Methods = parser.Methods;
                foreach (MethodDescription method in Methods)
                {
                    method.ParentFile = this;
                }
                Fields = parser.Fields;
                foreach (VariableDescription field in Fields)
                {
                    field.ParentFile = this;
                }
                Structs = parser.Structs;
                foreach (StructDescription structDescription in Structs)
                {
                    foreach (MethodDescription method in structDescription.Methods)
                    {
                        method.ParentFile = this;
                    }
                    foreach (VariableDescription field in structDescription.Fields)
                    {
                        field.ParentFile = this;
                    }
                    structDescription.ParentFile = this;
                }
                Enrichments = parser.Enrichments;
                foreach (EnrichmentDescription structDescription in Enrichments)
                {
                    structDescription.ParentFile = this;
                    foreach (MethodDescription method in structDescription.Methods)
                    {
                        method.ParentFile = this;
                    }
                    foreach (VariableDescription field in structDescription.Fields)
                    {
                        field.ParentFile = this;
                    }
                }
                Typedefs = parser.Typedefs;
                foreach (TypedefDescription typedef in Typedefs)
                {
                    typedef.ParentFile = this;
                }
                Usings     = parser.Usings;
                Namespaces = parser.Namespaces;
                foreach (NamespaceDescription namespaceDescription in Namespaces)
                {
                    namespaceDescription.Parent = this;
                }
                if (SourceFileChanged != null)
                {
                    SourceFileChanged(this);
                }
            }
            return(needUpdate);
        }