Exemple #1
0
 private void run()
 {
     while (!abortFlag)
     {
         DocumentParser parser = null;
         lock (toBackgroundStock)
         {
             if (toBackgroundStock.Count != 0)
             {
                 parser = toBackgroundStock.Last();
                 toBackgroundStock.Clear();
             }
         }
         if (parser != null)
         {
             parsing = true;
             parser.Parse();
             lock (fromBackgroundStock)
             {
                 fromBackgroundStock.Add(parser);
             }
             parsing = false;
         }
         System.Threading.Thread.Sleep(1);
     }
 }
Exemple #2
0
 public void EntryParse(DocumentParser documentParser)
 {
     lock (toBackgroundStock)
     {
         toBackgroundStock.Add(documentParser);
     }
 }
Exemple #3
0
 public DocumentParser GetResult()
 {
     lock (fromBackgroundStock)
     {
         if (fromBackgroundStock.Count == 0)
         {
             return(null);
         }
         DocumentParser parser = fromBackgroundStock.Last();
         fromBackgroundStock.Clear();
         return(parser);
     }
 }
Exemple #4
0
        private void entryParse()
        {
            if (TextFile == null)
            {
                return;
            }
            DocumentParser parser = TextFile.CreateDocumentParser(DocumentParser.ParseModeEnum.EditParse);

            if (parser != null)
            {
                Controller.AppendLog("parserID " + CodeDocument.EditID.ToString());
                backGroundParser.EntryParse(parser);
                Controller.AppendLog("entry parse " + DateTime.Now.ToString());
            }
        }
Exemple #5
0
        private void timer_Tick(object sender, EventArgs e)
        {
            DocumentParser parser = backGroundParser.GetResult();

            if (parser == null)
            {
                return;
            }
            if (TextFile == null)
            {
                return;
            }
            if (TextFile != parser.TextFile)
            {
                return;
            }
            Controller.AppendLog("ID " + CodeDocument.EditID.ToString() + " parserID " + parser.EditId.ToString());

            if (CodeDocument.EditID != parser.EditId)
            {
                Controller.AppendLog("parsed mismatch " + DateTime.Now.ToString());
                return;
            }

            Controller.AppendLog("parsed " + DateTime.Now.ToString());

            CodeDocument.CopyFrom(parser.Document);
            //CodeDocument.CopyColorMarkFrom(parser.Document);
            codeTextbox.Invoke(new Action(codeTextbox.Refresh));

            checkID("before accept parse normal");
            if (parser.ParsedDocument != null)
            {
                TextFile.AcceptParsedDocument(parser.ParsedDocument);
            }

            Controller.MessageView.Update(TextFile.ParsedDocument);
            codeTextbox.ReDrawHighlight();

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

            checkID("after accept parse normal");
        }
Exemple #6
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");
            }
        }