public int Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
        {
            if (VsShellUtilities.IsInAutomationFunction(_serviceProvider))
            {
                return(_nextTarget.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut));
            }

            if (pguidCmdGroup == GUID_VSStandardCommandSet97)
            {
                switch ((VSStd97CmdID)nCmdID)
                {
                case VSStd97CmdID.GotoRef:  GotoRef();  return(S_OK);

                case VSStd97CmdID.GotoDefn: GotoDefn(); return(S_OK);
                }
            }
            else if (pguidCmdGroup == VSStd2K)
            {
                var cmd = (VSStd2KCmdID)nCmdID;

                switch (cmd)
                {
                case VSStd2KCmdID.GOTOBRACE:
                    OnGoToBrace();
                    return(S_OK);
                }
            }

            var result = _nextTarget.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut);

            return(result);
        }
        /// <summary>
        /// It is the responsibility of caller to call this method on UI Thread.
        /// The method will throw if not called on UI Thread.
        /// </summary>
        public int ShowMessageBox(string message, string title, OLEMSGICON icon, OLEMSGBUTTON msgButton, OLEMSGDEFBUTTON defaultButton)
        {
            _threadingService.VerifyOnUIThread();

            if (_serviceProvider == null)
            {
                throw new ArgumentException("serviceProvider");
            }

            if (!(_serviceProvider.GetService(typeof(IVsUIShell)) is IVsUIShell uiShell))
            {
                throw new InvalidOperationException();
            }

            Guid emptyGuid = Guid.Empty;
            int  result    = 0;

            if (!VsShellUtilities.IsInAutomationFunction(_serviceProvider))
            {
                ErrorHandler.ThrowOnFailure(uiShell.ShowMessageBox(0,
                                                                   ref emptyGuid,
                                                                   title,
                                                                   message,
                                                                   null,
                                                                   0,
                                                                   msgButton,
                                                                   defaultButton,
                                                                   icon,
                                                                   0,
                                                                   out result));
            }
            return(result);
        }
        public int Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            // If we're in an automation function, move to the next command.
            if (VsShellUtilities.IsInAutomationFunction(_serviceProvider))
            {
                return(_nextCommandHandler.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut));
            }

            if (TryGetChar(ref pguidCmdGroup, nCmdID, pvaIn, out var c))
            {
                if (HandleSessionCompletion(c))
                {
                    return(VSConstants.S_OK);
                }

                var result = _nextCommandHandler.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut);

                if (HandleSessionStart(c))
                {
                    return(VSConstants.S_OK);
                }

                if (HandleSessionUpdate(c))
                {
                    return(VSConstants.S_OK);
                }

                return(result);
            }

            return(_nextCommandHandler.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut));
        }
        public bool ValidateInstalledPowerShellVersion()
        {
            if (InstalledPowerShellVersion < RequiredPowerShellVersion)
            {
                try
                {
                    if (!VsShellUtilities.IsInAutomationFunction(ServiceProvider.GlobalProvider) &&
                        MessageBox.Show(Resources.MissingPowerShellVersion,
                                        Resources.MissingDependency,
                                        MessageBoxButton.YesNo,
                                        MessageBoxImage.Warning) == MessageBoxResult.Yes)
                    {
                        System.Diagnostics.Process.Start(PowerShellTools.Common.Constants.PowerShellInstallFWLink);
                    }
                }
                catch (InvalidOperationException)
                {
                }

                _previousResult = false;
            }
            else
            {
                _previousResult = true;
            }

            return(_previousResult.Value);
        }
示例#5
0
        public int Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt,
                        IntPtr pvaIn, IntPtr pvaOut)
        {
            ThreadHelper.ThrowIfNotOnUIThread();



            if (VsShellUtilities.IsInAutomationFunction(ServiceProvider))
            {
                return(nextCommandTarget.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut));
            }

            char?typedChar = GetTypedChar(pguidCmdGroup, nCmdID, pvaIn);

            if (HandleCommit(nCmdID, typedChar))
            {
                return(VSConstants.S_OK);
            }

            int result = nextCommandTarget.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt,
                                                pvaIn, pvaOut);

            return(ErrorHandler.Succeeded(result) ?
                   HandleCompletion(nCmdID, typedChar, result) : result);
        }
