Exemple #1
0
 public TextFileNode(Data.TextFile textFile) : base(textFile as Data.File)
 {
     if (TextFileNodeCreated != null)
     {
         TextFileNodeCreated(this);
     }
 }
Exemple #2
0
        public DocumentParser(Data.TextFile textFile, ParseModeEnum parseMode)
        {
            this.EditId   = textFile.CodeDocument.EditID;
            this.document = new CodeDocument(textFile);
            this.document.CopyTextOnlyFrom(textFile.CodeDocument);

/*            lock (this.document)
 *          {
 *              this.document.CopyCharsFrom(textFile.CodeDocument);
 *              this.document.CopyLineIndexFrom(textFile.CodeDocument);
 *          }
 */         this.ParseMode = parseMode;
            this.TextFile  = textFile;
        }
Exemple #3
0
        public void SetTextFile(Data.TextFile textFile)
        {
            if (TextFile == textFile)
            {
                return;
            }
            if (TextFile != null)
            {
                if (closeCantidateTextFiles.Contains(textFile))
                {
                    closeCantidateTextFiles.Remove(textFile);
                }
                closeCantidateTextFiles.Add(textFile);
                if (closeCantidateTextFiles.Count > FilesCasheNumbers)
                {
                    closeCantidateTextFiles[0].Close();
                    closeCantidateTextFiles.RemoveAt(0);
                }
//                TextFile.Close(); // release document
            }

            if (textFile == null || textFile.CodeDocument == null)
            {
                codeTextbox.Document = null;
                codeTextbox.Visible  = false;
                return;
            }
            if (TextFile == null || TextFile.GetType() != textFile.GetType())
            {
                codeTextbox.Style = textFile.DrawStyle;
            }

            codeTextbox.Visible  = true;
            codeTextbox.Document = textFile.CodeDocument;
            TextFile             = textFile;
            ScrollToCaret();

            entryParse();
        }
Exemple #4
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");
            }
        }
Exemple #5
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(); }));
        }
Exemple #6
0
 public CodeDocument(Data.TextFile textFile, string text) : base(text)
 {
     textFileRef = new WeakReference <Data.TextFile>(textFile);
 }
Exemple #7
0
 public CodeDocument(Data.TextFile textFile)
 {
     textFileRef = new WeakReference <Data.TextFile>(textFile);
 }
Exemple #8
0
 public ParsedDocument(Data.TextFile textFile, int editID)
 {
     this.EditID = editID;
     textFileRef = new WeakReference <Data.TextFile>(textFile);
 }