protected override bool HandlePreExec(ref Guid commandGroup, uint commandId, uint executionOptions, IntPtr pvaIn, IntPtr pvaOut) { if (commandGroup == VsMenus.guidStandardCommandSet97) { switch ((VSConstants.VSStd97CmdID)commandId) { case VSConstants.VSStd97CmdID.GotoDecl: case VSConstants.VSStd97CmdID.GotoDefn: case VSConstants.VSStd97CmdID.GotoRef: HandleGoto((VSConstants.VSStd97CmdID)commandId); return(true); default: break; } } else if (commandGroup == VsMenus.guidStandardCommandSet2K) { switch ((VSConstants.VSStd2KCmdID)commandId) { case VSConstants.VSStd2KCmdID.FORMATDOCUMENT: ReformatDocument(); return(true); case VSConstants.VSStd2KCmdID.FORMATSELECTION: ReformatSelection(); return(true); case VSConstants.VSStd2KCmdID.COMMENT_BLOCK: case VSConstants.VSStd2KCmdID.COMMENTBLOCK: CommentSelection(); return(true); case VSConstants.VSStd2KCmdID.UNCOMMENT_BLOCK: case VSConstants.VSStd2KCmdID.UNCOMMENTBLOCK: UncommentSelection(); return(true); case VSConstants.VSStd2KCmdID.SHOWMEMBERLIST: CompletionHelper.DoTriggerCompletion(CompletionTarget, CompletionInfoType.ContextInfo, false, IntellisenseInvocationType.Default); return(true); case VSConstants.VSStd2KCmdID.COMPLETEWORD: CompletionHelper.DoTriggerCompletion(CompletionTarget, CompletionInfoType.GlobalInfo, false, IntellisenseInvocationType.Default); return(true); case VSConstants.VSStd2KCmdID.PARAMINFO: CompletionHelper.DoTriggerCompletion(CompletionTarget, CompletionInfoType.ContextInfo, true, IntellisenseInvocationType.Default); return(true); case VSConstants.VSStd2KCmdID.QUICKINFO: throw new NotImplementedException(); default: break; } } return(base.HandlePreExec(ref commandGroup, commandId, executionOptions, pvaIn, pvaOut)); }
protected override bool HandlePreExec(ref Guid commandGroup, uint commandId, uint executionOptions, IntPtr pvaIn, IntPtr pvaOut) { bool handled = Controller.PreprocessCommand(ref commandGroup, commandId, (OLECMDEXECOPT)executionOptions, pvaIn, pvaOut); try { if (!handled) { IIntellisenseCommandTarget sessionStack = Controller.IntellisenseSessionStack as IIntellisenseCommandTarget; IntellisenseKeyboardCommand?command = TranslateKeyboardCommand(commandGroup, commandId); if (sessionStack != null && command.HasValue) { handled = sessionStack.ExecuteKeyboardCommand(command.Value); } } if (commandGroup == VsMenus.guidStandardCommandSet97) { VSOBJGOTOSRCTYPE?gotoSourceType = null; switch ((VSConstants.VSStd97CmdID)commandId) { case VSConstants.VSStd97CmdID.GotoDecl: { if (!Controller.SupportsGotoDeclaration) { throw new NotSupportedException("The IntelliSense controller does not support the Go To Declaration operation."); } gotoSourceType = VSOBJGOTOSRCTYPE.GS_DECLARATION; handled = true; break; } case VSConstants.VSStd97CmdID.GotoDefn: { if (!Controller.SupportsGotoDefinition) { throw new NotSupportedException("The IntelliSense controller does not support the Go To Definition operation."); } gotoSourceType = VSOBJGOTOSRCTYPE.GS_DEFINITION; handled = true; break; } case VSConstants.VSStd97CmdID.GotoRef: { if (!Controller.SupportsGotoReference) { throw new NotSupportedException("The IntelliSense controller does not support the Go To Reference operation."); } gotoSourceType = VSOBJGOTOSRCTYPE.GS_REFERENCE; handled = true; break; } default: break; } if (gotoSourceType.HasValue) { ITextView textView = Controller.TextView; SnapshotPoint? point = textView.Caret.Position.Point.GetPoint(textView.TextBuffer, PositionAffinity.Predecessor); ITrackingPoint triggerPoint = textView.TextBuffer.CurrentSnapshot.CreateTrackingPoint(point.Value.Position, PointTrackingMode.Positive); Controller.GoToSource(gotoSourceType.Value, triggerPoint); handled = true; } } else if (commandGroup == VsMenus.guidStandardCommandSet2K) { switch ((VSConstants.VSStd2KCmdID)commandId) { case VSConstants.VSStd2KCmdID.UP_EXT: if (DismissAllCompletionSessions() || AnySignatureHelpSessions()) { commandId = (uint)VSConstants.VSStd2KCmdID.UP; handled = false; } break; case VSConstants.VSStd2KCmdID.DOWN_EXT: if (DismissAllCompletionSessions() || AnySignatureHelpSessions()) { commandId = (uint)VSConstants.VSStd2KCmdID.DOWN; handled = false; } break; case ECMD_SMARTTASKS: ExpandSmartTagUnderCaret(); handled = true; break; case VSConstants.VSStd2KCmdID.SHOWMEMBERLIST: CompletionHelper.DoTriggerCompletion(Controller, CompletionInfoType.ContextInfo, false, IntellisenseInvocationType.Default); handled = true; break; case VSConstants.VSStd2KCmdID.COMPLETEWORD: CompletionHelper.DoTriggerCompletion(Controller, CompletionInfoType.GlobalInfo, false, IntellisenseInvocationType.Default); handled = true; break; case VSConstants.VSStd2KCmdID.PARAMINFO: CompletionHelper.DoTriggerCompletion(Controller, CompletionInfoType.ContextInfo, true, IntellisenseInvocationType.Default); handled = true; break; case VSConstants.VSStd2KCmdID.QUICKINFO: throw new NotImplementedException(); case VSConstants.VSStd2KCmdID.ToggleConsumeFirstCompletionMode: _isInConsumeFirstCompletionMode = !_isInConsumeFirstCompletionMode; handled = true; break; default: break; } } } catch (Exception e) { Controller.PostprocessCommand(); e.PreserveStackTrace(); throw; } if (handled) { Controller.PostprocessCommand(); } return(handled); }