示例#6
0
        public int Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            var cmd = new Cmd(pguidCmdGroup, nCmdID);

            if (VsShellUtilities.IsInAutomationFunction(Services.VsServiceProvider))
            {
                return(nextCommandHandler.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut));
            }
            char ch = char.MinValue;

            //make sure the input is a char before getting it
            if (cmd == TypeCharCmd)
            {
                ch = (char)(ushort)Marshal.GetObjectForNativeVariant(pvaIn);
            }

            if ((ch == '"' || ch == '\'') && textView.Caret.Position.BufferPosition.GetChar() == ch)
            {
                textView.Caret.MoveToNextCaretPosition();
                return(VSConstants.S_OK);
            }

            return(nextCommandHandler.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut));
        }
示例#7
0
        public int Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
        {
            // 确定是否正在执行一个自动化的可扩展性对象操作。
            if (VsShellUtilities.IsInAutomationFunction(m_provider.ServiceProvider))
            {
                return(m_nextCommandHandler.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut));
            }

            if (pguidCmdGroup == VSConstants.VSStd2K && nCmdID == (uint)VSConstants.VSStd2KCmdID.TYPECHAR)
            {
                char typedChar = (char)(ushort)Marshal.GetObjectForNativeVariant(pvaIn);
                if (typedChar == '<')
                {
                    CommandHelper.Default.TryAddNamespace();
                }
                else if (typedChar == '(')
                {
                    if (CommandHelper.Default.TryAddParameters())
                    {
                        return(VSConstants.S_FALSE);
                    }
                }
            }
            int retVal = m_nextCommandHandler.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut);

            return(retVal);
        }
示例#8
0
        public int Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            if (VsShellUtilities.IsInAutomationFunction(_serviceProvider))
            {
                return(Next.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut));
            }

            if ((VSConstants.VSStd2KCmdID)nCmdID != VSConstants.VSStd2KCmdID.FORMATDOCUMENT)
            {
                return(Next.Exec(pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut));
            }

            var gaugeFile = new FileInfo(GaugePackage.DTE.ActiveDocument.FullName);

            var p = GaugeProcess.ForFormat(gaugeFile.DirectoryName, gaugeFile.Name);

            p.Start();
            p.WaitForExit();
            if (p.ExitCode != 0)
            {
                OutputPaneLogger.Error($"gauge format {gaugeFile.Name}\nSTDOUT:\n{p.StandardOutput.ReadToEnd()}\nSTDERR:\n{p.StandardError.ReadToEnd()}\n");
            }
            return(VSConstants.S_OK);
        }
示例#9
0
        /// <summary>
        /// Executes the specified command or displays help for the command.
        /// </summary>
        /// <param name="pguidCmdGroup">The globally unique identifier of the command group; can be <see langword="null" /> to specify the standard group.</param>
        /// <param name="nCmdID">The identity of the command to execute.</param>
        /// <param name="nCmdexecopt">Specifies how the object should execute the command.</param>
        /// <param name="pvaIn">A pointer to a structure containing input arguments (or <see langword="null"/>).</param>
        /// <param name="pvaOut">A pointer to a structure to receive command output (or <see langword="null"/>).</param>
        /// <returns>This method returns <see cref="VSConstants.S_OK"/> on success; otherwise, something else.</returns>
        public int Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt,
                        IntPtr pvaIn, IntPtr pvaOut)
        {
            // If we are in an automation function (e.g. test automation), just pass along
            // the command to the next command target in the chain
            if (VsShellUtilities.IsInAutomationFunction(ServiceProvider))
            {
                return(nextCommandTarget.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut));
            }

            // Get the character that was typed (if any)
            char?typedChar = GetTypedChar(pguidCmdGroup, nCmdID, pvaIn);

            // If the user committed a selection, finish the session and return
            if (HandleCommit(nCmdID, typedChar))
            {
                return(VSConstants.S_OK);
            }

            // Pass along the command to the next command target in the chain, so that
            // any typed character is added to the buffer
            int result = nextCommandTarget.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt,
                                                pvaIn, pvaOut);

            // On success, handle IntelliSense completion for the typed character / command
            return(ErrorHandler.Succeeded(result) ?
                   HandleCompletion(nCmdID, typedChar, result) : result);
        }
