// Parse first open script
        private void FirstParseScript(TabInfo cTab)
        {
            cTab.textEditor.Document.ExtraWordList = new HighlightExtraWord();

            tbOutputParse.Text = string.Empty;

            firstParse = true;

            GetMacros.GetGlobalMacros(Settings.pathHeadersFiles);

            DEBUGINFO("First Parse...");
            new ParserInternal(cTab, this);

            //while (parserIsRunning) System.Threading.Thread.Sleep(10); // Avoid stomping on files while the parser is running

            var ExtParser = new ParserExternal(firstParse);

            cTab.parseInfo = ExtParser.Parse(cTab.textEditor.Text, cTab.filepath, cTab.parseInfo);
            DEBUGINFO("External first parse status: " + ExtParser.LastStatus);

            HighlightProcedures.AddAllToList(cTab.textEditor.Document, cTab.parseInfo.procs);
            CodeFolder.UpdateFolding(cTab.textEditor.Document, cTab.filename, cTab.parseInfo.procs);
            CodeFolder.GetProceduresCollapse(cTab.textEditor.Document, cTab.filename);

            GetParserErrorLog(cTab);

            if (cTab.parseInfo.parseError)
            {
                tabControl2.SelectedIndex = 2;
                if (WindowState != FormWindowState.Minimized)
                {
                    MaximizeLog();
                }
            }
            firstParse = false;
        }
Exemplo n.º 2
0
        internal static void Rename(IParserInfo item, IDocument document, TabInfo cTab, List <TabInfo> tabs)
        {
            string newName;

            switch ((NameType)item.Type())
            {
            case NameType.LVar:     // local procedure variable
                Variable lvar = (Variable)item;
                newName = lvar.name;
                if (!ProcForm.CreateRenameForm(ref newName, "Local Variable") || newName == lvar.name)
                {
                    return;
                }
                if (cTab.parseInfo.CheckExistsName(newName, NameType.LVar, lvar.fdeclared, lvar.d.declared))
                {
                    MessageBox.Show("The local variable this name already exists.", "Unable to rename");
                    return;
                }
                RenameVariable(lvar, newName, RegexOptions.IgnoreCase, document);     // rename only via references
                break;

            case NameType.GVar:     // script variable
                Variable gvar = (Variable)item;
                newName = gvar.name;
                if (!ProcForm.CreateRenameForm(ref newName, "Script Variable") || newName == gvar.name)
                {
                    return;
                }
                if (cTab.parseInfo.CheckExistsName(newName, NameType.GVar))
                {
                    MessageBox.Show("The variable/procedure or declared macro this name already exists.", "Unable to rename");
                    return;
                }
                RenameVariable(gvar, newName, RegexOptions.IgnoreCase, document);     // rename only via references
                break;

            case NameType.Proc:
                RenameProcedure((Procedure)item, document, cTab, tabs);
                return;

            case NameType.Macro:
                Macro macros = (Macro)item;

                bool isGlobal = ProgramInfo.macrosGlobal.ContainsKey(macros.token);
                newName = macros.token;

                if (!ProcForm.CreateRenameForm(ref newName, (isGlobal) ? "Global Macro" : "Local Macro") || newName == macros.token)
                {
                    return;
                }

                if (cTab.parseInfo.CheckExistsName(newName, NameType.Macro))
                {
                    MessageBox.Show("The variable/procedure or declared macro this name already exists.", "Unable to rename");
                    return;
                }
                int diff = newName.Length - macros.token.Length;

                // Для глобальных требуется переименовать все макросы во всех открытых вкладках и во всех файлах проекта/мода
                if (isGlobal)
                {
                    RenameGlobalMacros(macros, newName, cTab, tabs, diff);
                    // обновить макросы
                    GetMacros.GetGlobalMacros(Settings.pathHeadersFiles);
                    return;
                }
                RenameMacros(macros.token, newName, RegexOptions.None, document);
                if (diff != 0)
                {
                    DefineMacroAdjustSpaces(macros, document, diff);
                }
                break;
            }
        }