Exemplo n.º 1
0
        public bool Parse(string FileName)
        {
            Name = Path.GetFileNameWithoutExtension(FileName);
            bool tmp_code_gen = VisualEnvironmentCompiler.StandartCompiler.InternalDebug.CodeGeneration;
            bool tmp_save_pcu = VisualEnvironmentCompiler.StandartCompiler.InternalDebug.PCUGenerate;

            VisualEnvironmentCompiler.StandartCompiler.InternalDebug.CodeGeneration       = false;
            VisualEnvironmentCompiler.StandartCompiler.InternalDebug.PCUGenerate          = false;
            VisualEnvironmentCompiler.StandartCompiler.InternalDebug.AlwaysGenerateXMLDoc = true;
            PascalABCCompiler.CompilerType ct = VisualEnvironmentCompiler.DefaultCompilerType;
            VisualEnvironmentCompiler.DefaultCompilerType = PascalABCCompiler.CompilerType.Standart;
            VisualEnvironmentCompiler.StandartCompiler.InternalDebug.DocumentedUnits.Add(FileName.ToLower());
            try
            {
                VisualEnvironmentCompiler.ExecuteAction(VisualEnvironmentCompilerAction.BuildUnit, FileName);
            }
            catch (System.Exception e)
            {
                throw;
            }
            VisualEnvironmentCompiler.DefaultCompilerType = ct;
            VisualEnvironmentCompiler.StandartCompiler.InternalDebug.CodeGeneration       = tmp_code_gen;
            VisualEnvironmentCompiler.StandartCompiler.InternalDebug.PCUGenerate          = tmp_save_pcu;
            VisualEnvironmentCompiler.StandartCompiler.InternalDebug.AlwaysGenerateXMLDoc = false;
            if (tree != null)
            {
                return(true);
            }
            return(false);
        }
Exemplo n.º 2
0
 private void toolStripButton2_Click(object sender, EventArgs e)
 {
     PascalABCCompiler.CompilerType ct = VisualEnvironmentCompiler.DefaultCompilerType;
     VisualEnvironmentCompiler.DefaultCompilerType = PascalABCCompiler.CompilerType.Standart;
     VisualEnvironmentCompiler.ExecuteAction(VisualEnvironmentCompilerAction.Rebuild, null);
     VisualEnvironmentCompiler.DefaultCompilerType = ct;
 }
Exemplo n.º 3
0
 private void toolStripButton2_Click(object sender, EventArgs e)
 {
     VisualEnvironmentCompiler.StandartCompiler.InternalDebug.CodeGeneration = false;
     PascalABCCompiler.CompilerType ct = VisualEnvironmentCompiler.DefaultCompilerType;
     VisualEnvironmentCompiler.DefaultCompilerType = PascalABCCompiler.CompilerType.Standart;
     VisualEnvironmentCompiler.ExecuteAction(VisualEnvironmentCompilerAction.Rebuild, null);
     VisualEnvironmentCompiler.DefaultCompilerType = ct;
     VisualEnvironmentCompiler.StandartCompiler.InternalDebug.CodeGeneration = true;
 }
 public void ExecuteBuild()
 {
     MyCompilation = true;
     VisualEnvironmentCompiler.StandartCompiler.InternalDebug.CodeGeneration = false;
     PascalABCCompiler.CompilerType ct = VisualEnvironmentCompiler.DefaultCompilerType;
     VisualEnvironmentCompiler.DefaultCompilerType = PascalABCCompiler.CompilerType.Standart;
     VisualEnvironmentCompiler.ExecuteAction(VisualEnvironmentCompilerAction.Build, null);
     VisualEnvironmentCompiler.DefaultCompilerType = ct;
     VisualEnvironmentCompiler.StandartCompiler.InternalDebug.CodeGeneration = true;
 }
