Пример #1
0
        public void OnShowDefinitionInAtlas(object sender, ExecutedRoutedEventArgs e)
        {
            var scene = UIManager.Instance().GetScene();

            CodeElement srcElement, tarElement;
            Document    srcDocument, tarDocument;
            int         srcLine, tarLine;

            CursorNavigator.GetCursorElement(out srcDocument, out srcElement, out srcLine);

            Guid cmdGroup      = VSConstants.GUID_VSStandardCommandSet97;
            var  commandTarget = ((System.IServiceProvider)m_package).GetService(typeof(SUIHostCommandDispatcher)) as IOleCommandTarget;

            if (commandTarget != null)
            {
                int hr = commandTarget.Exec(ref cmdGroup,
                                            (uint)VSConstants.VSStd97CmdID.GotoDefn,
                                            (uint)OLECMDEXECOPT.OLECMDEXECOPT_DODEFAULT,
                                            System.IntPtr.Zero, System.IntPtr.Zero);
            }

            CursorNavigator.GetCursorElement(out tarDocument, out tarElement, out tarLine);
            if (srcElement == null || tarElement == null || srcElement == tarElement)
            {
                return;
            }

            var srcName     = srcElement.Name;
            var srcLongName = srcElement.FullName;
            var srcType     = CursorNavigator.VSElementTypeToString(srcElement);
            var srcFile     = srcDocument.FullName;

            var tarName     = tarElement.Name;
            var tarLongName = tarElement.FullName;
            var tarType     = CursorNavigator.VSElementTypeToString(tarElement);
            var tarFile     = tarDocument.FullName;

            var db         = DBManager.Instance().GetDB();
            var srcRequest = new DoxygenDB.EntitySearchRequest(
                srcName, (int)DoxygenDB.SearchOption.MATCH_CASE | (int)DoxygenDB.SearchOption.MATCH_WORD,
                srcLongName, (int)DoxygenDB.SearchOption.MATCH_CASE | (int)DoxygenDB.SearchOption.DB_CONTAINS_WORD,
                srcType, srcFile, srcLine);
            var srcResult = new DoxygenDB.EntitySearchResult();

            db.SearchAndFilter(srcRequest, out srcResult);

            //var tarRequest = new DoxygenDB.EntitySearchRequest(
            //    tarName, (int)DoxygenDB.SearchOption.MATCH_CASE | (int)DoxygenDB.SearchOption.MATCH_WORD,
            //    tarLongName, (int)DoxygenDB.SearchOption.MATCH_CASE | (int)DoxygenDB.SearchOption.DB_CONTAINS_WORD,
            //    tarType, tarFile, tarLine);
            //var tarResult = new DoxygenDB.EntitySearchResult();
            //db.SearchAndFilter(tarRequest, out tarResult);
            var tarResult = DoShowInAtlas();

            DoxygenDB.Entity srcBestEntity, tarBestEntity;
            srcBestEntity = srcResult.bestEntity;
            tarBestEntity = tarResult.bestEntity;
            if (srcBestEntity != null && tarBestEntity != null && srcBestEntity.m_id != tarBestEntity.m_id)
            {
                scene.AcquireLock();
                scene.AddCodeItem(srcBestEntity.m_id);
                scene.AddCodeItem(tarBestEntity.m_id);
                scene.DoAddCustomEdge(srcBestEntity.m_id, tarBestEntity.m_id);
                scene.SelectCodeItem(tarBestEntity.m_id);
                scene.ReleaseLock();
            }
        }
Пример #2
0
        bool _AnalyseSolution(bool useClang, bool onlySelectedProjects = false, bool analyse = true)
        {
            if (!GetCommandActive())
            {
                return(false);
            }
            try
            {
                Logger.Info("Analysis Begin.");
                SetCommandActive(false);
                var traverser = new ProjectFileCollector();
                if (onlySelectedProjects)
                {
                    traverser.SetToSelectedProjects();
                }
                var scene = UIManager.Instance().GetScene();
                traverser.SetCustomExtension(scene.GetCustomExtensionDict());
                traverser.SetCustomMacro(scene.GetCustomMacroSet());
                traverser.Traverse();
                var dirList        = traverser.GetDirectoryList();
                var solutionFolder = traverser.GetSolutionFolder();

                if (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 (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);
        }
Пример #3
0
 static bool UseCodeModel()
 {
     return(!DBManager.Instance().IsBigSolution() &&
            UIManager.Instance().GetMainUI().IsDynamicNavigation());
 }