示例#10
0
        public int QueryStatus(ref Guid pguidCmdGroup, uint cCmds, OLECMD[] prgCmds, IntPtr pCmdText)
        {
            if (!VsShellUtilities.IsInAutomationFunction(this.Provider.ServiceProvider))
            {
                if (pguidCmdGroup == VSConstants.VSStd2K && cCmds > 0)
                {
                    // make the Insert Snippet, CommentBlock, and UncommentBlock command appear on the context menu
                    if ((uint)prgCmds[0].cmdID == (uint)VSConstants.VSStd2KCmdID.INSERTSNIPPET ||
                        (uint)prgCmds[0].cmdID == (uint)VSConstants.VSStd2KCmdID.COMMENTBLOCK ||
                        (uint)prgCmds[0].cmdID == (uint)VSConstants.VSStd2KCmdID.COMMENT_BLOCK ||
                        (uint)prgCmds[0].cmdID == (uint)VSConstants.VSStd2KCmdID.UNCOMMENTBLOCK ||
                        (uint)prgCmds[0].cmdID == (uint)VSConstants.VSStd2KCmdID.UNCOMMENT_BLOCK ||
                        (uint)prgCmds[0].cmdID == (uint)VSConstants.VSStd2KCmdID.OUTLN_TOGGLE_ALL ||
                        (uint)prgCmds[0].cmdID == (uint)VSConstants.VSStd2KCmdID.OUTLN_TOGGLE_CURRENT
                        // "HIDING" means start/stop outlining for these two
                        || (!this.outliningIsStopped && (uint)prgCmds[0].cmdID == (uint)VSConstants.VSStd2KCmdID.OUTLN_STOP_HIDING_ALL) ||
                        (this.outliningIsStopped && (uint)prgCmds[0].cmdID == (uint)VSConstants.VSStd2KCmdID.OUTLN_START_AUTOHIDING)
                        )
                    {
                        prgCmds[0].cmdf = (int)Constants.MSOCMDF_ENABLED | (int)Constants.MSOCMDF_SUPPORTED;
                        return(VSConstants.S_OK);
                    }

                    if ((uint)prgCmds[0].cmdID == (uint)VSConstants.VSStd2KCmdID.OUTLN_STOP_HIDING_CURRENT)
                    {
                        return((int)Constants.MSOCMDERR_E_DISABLED);
                    }
                }
            }
            return(this.NextCommandHandler.QueryStatus(ref pguidCmdGroup, cCmds, prgCmds, pCmdText));
        }
 public void NotifyFailure(string failureMessage)
 {
     _threadingService.VerifyOnUIThread();
     if (!VsShellUtilities.IsInAutomationFunction(_serviceProvider))
     {
         var result = VsShellUtilities.ShowMessageBox(_serviceProvider, failureMessage, null, OLEMSGICON.OLEMSGICON_WARNING,
                                                      OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
     }
 }
        private VSConstants.MessageBoxResult ShowMessageBox(string message, OLEMSGICON icon, OLEMSGBUTTON button, VSConstants.MessageBoxResult defaultResult = VSConstants.MessageBoxResult.IDOK)
        {
            if (VsShellUtilities.IsInAutomationFunction(_asyncPackage))
            {
                return(defaultResult);
            }

            return((VSConstants.MessageBoxResult)VsShellUtilities.ShowMessageBox(_asyncPackage, message, null, icon, button, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST));
        }
        private MessageBoxResult ShowMessageBox(string message, OLEMSGICON icon, OLEMSGBUTTON button, MessageBoxResult defaultResult = MessageBoxResult.IDOK)
        {
            _threadingService.VerifyOnUIThread();

            if (VsShellUtilities.IsInAutomationFunction(_serviceProvider))
            {
                return(defaultResult);
            }

            return((MessageBoxResult)VsShellUtilities.ShowMessageBox(_serviceProvider, message, null, icon, button, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST));
        }
        public int Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            if (VsShellUtilities.IsInAutomationFunction(_serviceProvider))
            {
                return(Next.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut));
            }

            var hresult = VSConstants.S_OK;

            switch ((VSConstants.VSStd97CmdID)nCmdID)
            {
            case VSConstants.VSStd97CmdID.FindReferences:
                var caretBufferPosition = TextView.Caret.Position.BufferPosition;
                var originalText        = Step.GetStepText(caretBufferPosition.GetContainingLine());

                var findRegex =
                    new GaugeServiceClient().GetFindRegex(caretBufferPosition.Snapshot.GetProject(GaugePackage.DTE),
                                                          originalText);

                var _dte = ServiceProvider.GlobalProvider.GetService(typeof(DTE)) as DTE2;
                var find = (Find2)_dte.Find;

                var types     = find.FilesOfType;
                var matchCase = find.MatchCase;
                var matchWord = find.MatchWholeWord;

                find.WaitForFindToComplete = false;
                find.Action            = vsFindAction.vsFindActionFindAll;
                find.Backwards         = false;
                find.MatchInHiddenText = true;
                find.MatchWholeWord    = true;
                find.MatchCase         = false;
                find.PatternSyntax     = vsFindPatternSyntax.vsFindPatternSyntaxRegExpr;
                find.ResultsLocation   = vsFindResultsLocation.vsFindResults1;
                find.SearchSubfolders  = true;
                find.Target            = vsFindTarget.vsFindTargetSolution;
                find.FindWhat          = findRegex;
                find.Execute();

                find.FilesOfType    = types;
                find.MatchCase      = matchCase;
                find.MatchWholeWord = matchWord;

                return(hresult);

            default:
                hresult = Next.Exec(pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut);
                break;
            }
            return(hresult);
        }
