示例#1
0
        private void subBgtimer_Tick(object sender, EventArgs e)
        {
            DocumentParser parser = subBackGroundParser.GetResult();

            if (parser == null)   // entry parse
            {
                if (subBackGroundParser.RemainingStocks != 0)
                {
                    return;
                }
                NavigatePanel.NavigatePanelNode node;
                Controller.NavigatePanel.GetSelectedNode(out node);
                if (node == null || node.Item == null)
                {
                    return;
                }
                Data.Project project = node.Item.Project;

                Data.Item item = project.FetchReparseTarget();
                if (item == null)
                {
                    return;
                }

                checkID("before entry parse");

                DocumentParser newParser = item.CreateDocumentParser(DocumentParser.ParseModeEnum.BackgroundParse);
                if (newParser != null)
                {
                    subBackGroundParser.EntryParse(newParser);
                    Controller.AppendLog("entry parse " + item.ID + " " + DateTime.Now.ToString());
                }
                checkID("after entry parse");
            }
            else
            { // receive result
                if (TextFile != null && TextFile == parser.TextFile)
                {
                    if (CodeDocument != null && CodeDocument.EditID != parser.EditId)
                    {
                        Controller.AppendLog("parsed mismatch sub " + parser.TextFile.Name + " " + DateTime.Now.ToString());
//                        TextFile.ParseRequested = false;
                        return;
                    }
                }

                Controller.AppendLog("parsed sub  " + parser.TextFile.Name + " " + DateTime.Now.ToString());
                if (parser.TextFile.Name == "TOP_0")
                {
                    string a = "";
                }
                Data.TextFile textFile = parser.TextFile;

                if (textFile == null)
                {
                    return;
                }
                //if (textFile.ParsedDocument == null)
                //{
                //    textFile.Close();
                //    textFile.ParseRequested = false;
                //    return;
                //}

                checkID("before accept parsed document");

                textFile.AcceptParsedDocument(parser.ParsedDocument);
                if (TextFile != textFile)
                {
                    textFile.Close();
                }
                if (textFile.NavigatePanelNode != null)
                {
                    textFile.NavigatePanelNode.Update();
                }

                Controller.NavigatePanel.UpdateVisibleNode();
                Controller.NavigatePanel.Refresh();
                parser.Dispose();

                checkID("after accept parsed document");
            }
        }
示例#2
0
        private void worker()
        {
            projectNode.Project.Update();
            //int idCount = projectNode.Project.GetRegisteredIdList().Count;
            //while (idCount != projectNode.Project.GetRegisteredIdList().Count)
            //{
            //    List<string> ids = projectNode.Project.GetRegisteredIdList();
            //    idCount = ids.Count;
            //    for (int i = 0; i < ids.Count; i++)
            //    {
            //        Data.Item item = projectNode.Project.GetRegisterdItem(ids[i]);
            //        item.Update();
            //    }
            //}


            {
                // data update
                projectNode.HierarchicalVisibleUpdate();
                List <Data.Item> items = projectNode.Project.FindItems(
                    (x) => (x is Data.TextFile),
                    (x) => (false)
                    );

                Invoke(new Action(() => { progressBar.Maximum = items.Count; }));

                // parse items
                int i = 0;
                foreach (Data.Item item in items)
                {
                    Invoke(new Action(() => { progressBar.Value = i; }));
                    i++;

                    if (!(item is Data.TextFile))
                    {
                        continue;
                    }
                    Data.TextFile textFile = item as Data.TextFile;
                    Invoke(new Action(() => { label.Text = textFile.Name; }));
                    CodeEditor.DocumentParser parser = textFile.CreateDocumentParser(CodeEditor.DocumentParser.ParseModeEnum.LoadParse);
                    if (parser == null)
                    {
                        continue;
                    }
                    parser.Parse();

                    textFile.CodeDocument.CopyFrom(parser.Document);

                    if (textFile.ParsedDocument != null)
                    {
                        CodeEditor.ParsedDocument oldParsedDocument = textFile.ParsedDocument;
                        textFile.ParsedDocument = null;
                        oldParsedDocument.Dispose();
                    }

                    textFile.AcceptParsedDocument(parser.ParsedDocument);

//                    textFile.ParseRequested = true;
                    textFile.Close();
                }
            }

            close = true;
            Invoke(new Action(() => { Close(); }));
        }