Exemplo n.º 5
0
        // Сбор аспектов без компиляции
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            TemplateButtonEnabled = false;
            BuildButtonsEnabled   = false;
            ShowTree();

            // Добавление параметров
            for (int i = 0; i < treeView.Nodes.Count; i++)
            {
                if (treeView.Nodes[i].Text != "&all")
                {
                    treeView.Nodes[i].Text = treeView.Nodes[i].Text + "  " + AspectPreprocessor.AspectsMap[treeView.Nodes[i].Text].Author + "  " + AspectPreprocessor.AspectsMap[treeView.Nodes[i].Text].Version;
                }
            }
            treeView.Refresh();
            treeView.Update();

            SaveButtonsEnabled   = true;
            InsertButtonsEnabled = true;

            // Обработка ошибок
            bool finished = true;

            if (AspectErrors.Count > 0)
            {
                finished = false;
                VisualPascalABC.WorkbenchServiceFactory.Workbench.ErrorsListWindow.ClearErrorList();
                //AspectErrors.Clear();
                //AspectErrors.Add(new PascalABCCompiler.Preprocessor_2.Errors.AspBeginEndError(TabWithAspects.Name, null, str));

                PascalABCCompiler.CompilerType ct = VisualEnvironmentCompiler.DefaultCompilerType;
                VisualEnvironmentCompiler.DefaultCompilerType = PascalABCCompiler.CompilerType.Standart;
                VisualEnvironmentCompiler.ExecuteAction(VisualEnvironmentCompilerAction.AddMessageToErrorListWindow, AspectErrors);
                VisualEnvironmentCompiler.DefaultCompilerType = ct;
            }
            // конец обработки
            if ((treeView.Nodes.Count <= 1) || (!finished))
            {
                BuildButtonsEnabled   = true;
                TemplateButtonEnabled = true;
                SaveButtonsEnabled    = false;
                SaveOneButtonEnabled  = false;
                InsertButtonsEnabled  = false;
                treeView.Nodes.Clear();
                treeView.Invalidate();
                treeView.Refresh();
                treeView.Update();
                AspectPreprocessorReset();
            }
        }
Exemplo n.º 6
0
        private void CreateCompiler()
        {
            standartCompiler = new PascalABCCompiler.Compiler(SourceFilesProvider, OnChangeCompilerState);
            CodeCompletion.CodeCompletionController.comp = new PascalABCCompiler.Compiler((PascalABCCompiler.Compiler)standartCompiler, SourceFilesProvider, OnChangeCompilerState);
            CodeCompletion.CodeCompletionController.ParsersController   = standartCompiler.ParsersController;
            CodeCompletion.CodeCompletionController.StandartDirectories = StandartDirectories;

            this.CodeCompletionParserController.Init();
            if (defaultCompilerType == PascalABCCompiler.CompilerType.Remote && !Tools.IsUnix())
            {
                LoadRemoteCompiler();
            }
            else
            {
                defaultCompilerType = PascalABCCompiler.CompilerType.Standart;
            }
        }
        private void CreateCompiler()
        {
            standartCompiler = new PascalABCCompiler.Compiler(SourceFilesProvider, OnChangeCompilerState);
            CodeCompletion.CodeCompletionController.comp = new PascalABCCompiler.Compiler((PascalABCCompiler.Compiler)standartCompiler, SourceFilesProvider, OnChangeCompilerState);
            if (ProjectFactory.Instance.CurrentProject != null)
            {
                CodeCompletion.CodeCompletionController.comp.CompilerOptions.CurrentProject = ProjectFactory.Instance.CurrentProject;
                ProjectFactory.Instance.Dirty = true;
            }
            CodeCompletion.CodeCompletionController.ParsersController   = standartCompiler.ParsersController;
            CodeCompletion.CodeCompletionController.StandartDirectories = StandartDirectories;

            this.CodeCompletionParserController.Init();
            if (defaultCompilerType == PascalABCCompiler.CompilerType.Remote && !Tools.IsUnix())
            {
                LoadRemoteCompiler();
            }
            else
            {
                defaultCompilerType = PascalABCCompiler.CompilerType.Standart;
            }
        }
