Exemplo n.º 1
0
        private Block MakeBlock(BlockPair pair, Set set, IProjectFile project_file)
        {
            int startLineNumber = pair.Top.EndLineNumber + 1;
            int endLineNumber   = pair.Bottom.StartLineNumber - 1;

            DocumentRange range = SimianResultsParser.GetDocumentRange(project_file, startLineNumber, endLineNumber, Solution);

            return(new Block(startLineNumber, endLineNumber, project_file, set, range));
        }
        public void Execute(IDataContext context, DelegateExecute nextExecute)
        {
            if (!File.Exists(SimianOptions.Instance.PathToSimian))
            {
                MessageBox.Show("You need to configure the path to the Simian executable.  Configuration is located at Resharper->Options->Agent Ralph->Simian Explorer.");
                // TODO: Launch the R# config here.
                return;
            }

            // Get solution from context in which action is executed
            ISolution solution = context.GetData(IDE.DataConstants.SOLUTION);
            if (solution == null)
                return;

            List<FileSystemPath> files_to_analyze = CollectAllFilesToAnalyze(solution);

            if(files_to_analyze.Count == 0)
            {
                SimianResultsDescriptor d2 = new SimianResultsDescriptor(solution, new List<ISet>(), "Simian Explorer");

                // Show the results in the gui.
                TreeModelBrowser.GetInstance(solution).Show("SearchResultsWindow", d2,
                                                            new TreeModelBrowserPanel(d2));
                return;
            }

            string simian_xml_file = SimianUtil.RunSimianToXml(files_to_analyze, SimianOptions.Instance);
            try
            {
                SimianResultsParser parser = new SimianResultsParser(solution);
                IEnumerable<Set> sim_sets = parser.GetSimianResults2(simian_xml_file);

                // Get the initial explorer.
                SimianResultsDescriptor d2 = new SimianResultsDescriptor(solution, ToIListOfISet(sim_sets), "Simian Explorer");

                // Show the results in the gui.
                TreeModelBrowser.GetInstance(solution).Show("SearchResultsWindow", d2,
                                                            new TreeModelBrowserPanel(d2));

                // And the examiner produces the content of the 'Refactoring Candidates' explorer.
                Examiner examiner = new Examiner(solution);
                IList<ISet> l = examiner.Examine(sim_sets);

                if(l.Count == 0)
                    return;

                d2 = new SimianResultsDescriptor(solution, l, "The Inbetweens");

                // Show the results in the gui.
                TreeModelBrowser.GetInstance(solution).Show("SearchResultsWindow", d2,
                                                            new TreeModelBrowserPanel(d2));

                if (parser.FilesInError.Count > 0)
                {
                    using (SimianErrorFilesForm f = new SimianErrorFilesForm())
                    {
                        f.FilesInError = parser.FilesInError;
                        f.ShowDialog();
                    }
                }
            }
            finally
            {
                if (File.Exists(simian_xml_file))
                    File.Delete(simian_xml_file);
            }
        }
        public void Execute(IDataContext context, DelegateExecute nextExecute)
        {
            if (!File.Exists(SimianOptions.Instance.PathToSimian))
            {
                MessageBox.Show("You need to configure the path to the Simian executable.  Configuration is located at Resharper->Options->Agent Ralph->Simian Explorer.");
                // TODO: Launch the R# config here.
                return;
            }

            // Get solution from context in which action is executed
            ISolution solution = context.GetData(IDE.DataConstants.SOLUTION);

            if (solution == null)
            {
                return;
            }

            List <FileSystemPath> files_to_analyze = CollectAllFilesToAnalyze(solution);

            if (files_to_analyze.Count == 0)
            {
                SimianResultsDescriptor d2 = new SimianResultsDescriptor(solution, new List <ISet>(), "Simian Explorer");

                // Show the results in the gui.
                TreeModelBrowser.GetInstance(solution).Show("SearchResultsWindow", d2,
                                                            new TreeModelBrowserPanel(d2));
                return;
            }

            string simian_xml_file = SimianUtil.RunSimianToXml(files_to_analyze, SimianOptions.Instance);

            try
            {
                SimianResultsParser parser   = new SimianResultsParser(solution);
                IEnumerable <Set>   sim_sets = parser.GetSimianResults2(simian_xml_file);

                // Get the initial explorer.
                SimianResultsDescriptor d2 = new SimianResultsDescriptor(solution, ToIListOfISet(sim_sets), "Simian Explorer");

                // Show the results in the gui.
                TreeModelBrowser.GetInstance(solution).Show("SearchResultsWindow", d2,
                                                            new TreeModelBrowserPanel(d2));

                // And the examiner produces the content of the 'Refactoring Candidates' explorer.
                Examiner     examiner = new Examiner(solution);
                IList <ISet> l        = examiner.Examine(sim_sets);

                if (l.Count == 0)
                {
                    return;
                }

                d2 = new SimianResultsDescriptor(solution, l, "The Inbetweens");

                // Show the results in the gui.
                TreeModelBrowser.GetInstance(solution).Show("SearchResultsWindow", d2,
                                                            new TreeModelBrowserPanel(d2));


                if (parser.FilesInError.Count > 0)
                {
                    using (SimianErrorFilesForm f = new SimianErrorFilesForm())
                    {
                        f.FilesInError = parser.FilesInError;
                        f.ShowDialog();
                    }
                }
            }
            finally
            {
                if (File.Exists(simian_xml_file))
                {
                    File.Delete(simian_xml_file);
                }
            }
        }