Esempio n. 1
0
        public void WriteAst()
        {
            int i     = 0;
            var files = this.neo4jwrapp.FindWithoutLabel <File>(typeof(File), File.HasAstLabel).ToList();

            foreach (var file in files)
            {
                this.FireProgressChanged(i++ / (double)files.Count);
                var fileContent = GetRaw(file.Commit, file.Path);
                var parsedGraph = GumTreeWrapper.Parse(fileContent);

                bool complete   = false;
                int  triedCount = 0;
                while (!complete && triedCount < 3)
                {
                    try
                    {
                        var foo = parsedGraph.GetRoot();
                        complete = true;
                    } catch (Exception e)
                    {
                        triedCount++;
                        FireStatusChanged("Could not parse with GumTree ... Try again. " + file.Path + " " + file.Commit);
                    }
                }

                if (!complete)
                {
                    FireStatusChanged("Could not parse with GumTree ... Give up ... next File. " + file.Path + " " + file.Commit);
                    continue;
                }

                AddAstGraphToGraph(parsedGraph, file);

                this.neo4jwrapp.AddLabel(file, File.HasAstLabel);
            }
            this.FireProgressChanged(-1);
        }