Exemplo n.º 8
0
        // Сбор аспектов с последующей компиляцией
        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            BuildButtonsEnabled = false;

            PascalABCCompiler.CompilerType ct = VisualEnvironmentCompiler.DefaultCompilerType;
            VisualEnvironmentCompiler.DefaultCompilerType = PascalABCCompiler.CompilerType.Standart;
            VisualEnvironmentCompiler.ExecuteAction(VisualEnvironmentCompilerAction.Build, null);
            VisualEnvironmentCompiler.DefaultCompilerType = ct;

            TemplateButtonEnabled = false;
            ShowTree();
            //Добавление параметров
            for (int i = 0; i < treeView.Nodes.Count; i++)
            {
                if (treeView.Nodes[i].Text != "&all")
                {
                    treeView.Nodes[i].Text = treeView.Nodes[i].Text + "  " + AspectPreprocessor.AspectsMap[treeView.Nodes[i].Text].Author + "  " + AspectPreprocessor.AspectsMap[treeView.Nodes[i].Text].Version;
                }
            }
            treeView.Refresh();
            treeView.Update();

            SaveButtonsEnabled   = true;
            InsertButtonsEnabled = true;
            if (treeView.Nodes.Count <= 1)
            {
                BuildButtonsEnabled   = true;
                TemplateButtonEnabled = true;
                SaveButtonsEnabled    = false;
                SaveOneButtonEnabled  = false;
                InsertButtonsEnabled  = false;
                treeView.Nodes.Clear();
                treeView.Invalidate();
                treeView.Refresh();
                treeView.Update();
                AspectPreprocessorReset();
            }
        }
        private void CreateCompiler()
        {
            standartCompiler = new PascalABCCompiler.Compiler(SourceFilesProvider, OnChangeCompilerState);
            CodeCompletion.CodeCompletionController.comp = new PascalABCCompiler.Compiler((PascalABCCompiler.Compiler)standartCompiler, SourceFilesProvider, OnChangeCompilerState);
            CodeCompletion.CodeCompletionController.ParsersController = standartCompiler.ParsersController;
            CodeCompletion.CodeCompletionController.StandartDirectories = StandartDirectories;

            this.CodeCompletionParserController.Init();
            if (defaultCompilerType == PascalABCCompiler.CompilerType.Remote && !Tools.IsUnix())
                LoadRemoteCompiler();
            else
                defaultCompilerType = PascalABCCompiler.CompilerType.Standart;
        }