示例#15
0
        public int Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
        {
            if (VsShellUtilities.IsInAutomationFunction(Service))
            {
                return(_nextCommandTarget.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut));
            }

            if (pguidCmdGroup == VSConstants.VSStd2K)
            {
                switch ((VSConstants.VSStd2KCmdID)nCmdID)
                {
                case VSConstants.VSStd2KCmdID.TAB:
                    if (_state._justCompletedFunc)
                    {
                        var caret_pos = TextView.Caret.Position.BufferPosition;
                        int caret     = caret_pos.Position;

                        //IntPtr pointer = Marshal.AllocHGlobal(1024);
                        //Marshal.GetNativeVariantForObject('(', pointer);

                        /*object customin = '(';
                         * object customout = null;
                         * DTE.Commands.Raise(VSConstants.VSStd2K.ToString("B").ToUpper(), (int)VSConstants.VSStd2KCmdID.TYPECHAR, ref customin, ref customout);*/

                        TextView.TextBuffer.Insert(caret, "()");
                        TextView.Caret.MoveToPreviousCaretPosition();
                        _state._justCompletedFunc      = false;
                        _state._justCompletedAutoBrace = true;

                        caret_pos = TextView.Caret.Position.BufferPosition;
                        _state._justCompletedAutoBraceTrack = TextView.TextBuffer.CurrentSnapshot.CreateTrackingSpan(
                            Span.FromBounds(caret + 1, caret_pos.GetContainingLine().End.Position), SpanTrackingMode.EdgeInclusive
                            );

                        TabAutoCallPackage.MenuService.GlobalInvoke(new CommandID(VSConstants.VSStd2K, (int)VSConstants.VSStd2KCmdID.PARAMINFO));
                        return(VSConstants.S_OK);
                    }
                    else if (_state._justCompletedAutoBrace)
                    {
                        _state._justCompletedAutoBrace      = false;
                        _state._justCompletedAutoBraceTrack = null;
                        Operations.MoveToEndOfLine(false);
                        Operations.InsertText(";");
                        return(VSConstants.S_OK);
                    }
                    break;
                }
            }

            return(_nextCommandTarget.Exec(pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut));
        }
