Exemple #1
0
        public void ShowTree()
        {
            //Желательно строить в отдельном потоке а потом разом выводить. Незабуть про синхронизацию.
            //Пока можно посто в лоб.
            try
            {
                PascalABCCompiler.SemanticTree.IProgramNode Root = VisualEnvironmentCompiler.StandartCompiler.SemanticTree;
                treeView.Nodes.Clear();
                // связываем Visitor и treeView.Nodes
                Visitor = new SematicTreeVisitor(treeView.Nodes);
                Visitor.CreateMyDictionaries();
                Visitor.setTreeView(treeView);
                // собственно проходим по дереву от корня
                Root.visit(Visitor);
                //Visitor.visit(Root, treeView.Nodes);
                //Visitor.visit(Root);
                // устанавливаем обратные связи
                Visitor.makeUpRows(treeView);

                // по умолчанию выбранным является Nodes[0]
                treeView.SelectedNode = treeView.Nodes[0];
                //treeView.SelectedNode.BackColor = Color.Chocolate;
                //treeView.Invalidate();
                treeView.Invalidate();
                treeView.Refresh();
                treeView.Update();
            }
            catch (Exception e)
            {
                VisualEnvironmentCompiler.ExecuteAction(VisualEnvironmentCompilerAction.AddTextToCompilerMessages, "SemanticVisualisator Exception: " + e.ToString());
            }
        }
 public void OpenFilesInEnvironment(List <string> fileNames)
 {
     foreach (string name in fileNames)
     {
         VisualEnvironmentCompiler.ExecuteAction(VisualEnvironmentCompilerAction.OpenFile, name);
     }
 }
Exemple #3
0
        /*[DllImport("PT4\\PT4PABC.dll", CharSet = CharSet.Ansi, EntryPoint = "pt4demo")]
         * static extern int pt4demo(string startdir,
         * string ptdir, string dllname,
         * int dlloptions, int usedlltopics, int usedemodat,
         * string demodatname, string demodatdir,
         * StringBuilder topic, ref int number);
         *
         * [DllImport("PT4\\PT4PABC.dll", CharSet = CharSet.Ansi, EntryPoint = "pt4load")]
         * static extern int pt4load(string startdir,
         * string ptdir, string envlist, string dirlist,
         * int startenv, StringBuilder edittext, StringBuilder filename);
         *
         * [DllImport("PT4\\PT4PABC.dll", CharSet = CharSet.Ansi, EntryPoint = "pt4results")]
         * static extern int pt4results(string startdir,
         * string ptdir, int showbrowsedir, int browsesubdirs,
         * ref int fontsize, ref int showinffile, ref int showtxtfile);
         *
         * [DllImport("PT4\\PT4PABC.dll", CharSet = CharSet.Ansi, EntryPoint = "pt4getdatinfo")]
         * static extern int pt4getdatinfo(string startdir,
         * StringBuilder studentname, ref int fontsize,
         * StringBuilder envir, StringBuilder ptdir);
         *
         * [DllImport("PT4\\PT4PABC.dll", CharSet = CharSet.Ansi, EntryPoint = "pt4setdatinfo")]
         * public static extern int pt4setdatinfo(string startdir,
         * int fontsize, string envir);*/


        public int Demo(StringBuilder topic, ref int number)
        {
//MABR 26.12.2015>
            string CurrentSourceFileName = VisualEnvironmentCompiler.ExecuteAction(VisualEnvironmentCompilerAction.GetCurrentSourceFileName, "") as string;

            tools.Demo(Path.GetDirectoryName(CurrentSourceFileName));
//            tools.Demo(PABCWorkDirectory);
//MABR 26.12.2015<
            return(0);
//            return pt4demo(PABCWorkDirectory, PT4Directory, "pt4", 0, 1, 2, "", "", topic, ref number);
        }
Exemple #4
0
        /*private void CheckAndCopyPT4Files(string FileName)
         * {
         *
         *  string fn=PABCWorkDirectory+"\\"+FileName;
         *  string instfn=PT4Directory+"\\"+FileName;
         *  try
         *  {
         *      if (!File.Exists(fn))
         *          if (File.Exists(instfn))
         *              File.Copy(instfn, fn);
         *  }
         *  catch (Exception)
         *  {
         *  }
         *
         * }*/

        public PT4Provider_VisualPascalABCPlugin(IWorkbench Workbench)
        {
            VisualEnvironmentCompiler = Workbench.VisualEnvironmentCompiler;
            VisualEnvironmentCompiler.ChangeVisualEnvironmentState   += new ChangeVisualEnvironmentStateDelegate(VisualEnvironmentCompiler_ChangeVisualEnvironmentState);
            VisualEnvironmentCompiler.Compiler.OnChangeCompilerState += Compiler_OnChangeCompilerState;
            PABCWorkDirectory = VisualEnvironmentCompiler.ExecuteAction(VisualEnvironmentCompilerAction.GetDirectory, "%WORKINGDIRECTORY%") as string;

            /*if (PABCWorkDirectory == null)
             *  PABCWorkDirectory = "";
             * else
             *  if (Directory.Exists(PABCWorkDirectory))
             *  {
             *      CheckAndCopyPT4Files(PT4Provider.Constants.ResultsABCFileName);
             *      //CheckAndCopyPT4Files(PT4Provider.Constants.ResultsDATFileName);
             *  }
             */
            /*string PABCOutputDirectory = VisualEnvironmentCompiler.ExecuteAction(VisualEnvironmentCompilerAction.GetDirectory, "%OUTPUTDIRECTORY%") as string;
             * if (PABCOutputDirectory != null)
             *  if (Directory.Exists(PABCOutputDirectory))
             *  {
             *      PABCWorkDirectory = PABCOutputDirectory;
             *      CheckAndCopyPT4Files(PT4Provider.Constants.ResultsABCFileName);
             *      //CheckAndCopyPT4Files(PT4Provider.Constants.ResultsDATFileName);
             *  }
             */
        }