Exemplo n.º 10
0
        // Сохранение текущего аспекта
        private void toolStripButton2_Click_1(object sender, EventArgs e)
        {
            if (VisualPascalABC.VisualPABCSingleton.MainForm.CurrentCodeFileDocument == TabWithAspects)
            {
                VisualPascalABC.VisualPABCSingleton.MainForm.CurrentCodeFileDocument.SelectAll();
                string txt = VisualPascalABC.VisualPABCSingleton.MainForm.CurrentCodeFileDocument.SelectedText;

                string[] file_names = new string[1];
                //file_names[0] = "C:\\PABCWork.NET\\program8.pas";
                file_names[0] = RootFileName;

                string check;
                // Проверка сохраняемых аспектов
                check = txt;
                List <PascalABCCompiler.SyntaxTree.SourceContext> beg;
                bool can_save = true;
                //lovim posledniy vibrannii aspect i dlia nego delaem vse eto - Asptxtname
                {
                    beg = AspectPreprocessor.AspectsMap[AspectTxtName].GetBeginList();
                    int  asp_num = 0;
                    int  asp_pos;
                    bool error_found = false;

                    for (int i = 0; i < beg.Count; i++)
                    {
                        error_found = false;
                        asp_pos     = (check.IndexOf("{$asp " + AspectTxtName + "}", asp_num));
                        if ((asp_pos >= 0) && (check.IndexOf("{$endasp " + AspectTxtName + "}", asp_num) > (asp_pos + ("{$asp " + AspectTxtName + "}").Length)))
                        {
                            if ((check.IndexOf("{$asp ", asp_pos + ("{$asp " + AspectTxtName + "}").Length, check.IndexOf("{$endasp " + AspectTxtName + "}", asp_num) - (asp_pos + ("{$asp " + AspectTxtName + "}").Length)) < 0) && (check.IndexOf("{$endasp ", asp_pos + ("{$asp " + AspectTxtName + "}").Length, check.IndexOf("{$endasp " + AspectTxtName + "}", asp_num) - (asp_pos + ("{$asp " + AspectTxtName + "}").Length)) < 0))
                            {
                                asp_num = check.IndexOf("{$endasp " + AspectTxtName + "}", asp_num) + ("{$endasp " + AspectTxtName + "}").Length;
                            }
                            else
                            {
                                error_found = true;
                                break;
                            }
                        }
                        else
                        {
                            error_found = true;
                            break;
                        }
                    }
                    if (error_found)
                    {
                        can_save = false;
                        VisualPascalABC.WorkbenchServiceFactory.Workbench.ErrorsListWindow.ClearErrorList();
                        AspectErrors.Clear();
                        AspectErrors.Add(new PascalABCCompiler.Preprocessor_2.Errors.AspBeginEndError(TabWithAspects.Name, null, AspectTxtName));

                        PascalABCCompiler.CompilerType ct = VisualEnvironmentCompiler.DefaultCompilerType;
                        VisualEnvironmentCompiler.DefaultCompilerType = PascalABCCompiler.CompilerType.Standart;
                        VisualEnvironmentCompiler.ExecuteAction(VisualEnvironmentCompilerAction.AddMessageToErrorListWindow, AspectErrors);
                        VisualEnvironmentCompiler.DefaultCompilerType = ct;
                        //exit saving
                    }
                }
                // Конец проверки
                if (can_save)
                {
                    StreamWriter sw = File.CreateText(Path.GetDirectoryName(file_names[0]) + "\\" + Path.GetFileNameWithoutExtension(file_names[0]) + "_asp.pas");
                    sw.Write(txt);
                    sw.Close();

                    if (VisualPascalABC.ProjectFactory.Instance.ProjectLoaded)
                    {
                        AspectPreprocessor.WriteAspect(txt, Path.GetDirectoryName(RootProjectInfo.Path), AspectTxtName);
                    }
                    else
                    {
                        AspectPreprocessor.WriteAspect(txt, "", AspectTxtName);
                    }

                    // Обновление вкладок

                    StreamWriter sw1;
                    VisualPascalABC.CodeFileDocumentControl tp;
                    if (!VisualPascalABC.ProjectFactory.Instance.ProjectLoaded)
                    {
                        tp = VisualPascalABC.VisualPABCSingleton.MainForm.FindTab(file_names[0]);
                        if (tp != null)
                        {
                            VisualPascalABC.VisualPABCSingleton.MainForm.CurrentCodeFileDocument = tp;
                            VisualPascalABC.VisualPABCSingleton.MainForm.CurrentCodeFileDocument.LoadFromFile(file_names[0]);
                            VisualPascalABC.VisualPABCSingleton.MainForm.SaveAspPlugin(tp);
                        }
                    }
                    else
                    {
                        foreach (PascalABCCompiler.IFileInfo fi in RootProjectInfo.SourceFiles)
                        {
                            tp = VisualPascalABC.VisualPABCSingleton.MainForm.FindTab(Path.GetDirectoryName(RootProjectInfo.Path) + "\\" + fi.Name);
                            if (tp != null)
                            {
                                VisualPascalABC.VisualPABCSingleton.MainForm.CurrentCodeFileDocument = tp;
                                VisualPascalABC.VisualPABCSingleton.MainForm.CurrentCodeFileDocument.LoadFromFile(Path.GetDirectoryName(RootProjectInfo.Path) + "\\" + fi.Name);
                                VisualPascalABC.VisualPABCSingleton.MainForm.SaveAspPlugin(tp);
                            }
                        }
                        // Открываем главный файл после обновления
                        tp = VisualPascalABC.VisualPABCSingleton.MainForm.FindTab(Path.GetDirectoryName(RootProjectInfo.Path) + "\\" + file_names[0]);
                        if (tp != null)
                        {
                            VisualPascalABC.VisualPABCSingleton.MainForm.CurrentCodeFileDocument = tp;
                            //VisualPascalABC.VisualPABCSingleton.MainForm.CurrentCodeFileDocument.LoadFromFile(file_names[0]);
                        }
                    }

                    // Закрываем вкладку с аспектами
                    if (TabWithAspects != null)
                    {
                        VisualPascalABC.VisualPABCSingleton.MainForm.CloseAspPlugin(TabWithAspects);
                    }

                    // Деактивируем пункт сохранения
                    SaveButtonsEnabled    = false;
                    SaveOneButtonEnabled  = false;
                    TemplateButtonEnabled = true;
                    BuildButtonsEnabled   = true;

                    treeView.Nodes.Clear();
                    treeView.Refresh();
                }
            }
            else
            {
                AspectPreprocessorReset();
                SaveButtonsEnabled    = false;
                SaveOneButtonEnabled  = false;
                TemplateButtonEnabled = true;
                BuildButtonsEnabled   = true;
                treeView.Nodes.Clear();
                treeView.Refresh();
            }
        }