示例#16
0
        private bool IsCommandExecutedSuccessful(Guid pguidCmdGroup, uint nCmdID)
        {
            if (VsShellUtilities.IsInAutomationFunction(_provider.ServiceProvider))
            {
                return(false);
            }

            if (pguidCmdGroup == VSConstants.GUID_VSStandardCommandSet97 && nCmdID == (uint)VSConstants.VSStd97CmdID.GotoDefn)
            {
                return(TryGoToDefinition());
            }

            return(false);
        }
 public bool Confirm(string message)
 {
     _threadingService.VerifyOnUIThread();
     if (!VsShellUtilities.IsInAutomationFunction(_serviceProvider))
     {
         var result = VsShellUtilities.ShowMessageBox(_serviceProvider, message, null, OLEMSGICON.OLEMSGICON_QUERY,
                                                      OLEMSGBUTTON.OLEMSGBUTTON_YESNO, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
         if (result == (int)VSConstants.MessageBoxResult.IDNO)
         {
             return(false);
         }
     }
     return(true);
 }
        public int Exec(ref Guid cmdGroup, uint cmdId, uint cmdExecOpt, IntPtr pin, IntPtr pout)
        {
            try {
                if (VsShellUtilities.IsInAutomationFunction(ServiceProvider))
                {
                    return(_nextCommandHandler.Exec(ref cmdGroup, cmdId, cmdExecOpt, pin, pout));
                }

                var typedChar = char.MinValue;
                var retVal    = VSConstants.S_OK;

                if (cmdGroup == VSConstants.VSStd2K && cmdId == (uint)VSConstants.VSStd2KCmdID.TYPECHAR)
                {
                    typedChar = (char)(ushort)Marshal.GetObjectForNativeVariant(pin);
                }

                var shouldReturn = _completionController.TryCommitSession(typedChar, cmdId);
                if (shouldReturn)
                {
                    return(retVal);
                }

                if (cmdId == (uint)VSConstants.VSStd2KCmdID.RETURN)
                {
                    if (_customFormatter.TryFormatOnEnter())
                    {
                        return(VSConstants.S_OK);
                    }
                }

                var isControlSpace = Keyboard.Modifiers == ModifierKeys.Control && typedChar == ' ';

                if (!isControlSpace)
                {
                    retVal = _nextCommandHandler.Exec(ref cmdGroup, cmdId, cmdExecOpt, pin, pout);
                }

                if (_completionController.TryComplete(typedChar, cmdId, _completionBroker))
                {
                    return(VSConstants.S_OK);
                }

                return(retVal);
            } catch (Exception e) {
                Debug.WriteLine("Exec failed");
                Debug.WriteLine(e.ToString());

                return(VSConstants.S_FALSE);
            }
        }
示例#19
0
        public int Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
        {
            if (VsShellUtilities.IsInAutomationFunction(m_provider.ServiceProvider))
            {
                return(m_nextCommandHandler.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut));
            }

            if (nCmdID == (uint)VSConstants.VSStd2KCmdID.TAB)
            {
                TriggerCompletion();
                var targetCompletionSets = m_session.CompletionSets.Where(i => i.GetType() == typeof(CompletionSet));
                foreach (var targetCompletionSet in targetCompletionSets)
                {
                    targetCompletionSet.SelectBestMatch();
                    if (targetCompletionSet.SelectionStatus.IsSelected && targetCompletionSet.SelectionStatus.IsUnique)
                    {
                        var insertedText = targetCompletionSet.Completions.First().InsertionText;
                        if (insertedText.StartsWith("<"))
                        {
                            m_session.SelectedCompletionSet = targetCompletionSet;
                            m_session.Commit();

                            var targetIndex = insertedText.LastIndexOf("</");
                            while (targetIndex > -1)
                            {
                                var index = insertedText.LastIndexOf("</", targetIndex);
                                if (index == -1)
                                {
                                    break;
                                }

                                targetIndex = index;
                            }

                            // move the caret in between the tags
                            for (var i = 0; i < (insertedText.Length - targetIndex); i++)
                            {
                                m_textView.Caret.MoveToPreviousCaretPosition();
                            }
                            return(VSConstants.S_OK);
                        }
                    }
                }

                m_session.Dismiss();
            }

            return(m_nextCommandHandler.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut));
        }
        private bool NotUsedExec(Guid pguidCmdGroup, uint cmdId)
        {
            if (VsShellUtilities.IsInAutomationFunction(this.serviceProvider))
            {
                return(true);
            }

            if (this.InMultiEditMode)
            {
                return(false);
            }

            return(!(AnyTimeCommands.TryGetValue(pguidCmdGroup, out var commands) &&
                     commands.Contains(cmdId)));
        }
