public void Clear()
 {
     //Includes.Clear();
     Methods.Clear();
     Fields.Clear();
     Structs.Clear();
     Typedefs.Clear();
     Enrichments.Clear();
     Usings.Clear();
     Namespaces.Clear();
 }
        public IEnumerator TestListEnrichments()
        {
            Log.Debug("DiscoveryServiceV2IntegrationTests", "Attempting to ListEnrichments...");
            Enrichments listEnrichmentsResponse = null;

            service.ListEnrichments(
                callback: (DetailedResponse <Enrichments> response, IBMError error) =>
            {
                Log.Debug("DiscoveryServiceV2IntegrationTests", "ListEnrichments result: {0}", response.Response);
                listEnrichmentsResponse = response.Result;
                Assert.IsNotNull(listEnrichmentsResponse);
                Assert.IsNull(error);
            },
                projectId: projectId
                );

            while (listEnrichmentsResponse == null)
            {
                yield return(null);
            }
        }
        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);
        }