Esempio n. 1
0
        bool _AnalyseSolution(bool useClang, AnalyseType type = AnalyseType.ANALYSE_SOLUTION)
        {
            if (!GetCommandActive())
            {
                return(false);
            }
            try
            {
                Logger.Info("Analysis Begin.");
                SetCommandActive(false);
                var traverser = new ProjectFileCollector();
                if (type == AnalyseType.ANALYSE_SELECTED_PROJECTS)
                {
                    traverser.SetToSelectedProjects();
                }
                if (type == AnalyseType.ANALYSE_OPENED_FILES)
                {
                    traverser.SetIncludeScope(ProjectFileCollector.IncludeScope.INCLUDE_OPEN_FOLDERS);
                }
                else
                {
                    traverser.SetIncludeScope(ProjectFileCollector.IncludeScope.INCLUDE_PROJECT_FOLDERS);
                }
                var scene = UIManager.Instance().GetScene();
                traverser.SetCustomExtension(scene.GetCustomExtensionDict());
                traverser.SetCustomMacro(scene.GetCustomMacroSet());
                traverser.Traverse();
                var dirList        = traverser.GetDirectoryList();
                var solutionFolder = traverser.GetSolutionFolder();

                if ((type == AnalyseType.ANALYSE_DUMMY && dirList.Count == 0) || solutionFolder == "")
                {
                    SetCommandActive(true);
                    return(false);
                }
                string doxyFolder = solutionFolder;
                if (analysisWindow.customDirectoryEdit.Text != null && analysisWindow.customDirectoryEdit.Text != "")
                {
                    doxyFolder = analysisWindow.customDirectoryEdit.Text;
                }
                doxyFolder += "/CodeGraphData";
                CheckOrCreateFolder(doxyFolder);
                Logger.Info("Folder: " + doxyFolder);

                // Use selected projects as postfix
                string postFix = "";
                if (type == AnalyseType.ANALYSE_SELECTED_PROJECTS)
                {
                    var projectNameList = traverser.GetSelectedProjectName();
                    foreach (string item in projectNameList)
                    {
                        postFix += "_" + item;
                    }
                }
                else if (type == AnalyseType.ANALYSE_DUMMY)
                {
                    postFix = "_dummy";
                }
                else if (type == AnalyseType.ANALYSE_OPENED_FILES)
                {
                    postFix = "_files";
                }
                else
                {
                    postFix = "_solution";
                }
                postFix = postFix.Replace(" ", "");

                DoxygenDB.DoxygenDBConfig config = new DoxygenDB.DoxygenDBConfig();
                config.m_configPath = doxyFolder + "/Result" + postFix + ".graph";
                if (type != AnalyseType.ANALYSE_DUMMY)
                {
                    config.m_inputFolders = dirList;
                    config.m_includePaths = traverser.GetAllIncludePath();
                }
                config.m_outputDirectory = doxyFolder + "/Result" + postFix;
                config.m_projectName     = traverser.GetSolutionName() + postFix;
                config.m_defines         = traverser.GetAllDefines();
                config.m_useClang        = useClang;
                config.m_mainLanguage    = traverser.GetMainLanguage();
                config.m_customExt       = scene.GetCustomExtensionDict();
                DBManager.Instance().CloseDB();

                System.Threading.Thread analysisThread = new System.Threading.Thread((ThreadStart) delegate
                {
                    try
                    {
                        if (DoxygenDB.DoxygenDB.GenerateDB(config))
                        {
                            DBManager.Instance().OpenDB(config.m_configPath);
                        }
                        else
                        {
                            SetCommandActive(true);
                        }
                    }
                    catch (Exception)
                    {
                        SetCommandActive(true);
                    }
                });
                analysisThread.Name = "Analysis Thread";
                analysisThread.Start();
            }
            catch (Exception)
            {
                Logger.Warning("Analyse failed. Please try again.");
                DBManager.Instance().CloseDB();
                SetCommandActive(true);
            }
            return(true);
        }
Esempio n. 2
0
        bool _AnalyseSolution(bool useClang, bool onlySelectedProjects = false)
        {
            if (!GetCommandActive())
            {
                return(false);
            }
            try
            {
                SetCommandActive(false);
                var traverser = new ProjectFileCollector();
                if (onlySelectedProjects)
                {
                    traverser.SetToSelectedProjects();
                }
                var scene = UIManager.Instance().GetScene();
                traverser.SetCustomExtension(scene.GetCustomExtensionDict());
                traverser.Traverse();
                var dirList        = traverser.GetDirectoryList();
                var solutionFolder = traverser.GetSolutionFolder();

                if (dirList.Count == 0 || solutionFolder == "")
                {
                    SetCommandActive(true);
                    return(false);
                }
                string doxyFolder = solutionFolder + "/CodeGraphData";
                CheckOrCreateFolder(doxyFolder);

                // Use selected projects as postfix
                string postFix = "";
                if (onlySelectedProjects)
                {
                    var projectNameList = traverser.GetSelectedProjectName();
                    foreach (string item in projectNameList)
                    {
                        postFix += "_" + item;
                    }
                }
                else
                {
                    postFix = "_solution";
                }
                postFix = postFix.Replace(" ", "");

                DoxygenDB.DoxygenDBConfig config = new DoxygenDB.DoxygenDBConfig();
                config.m_configPath      = doxyFolder + "/Result" + postFix + ".graph";
                config.m_inputFolders    = dirList;
                config.m_outputDirectory = doxyFolder + "/Result" + postFix;
                config.m_projectName     = traverser.GetSolutionName() + postFix;
                config.m_includePaths    = traverser.GetAllIncludePath();
                config.m_defines         = traverser.GetAllDefines();
                config.m_useClang        = useClang;
                config.m_mainLanguage    = traverser.GetMainLanguage();
                config.m_customExt       = scene.GetCustomExtensionDict();
                DBManager.Instance().CloseDB();

                System.Threading.Thread analysisThread = new System.Threading.Thread((ThreadStart) delegate
                {
                    try
                    {
                        if (DoxygenDB.DoxygenDB.GenerateDB(config))
                        {
                            DBManager.Instance().OpenDB(config.m_configPath);
                        }
                        else
                        {
                            SetCommandActive(true);
                        }
                    }
                    catch (Exception)
                    {
                        SetCommandActive(true);
                    }
                });
                analysisThread.Name = "Analysis Thread";
                analysisThread.Start();
            }
            catch (Exception)
            {
                Logger.Warning("Analyse failed. Please try again.");
                DBManager.Instance().CloseDB();
                SetCommandActive(true);
            }
            return(true);
        }