示例#21
0
        public int Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
        {
            if (VsShellUtilities.IsInAutomationFunction(Service))
            {
                return(_nextCommandTarget.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut));
            }

            if (pguidCmdGroup == VSConstants.GUID_VSStandardCommandSet97)
            {
                if (nCmdID == (uint)VSConstants.VSStd97CmdID.SaveSolution)
                {
                }
            }

            return(_nextCommandTarget.Exec(pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut));
        }
示例#22
0
        public int Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
        {
            if (SupportsAutomation || (VisualRustPackage.Instance != null && !VsShellUtilities.IsInAutomationFunction(VisualRustPackage.Instance)))
            {
                if (pguidCmdGroup == CommandGroupId && CommandIdSet.Contains(nCmdID))
                {
                    bool result = Execute(ConvertFromCommandId(nCmdID), nCmdexecopt, pvaIn, pvaOut);

                    if (result)
                    {
                        return(VSConstants.S_OK);
                    }
                }
            }

            return(_NextCommandTarget.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut));
        }
        public int QueryStatus(ref Guid pguidCmdGroup, uint cCmds, OLECMD[] prgCmds, IntPtr pCmdText)
        {
            if (!VsShellUtilities.IsInAutomationFunction(_provider._serviceProvider))
            {
                if (pguidCmdGroup == VSConstants.VSStd2K && cCmds > 0)
                {
                    // make the Insert Snippet command appear on the context menu
                    if ((uint)prgCmds[0].cmdID == (uint)VSConstants.VSStd2KCmdID.INSERTSNIPPET)
                    {
                        prgCmds[0].cmdf = (int)Constants.MSOCMDF_ENABLED | (int)Constants.MSOCMDF_SUPPORTED;
                        return(VSConstants.S_OK);
                    }
                }
            }

            return(_nextCommandHandler.QueryStatus(ref pguidCmdGroup, cCmds, prgCmds, pCmdText));
        }
