private void OnNetworkReadCallback(string message)
        {
            Utility.NetworkProtocolUtility.MESSAGE_TYPE messageType = Utility.NetworkProtocolUtility.GetMessageType(message);

            if (messageType == Utility.NetworkProtocolUtility.MESSAGE_TYPE.MOVE_CURSOR)
            {
                Utility.NetworkProtocolUtility.CursorPosition cursorPosition = Utility.NetworkProtocolUtility.ParseSetCursorMessage(message);
                if (cursorPosition.Valid)
                {
                    cursorPosition.ColumnNumber += 1;                     // VS counts columns starting at 1, sourcetrail starts at 0
                    DTE dte = (DTE)GetService(typeof(DTE));
                    if (Utility.FileUtility.OpenSourceFile(dte, cursorPosition.FilePath))
                    {
                        Utility.FileUtility.GoToLine(dte, cursorPosition.LineNumber, cursorPosition.ColumnNumber);

                        Utility.SystemUtility.GetWindowFocus();
                    }
                }
            }
            else if (messageType == Utility.NetworkProtocolUtility.MESSAGE_TYPE.CREATE_CDB)
            {
                if (_validSolutionLoaded)
                {
                    DTE dte = (DTE)GetService(typeof(DTE));

                    CreateCompilationDatabase(dte);
                }
            }
            else if (messageType == Utility.NetworkProtocolUtility.MESSAGE_TYPE.PING)
            {
                SendPing();
            }
        }
Exemplo n.º 2
0
        private void OnNetworkReadCallback(string message)
        {
            Utility.NetworkProtocolUtility.MESSAGE_TYPE messageType = Utility.NetworkProtocolUtility.GetMessageType(message);

            if (messageType == Utility.NetworkProtocolUtility.MESSAGE_TYPE.MOVE_CURSOR)
            {
                Logging.Logging.LogInfo("Received request to set the IDE cursor.");
                Utility.NetworkProtocolUtility.CursorPosition cursorPosition = Utility.NetworkProtocolUtility.ParseSetCursorMessage(message);
                if (cursorPosition.Valid)
                {
                    Logging.Logging.LogInfo("Trying to set cursor position to line " + cursorPosition.LineNumber + ", column " + cursorPosition.ColumnNumber + " in file \"" + cursorPosition.FilePath + "\"");

                    cursorPosition.ColumnNumber += 1;                     // VS counts columns starting at 1, sourcetrail starts at 0
                    DTE dte = (DTE)GetService(typeof(DTE));
                    if (Utility.FileUtility.OpenSourceFile(dte, cursorPosition.FilePath))
                    {
                        Utility.FileUtility.GoToLine(dte, cursorPosition.LineNumber, cursorPosition.ColumnNumber);

                        Utility.SystemUtility.GetWindowFocus();
                    }
                }
            }
            else if (messageType == Utility.NetworkProtocolUtility.MESSAGE_TYPE.CREATE_CDB)
            {
                Logging.Logging.LogInfo("Received request to create a compilation database.");
                if (_validSolutionLoaded)
                {
                    DTE dte = (DTE)GetService(typeof(DTE));

                    CreateCompilationDatabase(dte);
                }
            }
            else if (messageType == Utility.NetworkProtocolUtility.MESSAGE_TYPE.PING)
            {
                SendPing();
            }
        }
        private void OnNetworkReadCallback(string message)
        {
            Utility.NetworkProtocolUtility.MESSAGE_TYPE messageType = Utility.NetworkProtocolUtility.GetMessageType(message);

            if (messageType == Utility.NetworkProtocolUtility.MESSAGE_TYPE.MOVE_CURSOR)
            {
                Logging.Logging.LogInfo("Received request to set the IDE cursor.");
                Utility.NetworkProtocolUtility.CursorPosition cursorPosition = Utility.NetworkProtocolUtility.ParseSetCursorMessage(message);
                if (cursorPosition.Valid)
                {
                    Logging.Logging.LogInfo("Trying to set cursor position to line " + cursorPosition.LineNumber + ", column " + cursorPosition.ColumnNumber + " in file \"" + cursorPosition.FilePath + "\"");

                    cursorPosition.ColumnNumber += 1;                     // VS counts columns starting at 1, sourcetrail starts at 0

                    ThreadHelper.JoinableTaskFactory.Run(
                        async delegate
                    {
                        // Switch to main thread
                        await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

                        DTE dte = (DTE)GetService(typeof(DTE));
                        if (Utility.FileUtility.OpenSourceFile(dte, cursorPosition.FilePath))
                        {
                            Utility.FileUtility.GoToLine(dte, cursorPosition.LineNumber, cursorPosition.ColumnNumber);

                            Utility.SystemUtility.GetWindowFocus();
                        }
                    }
                        );
                }
            }
            else if (messageType == Utility.NetworkProtocolUtility.MESSAGE_TYPE.CREATE_CDB)
            {
                Logging.Logging.LogInfo("Received request to create a compilation database.");
                if (_validSolutionLoaded)
                {
                    ThreadHelper.JoinableTaskFactory.Run(
                        async delegate
                    {
                        // Switch to main thread
                        await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
                        DTE dte = (DTE)GetService(typeof(DTE));

                        CreateCompilationDatabase(dte);
                    }
                        );
                }
                else
                {
                    Logging.Logging.LogInfo(
                        "No C/C++ project was detected. To use the Sourcetrail Extension, please make " +
                        "sure that the loaded Visual Studio Solution contains at least one C/C++ project " +
                        "and Visual Studio is configured to generate a symbol database " +
                        "(Tools->Options->Text Editor->C/C++->Advanced->Browsing/Navigation->Disable Database = False).");
                }
            }
            else if (messageType == Utility.NetworkProtocolUtility.MESSAGE_TYPE.PING)
            {
                SendPing();
            }
        }