示例#1
0
        private void tmrErrorMonitor_Tick(object sender, System.EventArgs e)
        {
            // If this is a text file, don't scan for errors
            if (g_curFile.isText) {
                this.tmrErrorMonitor.Enabled = false;
                return;
            }

            // Disable the timer if we're not requiring it
            if (g.Config.b_Err_WhileTyping == false) {
                this.tmrErrorMonitor.Enabled = false;
                return;
            }

            if (this._LastMoved) {
                this._LastMoved = false;
                return;
            }

            if (this.txtEditor.Text != this._LastText) {
                MemoryStream mem = new MemoryStream(System.Text.ASCIIEncoding.ASCII.GetBytes(txtEditor.Document.GetText(LineEndStyle.CarriageReturnNewline)));
                mem.Position = 0;

                netMercs.TorqueDev.Lexer.Scanner scanner = new netMercs.TorqueDev.Lexer.Scanner(mem);
                netMercs.TorqueDev.Lexer.Parser parser = new netMercs.TorqueDev.Lexer.Parser(scanner);

                parser.Parse();

                netMercs.TorqueDev.Lexer.ErrorCollection errcoll = (netMercs.TorqueDev.Lexer.ErrorCollection)parser.errors.ErrCollection.Clone();

                parser = null;
                scanner = null;

                mem.Close();

                if (g.Project.ErrorList.Contains(this.g_curFile))
                    g.Project.ErrorList[this.g_curFile] = errcoll;
                else
                    g.Project.ErrorList.Add(this.g_curFile, errcoll);

                this._LastText = this.txtEditor.Text;

                // Render the squiggles
                ErrorRender();

                // Render the treeview
                g.Main.ScanBuildTree();
            } else {
                // Just render the error if the text didn't change
                ErrorRender();
            }
        }
示例#2
0
        public void TokenizerThread()
        {
            // Calls tokenization functions from
            Thread.CurrentThread.Priority = ThreadPriority.BelowNormal;
            XParser parser = new XParser();

            g.LogDebug("CPROJECT::TokenizerThread: INIT thread");
            while (Thread.CurrentThread.ThreadState == ThreadState.Running)
            {
                if (Thread.CurrentThread.ThreadState != ThreadState.Running)
                {
                    g.LogDebug("CPROJECT::TokenizerThread: Aborted; breaking");
                    break;
                }

                //Thread.Sleep(0);
                Thread.Sleep(1000);

                if (this.__tokenizer_queue.Count == 0)
                {
                    if (this.__needs_rehash)
                    {
                        g.LogDebug("CPROJECT::TokenizerThread: __needs_rehash");
                        this.__needs_rehash = false;
                        g.Main.InitExplorer();
                    }
                    continue;
                }

                while (this.__tokenizer_queue.Count != 0)
                {
                    CProject.TokenizerQueue tq = (CProject.TokenizerQueue) this.__tokenizer_queue[0];

                    g.LogDebug("CPROJECT::TokenizerThread: Got " + tq.file.RelativePath + " for tokenization");

                    // Do not deal with files that are "foreign" or "text"
                    if (tq.file.isForeign || tq.file.isText)
                    {
                        g.LogDebug("CPROJECT::TokenizerThread: Foreign/text; return");
                        this.__tokenizer_queue.RemoveAt(0);
                        continue;
                    }
                    Monitor.Enter(this.TokenObjList);
                    Monitor.Enter(tq.file);

                    foreach (CProject.TokenObject tokobj in this.TokenObjList.Values)
                    {
                        tokobj.RemoveFileRefs(tq.file);
                    }

                    if (tq.needFile)
                    {
                        System.IO.Directory.SetCurrentDirectory(this.ProjectPath);
                        tq.file.TokenList  = frmMain.parser.MakeTokenListingFromFile(tq.file.RelativePath);
                        this._TokenObjList = frmMain.parser.MakeObjectListingFromFile(tq.file.RelativePath, tq.file, this._TokenObjList);
                    }
                    else
                    {
                        tq.file.TokenList  = frmMain.parser.MakeTokenListing(tq.code);
                        this._TokenObjList = frmMain.parser.MakeObjectListing(tq.code, tq.file, this._TokenObjList);
                    }

                    Monitor.Exit(this.TokenObjList);
                    Monitor.Exit(tq.file);


                    RebuildVisibleTree();
                    //RefreshEditorDropdowns();


                    this.__tokenizer_queue.RemoveAt(0);
                    this.__needs_rehash = true;

                    //System.GC.Collect(System.GC.MaxGeneration);
                }
            }
        }
示例#3
0
        public void TokenizerThread()
        {
            // Calls tokenization functions from
            Thread.CurrentThread.Priority = ThreadPriority.BelowNormal;
            XParser parser = new XParser();

            g.LogDebug("CPROJECT::TokenizerThread: INIT thread");
            while(Thread.CurrentThread.ThreadState == ThreadState.Running) {
                if (Thread.CurrentThread.ThreadState != ThreadState.Running) {
                    g.LogDebug("CPROJECT::TokenizerThread: Aborted; breaking");
                    break;
                }

                //Thread.Sleep(0);
                Thread.Sleep(1000);

                if (this.__tokenizer_queue.Count == 0) {
                    if (this.__needs_rehash) {
                        g.LogDebug("CPROJECT::TokenizerThread: __needs_rehash");
                        this.__needs_rehash = false;
                        g.Main.InitExplorer();
                    }
                    continue;
                }

                while (this.__tokenizer_queue.Count != 0) {
                    CProject.TokenizerQueue tq = (CProject.TokenizerQueue)this.__tokenizer_queue[0];

                    g.LogDebug("CPROJECT::TokenizerThread: Got " + tq.file.RelativePath + " for tokenization");

                    // Do not deal with files that are "foreign" or "text"
                    if (tq.file.isForeign || tq.file.isText) {
                        g.LogDebug("CPROJECT::TokenizerThread: Foreign/text; return");
                        this.__tokenizer_queue.RemoveAt(0);
                        continue;
                    }
                    Monitor.Enter(this.TokenObjList);
                    Monitor.Enter(tq.file);

                    foreach (CProject.TokenObject tokobj in this.TokenObjList.Values) {
                        tokobj.RemoveFileRefs(tq.file);
                    }

                    if (tq.needFile) {
                        System.IO.Directory.SetCurrentDirectory(this.ProjectPath);
                        tq.file.TokenList = frmMain.parser.MakeTokenListingFromFile(tq.file.RelativePath);
                        this._TokenObjList = frmMain.parser.MakeObjectListingFromFile(tq.file.RelativePath, tq.file, this._TokenObjList);
                    } else {
                        tq.file.TokenList = frmMain.parser.MakeTokenListing(tq.code);
                        this._TokenObjList = frmMain.parser.MakeObjectListing(tq.code, tq.file, this._TokenObjList);
                    }

                    Monitor.Exit(this.TokenObjList);
                    Monitor.Exit(tq.file);

                    RebuildVisibleTree();
                    //RefreshEditorDropdowns();

                    this.__tokenizer_queue.RemoveAt(0);
                    this.__needs_rehash = true;

                    //System.GC.Collect(System.GC.MaxGeneration);
                }
            }
        }