示例#24
0
        public int Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
        {
            if (VsShellUtilities.IsInAutomationFunction(_mProvider.ServiceProvider))
            {
                return(_mNextCommandHandler.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut));
            }

            if (pguidCmdGroup != VSConstants.VSStd2K)
            {
                return(_mNextCommandHandler.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut));
            }

            switch ((VSConstants.VSStd2KCmdID)nCmdID)
            {
            case VSConstants.VSStd2KCmdID.RETURN:
                if (InSession && ErrorHandler.Succeeded(EndCurrentExpansion(false)))
                {
                    return(VSConstants.S_OK);
                }
                break;

            case VSConstants.VSStd2KCmdID.TAB:
                if (InSession && ErrorHandler.Succeeded(NextField()))
                {
                    return(VSConstants.S_OK);
                }
                break;

            case VSConstants.VSStd2KCmdID.BACKTAB:
                if (InSession && ErrorHandler.Succeeded(PreviousField()))
                {
                    return(VSConstants.S_OK);
                }
                break;

            case VSConstants.VSStd2KCmdID.SURROUNDWITH:
            case VSConstants.VSStd2KCmdID.INSERTSNIPPET:
                var textManager = (IVsTextManager2)_mProvider.ServiceProvider.GetService(typeof(SVsTextManager));
                textManager.GetExpansionManager(out _mExManager);
                TriggerSnippet(nCmdID);
                return(VSConstants.S_OK);
            }

            return(_mNextCommandHandler.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut));
        }
示例#25
0
        /// <summary>
        /// Queries the object for the status of one or more commands generated by user interface events.
        /// </summary>
        /// <param name="pguidCmdGroup">Unique identifier of the command group; can be NULL to specify the standard group. All the commands that are passed in the prgCmds array must belong to the group specified by pguidCmdGroup.</param>
        /// <param name="cCmds">The number of commands in the prgCmds array.</param>
        /// <param name="prgCmds">A caller-allocated array of OLECMD structures that indicate the commands for which the caller needs status information. This method fills the cmdf member of each structure with values taken from the OLECMDF enumeration.</param>
        /// <param name="pCmdText">Pointer to an OLECMDTEXT structure in which to return name and/or status information of a single command. Can be NULL to indicate that the caller does not need this information.</param>
        /// <returns>This method supports the standard return values E_FAIL and E_UNEXPECTED, as well as the following: S_OK, E_POINTER, OLECMDERR_E_UNKNOWNGROUP</returns>
        public int QueryStatus(ref Guid pguidCmdGroup, uint cCmds, OLECMD[] prgCmds, IntPtr pCmdText)
        {
            // add insert snippets context menu
            if (!VsShellUtilities.IsInAutomationFunction(languageService.Site))
            {
                if (pguidCmdGroup == VSConstants.VSStd2K && cCmds > 0)
                {
                    // make the Insert Snippet command appear on the context menu
                    if ((uint)prgCmds[0].cmdID == (uint)VSConstants.VSStd2KCmdID.INSERTSNIPPET)
                    {
                        prgCmds[0].cmdf = (int)Microsoft.VisualStudio.OLE.Interop.Constants.MSOCMDF_ENABLED | (int)Microsoft.VisualStudio.OLE.Interop.Constants.MSOCMDF_SUPPORTED;
                        return(VSConstants.S_OK);
                    }
                }
            }

            return(VsCommandFilter.QueryStatus(ref pguidCmdGroup, cCmds, prgCmds, pCmdText));
        }
示例#26
0
        public int QueryStatus(ref Guid pguidCmdGroup, uint cCmds, OLECMD[] prgCmds, IntPtr pCmdText)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            if (!VsShellUtilities.IsInAutomationFunction(ProbeToolsPackage.Instance))
            {
                if (pguidCmdGroup == VSConstants.VSStd2K && cCmds > 0)
                {
                    if (prgCmds[0].cmdID == (uint)VSConstants.VSStd2KCmdID.INSERTSNIPPET)
                    {
                        prgCmds[0].cmdf = (int)Microsoft.VisualStudio.OLE.Interop.Constants.MSOCMDF_ENABLED | (int)Microsoft.VisualStudio.OLE.Interop.Constants.MSOCMDF_SUPPORTED;
                        return(VSConstants.S_OK);
                    }
                }
            }

            return(_nextCommandHandler.QueryStatus(ref pguidCmdGroup, cCmds, prgCmds, pCmdText));
        }
        public int Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
        {
            if (VsShellUtilities.IsInAutomationFunction(_provider.ServiceProvider))
            {
                return(_nextCommandHandler.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut));
            }

            if (pguidCmdGroup != VSConstants.GUID_VSStandardCommandSet97 || nCmdID != (uint)VSConstants.VSStd97CmdID.GotoDefn)
            {
                return(_nextCommandHandler.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut));
            }

            if (!TryGoToDefinition())
            {
                return(_nextCommandHandler.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut));
            }

            return(VSConstants.S_OK);
        }