Exemplo n.º 11
0
        // Построение и отображение дерева аспектов
        public void ShowTree()
        {
            try
            {
                string[] file_names = new string[100];
                file_names[0] = VisualPascalABC.VisualPABCSingleton.MainForm.CurrentCodeFileDocument.FileName;

                treeView.Nodes.Clear();
                treeView.Invalidate();
                treeView.Refresh();
                treeView.Update();

                AspectPreprocessorReset();

                if (!VisualPascalABC.ProjectFactory.Instance.ProjectLoaded)
                {
                    RootFileName = file_names[0];

                    //for (int i = 0; i < UsedUnits.Count; i++)
                    //  file_names[i] = UsedUnits[i];
                }
                else
                {
                    //work with project
                    RootProjectInfo = VisualPascalABC.ProjectFactory.Instance.CurrentProject;
                    RootFileName    = RootProjectInfo.MainFile;
                    int i = 0;
                    foreach (PascalABCCompiler.IFileInfo fi in RootProjectInfo.SourceFiles)
                    {
                        file_names[i] = fi.Name;
                        i++;
                    }
                }

                List <string> temp = new List <string>();
                treeView.Nodes.Add("&all");
                foreach (string name in file_names)
                {
                    string[] files = new string[1];
                    files[0] = name;

                    AspectTxt = AspectPreprocessor.Build(files, AspectErrors, AspectScm);

                    // Вывод ошибок
                    if (AspectErrors.Count > 0)
                    {
                        PascalABCCompiler.CompilerType ct = VisualEnvironmentCompiler.DefaultCompilerType;
                        VisualEnvironmentCompiler.DefaultCompilerType = PascalABCCompiler.CompilerType.Standart;
                        VisualEnvironmentCompiler.ExecuteAction(VisualEnvironmentCompilerAction.Build, null);
                        VisualEnvironmentCompiler.DefaultCompilerType = ct;
                    }
                    else
                    {
                        for (int i = 0; i < AspectPreprocessor.CompilerDirectives.Count; i++)
                        {
                            if (AspectPreprocessor.CompilerDirectives[i].Name.text == "asp")
                            {
                                if (!(temp.Contains(AspectPreprocessor.CompilerDirectives[i].Directive.text)))
                                {
                                    treeView.Nodes.Add(AspectPreprocessor.CompilerDirectives[i].Directive.text);
                                    temp.Add(AspectPreprocessor.CompilerDirectives[i].Directive.text);
                                }
                            }

                            //aspdata
                            string s = AspectPreprocessor.GetAspects(AspectPreprocessor.CompilerDirectives, AspectScm);
                            if (AspectPreprocessor.CompilerDirectives[i].Name.text == "aspdata")
                            {
                                string t = AspectPreprocessor.CompilerDirectives[i].Directive.text;
                                if (t.IndexOf(' ') > 0)
                                {
                                    string n     = t.Substring(0, t.IndexOf(' ')).Trim();
                                    string param = t.Substring(t.IndexOf(' ')).Trim();
                                    if (AspectPreprocessor.AspectsMap.ContainsKey(n))
                                    {
                                        int c = param.IndexOf(' ');
                                        if (c > 0)
                                        {
                                            AspectPreprocessor.AspectsMap[n].Author = param.Substring(0, c).Trim();
                                            if (param.IndexOf(' ', c + 1) > 0)
                                            {
                                                AspectPreprocessor.AspectsMap[n].Version = param.Substring(c, param.IndexOf(' ', c + 1) - c).Trim();
                                            }
                                            else
                                            {
                                                AspectPreprocessor.AspectsMap[n].Version = param.Substring(c).Trim();
                                            }
                                        }
                                    }
                                }
                            }
                            //end aspdata
                        }

                        //sozdat etot file esli netu
                        //VisualPascalABC.VisualPABCSingleton.MainForm.OpenFile(Path.GetDirectoryName(file_names[0]) + "\\" + Path.GetFileNameWithoutExtension(file_names[0]) + "_asp.pas", null);
                        VisualPascalABC.VisualPABCSingleton.MainForm.OpenTabWithText(Path.GetFileNameWithoutExtension(file_names[0]) + "_asp", "");
                        TabWithAspects = VisualPascalABC.VisualPABCSingleton.MainForm.CurrentCodeFileDocument;

                        VisualPascalABC.VisualPABCSingleton.MainForm.VisualEnvironmentCompiler.ExecuteAction(VisualPascalABCPlugins.VisualEnvironmentCompilerAction.SetCurrentSourceFileText, AspectPreprocessor.GetAspects(AspectPreprocessor.CompilerDirectives, AspectScm));
                        AspectTxtName = "&all";
                    }
                }

                /*
                 * for (int i = 0; i < AspectPreprocessor.CompilerDirectives.Count; i++)
                 * {
                 *  //aspdata
                 *  string s = AspectPreprocessor.GetAspects(AspectPreprocessor.CompilerDirectives, AspectScm);
                 *  if (AspectPreprocessor.CompilerDirectives[i].Name.text == "aspdata")
                 *  {
                 *      string t = AspectPreprocessor.CompilerDirectives[i].Directive.text;
                 *      string n = t.Substring(0, t.IndexOf(' ')).Trim();
                 *      string param = t.Substring(t.IndexOf(' ')).Trim();
                 *      if (AspectPreprocessor.AspectsMap.ContainsKey(n))
                 *      {
                 *          AspectPreprocessor.AspectsMap[n].Author = param.Substring(0, param.IndexOf(' ')).Trim();
                 *          AspectPreprocessor.AspectsMap[n].Author = param.Substring(param.IndexOf(' ')).Trim();
                 *          AspectPreprocessor.AspectsMap[n].IsSavedParams = true;
                 *      }
                 *  }
                 *  //end aspdata
                 * }
                 */
            }
            catch (Exception e)
            {
                //VisualEnvironmentCompiler.ExecuteAction(VisualEnvironmentCompilerAction.AddTextToCompilerMessages, "AspectTree Exception: " + e.ToString());
            }
        }