Exemple #5
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);
        }
Exemple #6
0
 internal void Init()
 {
     if (project.closed && lbFiles.Items.Count < 2)
     {
         project.files.Clear();
         string FileName = (string)VisualEnvironmentCompiler.ExecuteAction(VisualEnvironmentCompilerAction.GetCurrentSourceFileName, null);
         builder.options.OutputCHMFileName = System.IO.Path.ChangeExtension(System.IO.Path.GetFileName(FileName), ".chm");
         builder.options.WorkingDirectory  = System.IO.Path.GetDirectoryName(FileName);
         builder.options.CHMBannerText     = PascalABCCompiler.StringResources.Get(HelpBuilder_VisualPascalABCPlugin.StringsPrefix + "BANNER_TEXT");
         this.Text = PascalABCCompiler.StringResources.Get(HelpBuilder_VisualPascalABCPlugin.StringsPrefix + "FORM_NAME") + " - " + PascalABCCompiler.StringResources.Get(HelpBuilder_VisualPascalABCPlugin.StringsPrefix + "UNTITLED");
         this.propertyGrid1.Update();
         project.files.Add(FileName);
         lbFiles.Items.Clear();
         lbFiles.Items.Add(System.IO.Path.GetFileName(FileName));
         SetStartCompilingButtonsEnabled(true);
     }
 }
Exemple #7
0
 private void toolStripButton1_Click(object sender, EventArgs e)
 {
     PascalABCCompiler.CompilerType ct = VisualEnvironmentCompiler.DefaultCompilerType;
     VisualEnvironmentCompiler.DefaultCompilerType = PascalABCCompiler.CompilerType.Standart;
     VisualEnvironmentCompiler.ExecuteAction(VisualEnvironmentCompilerAction.Build, null);
     VisualEnvironmentCompiler.DefaultCompilerType = ct;
 }
 public override string GetCurrentDocumentFileName()
 {
     return((string)_compiler.ExecuteAction(VisualEnvironmentCompilerAction.GetCurrentSourceFileName, null));
 }
Exemple #9
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());
            }
        }
        /*private void CheckAndCopyPT4Files(string FileName)
        {
            
            string fn=PABCWorkDirectory+"\\"+FileName;
            string instfn=PT4Directory+"\\"+FileName;
            try
            {
                if (!File.Exists(fn))
                    if (File.Exists(instfn))
                        File.Copy(instfn, fn);
            }
            catch (Exception)
            {
            }

        }*/

        public PT4Provider_VisualPascalABCPlugin(IWorkbench Workbench)
        {
            VisualEnvironmentCompiler = Workbench.VisualEnvironmentCompiler;
            VisualEnvironmentCompiler.ChangeVisualEnvironmentState += new ChangeVisualEnvironmentStateDelegate(VisualEnvironmentCompiler_ChangeVisualEnvironmentState);
            VisualEnvironmentCompiler.Compiler.OnChangeCompilerState += Compiler_OnChangeCompilerState;
            PABCWorkDirectory = VisualEnvironmentCompiler.ExecuteAction(VisualEnvironmentCompilerAction.GetDirectory, "%WORKINGDIRECTORY%") as string;
            /*if (PABCWorkDirectory == null)
                PABCWorkDirectory = "";
            else
                if (Directory.Exists(PABCWorkDirectory))
                {
                    CheckAndCopyPT4Files(PT4Provider.Constants.ResultsABCFileName);
                    //CheckAndCopyPT4Files(PT4Provider.Constants.ResultsDATFileName);
                }
             */
            /*string PABCOutputDirectory = VisualEnvironmentCompiler.ExecuteAction(VisualEnvironmentCompilerAction.GetDirectory, "%OUTPUTDIRECTORY%") as string;
            if (PABCOutputDirectory != null)
                if (Directory.Exists(PABCOutputDirectory))
                {
                    PABCWorkDirectory = PABCOutputDirectory;
                    CheckAndCopyPT4Files(PT4Provider.Constants.ResultsABCFileName);
                    //CheckAndCopyPT4Files(PT4Provider.Constants.ResultsDATFileName);
                }
            */
        }