示例#28
0
        public int Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
        {
            if (VsShellUtilities.IsInAutomationFunction(Service))
            {
                return(_nextCommandTarget.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut));
            }

            if (pguidCmdGroup == VSConstants.VSStd2K)
            {
                switch ((VSConstants.VSStd2KCmdID)nCmdID)
                {
                case VSConstants.VSStd2KCmdID.AUTOCOMPLETE:
                case VSConstants.VSStd2KCmdID.COMPLETEWORD:
                    // let it autocomplete
                    var vbefore = TextView.TextSnapshot.Version;
                    _nextCommandTarget.Exec(pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut);

                    // call our low priority to check for session
                    Check4Session();

                    // detects if it autocompleted
                    ThreadHelper.JoinableTaskFactory.Run(async delegate
                    {
                        await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
                        var vafter = TextView.TextSnapshot.Version;
                        if (vbefore != vafter)
                        {
                            _state._justCompletedWordVer = TextView.TextSnapshot.Version;
                            _state._justCompletedFunc    = true;
                        }
                    });

                    return(VSConstants.S_OK);
                }
            }

            //if(pguidCmdGroup == VSConstants.VSStd2K || pguidCmdGroup == VSConstants.GUID_VSStandardCommandSet97)
            {
                Check4Session();
            }

            return(_nextCommandTarget.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut));
        }
示例#29
0
        public int Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
        {
            SetUpCommandInfo(pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut);

            var Result = VSConstants.S_OK;

            try
            {
                if (pguidCmdGroup == VSConstants.GUID_VSStandardCommandSet97)
                {
                    switch ((VSConstants.VSStd97CmdID)nCmdID)
                    {
                    case VSConstants.VSStd97CmdID.GotoDefn:
                        GotoDefinition();
                        return(Result);
                    }
                }

                if (VsShellUtilities.IsInAutomationFunction(Provider.ServiceProvider))
                {
                    return(PassCommandAlong);
                }

                if (IsCommitCharacter && IsSelection)
                {
                    if (IsFullySelected)
                    {
                        Session.Commit();
                        return(Result);
                    }
                    Session.Dismiss();
                }

                Result = PassCommandAlong;

                return(LetterOrDigit ||
                       DeletionCharacter ||
                       AutocompleteCommand ?
                       VSConstants.S_OK :
                       Result);
            } catch { return(Result); }
        }
示例#30
0
        public int QueryStatus(ref Guid pguidCmdGroup, uint cCmds, OLECMD[] prgCmds, IntPtr pCmdText)
        {
            if (VsShellUtilities.IsInAutomationFunction(_mProvider.ServiceProvider))
            {
                return(_mNextCommandHandler.QueryStatus(ref pguidCmdGroup, cCmds, prgCmds, pCmdText));
            }

            if (pguidCmdGroup != VSConstants.VSStd2K || cCmds <= 0)
            {
                return(_mNextCommandHandler.QueryStatus(ref pguidCmdGroup, cCmds, prgCmds, pCmdText));
            }

            if (prgCmds[0].cmdID != (uint)VSConstants.VSStd2KCmdID.INSERTSNIPPET && (prgCmds[0].cmdID != (uint)VSConstants.VSStd2KCmdID.SURROUNDWITH || _textView.Selection.IsEmpty))
            {
                return(_mNextCommandHandler.QueryStatus(ref pguidCmdGroup, cCmds, prgCmds, pCmdText));
            }

            prgCmds[0].cmdf = (int)Constants.MSOCMDF_ENABLED | (int)Constants.MSOCMDF_SUPPORTED;
            return(VSConstants.S_OK);
        }