private int QueryVisualStudio2014Status( ref Guid pguidCmdGroup, uint commandCount, OLECMD[] prgCmds, IntPtr commandText ) { switch ((VSConstants.VSStd14CmdID)prgCmds[0].cmdID) { case VSConstants.VSStd14CmdID.SmartBreakLine: prgCmds[0].cmdf = (uint)( OLECMDF.OLECMDF_ENABLED | OLECMDF.OLECMDF_SUPPORTED | OLECMDF.OLECMDF_INVISIBLE ); return(VSConstants.S_OK); default: return(NextCommandTarget.QueryStatus( ref pguidCmdGroup, commandCount, prgCmds, commandText )); } }
public int QueryStatus( ref Guid pguidCmdGroup, uint commandCount, OLECMD[] prgCmds, IntPtr commandText ) { Contract.ThrowIfFalse(commandCount == 1); Contract.ThrowIfFalse(prgCmds.Length == 1); // TODO: We'll need to extend the command handler interfaces at some point when we have commands that // require enabling/disabling at some point. For now, we just enable the few that we care about. if (pguidCmdGroup == VSConstants.VsStd14) { return(QueryVisualStudio2014Status( ref pguidCmdGroup, commandCount, prgCmds, commandText )); } else { return(NextCommandTarget.QueryStatus( ref pguidCmdGroup, commandCount, prgCmds, commandText )); } }
private int QueryRoslynGroupStatus(ref Guid pguidCmdGroup, uint commandCount, OLECMD[] prgCmds, IntPtr commandText) { switch (prgCmds[0].cmdID) { case ID.RoslynCommands.GoToImplementation: return(QueryGoToImplementationStatus(prgCmds)); default: return(NextCommandTarget.QueryStatus(ref pguidCmdGroup, commandCount, prgCmds, commandText)); } }
private int QueryVisualStudio2014Status(ref Guid pguidCmdGroup, uint commandCount, OLECMD[] prgCmds, IntPtr commandText) { switch ((VSConstants.VSStd14CmdID)prgCmds[0].cmdID) { case VSConstants.VSStd14CmdID.SmartBreakLine: return(QueryAutomaticLineEnderStatus(prgCmds)); default: return(NextCommandTarget.QueryStatus(ref pguidCmdGroup, commandCount, prgCmds, commandText)); } }
private int QueryVisualStudio11Status(ref Guid pguidCmdGroup, uint commandCount, OLECMD[] prgCmds, IntPtr commandText) { switch ((VSConstants.VSStd11CmdID)prgCmds[0].cmdID) { case VSConstants.VSStd11CmdID.ExecuteSelectionInInteractive: return(QueryExecuteInInteractiveWindowStatus(ref pguidCmdGroup, commandCount, prgCmds, commandText));; default: return(NextCommandTarget.QueryStatus(ref pguidCmdGroup, commandCount, prgCmds, commandText)); } }
private int QueryVisualStudio2000Status(ref Guid pguidCmdGroup, uint commandCount, OLECMD[] prgCmds, IntPtr commandText) { switch ((VSConstants.VSStd2KCmdID)prgCmds[0].cmdID) { case VSConstants.VSStd2KCmdID.OPENFILE: return(QueryOpenFileStatus(ref pguidCmdGroup, commandCount, prgCmds, commandText)); default: return(NextCommandTarget.QueryStatus(ref pguidCmdGroup, commandCount, prgCmds, commandText)); } }
private int QueryVisualStudio97Status(ref Guid pguidCmdGroup, uint commandCount, OLECMD[] prgCmds, IntPtr commandText) { switch ((VSConstants.VSStd97CmdID)prgCmds[0].cmdID) { case VSConstants.VSStd97CmdID.GotoDefn: return(QueryGoToDefinitionStatus(prgCmds)); default: return(NextCommandTarget.QueryStatus(ref pguidCmdGroup, commandCount, prgCmds, commandText)); } }
/// <remarks>TODO: Revert the change to use standard VS11 command pending https://github.com/dotnet/roslyn/issues/8927 .</remarks> private int QueryInteractiveStatus(ref Guid pguidCmdGroup, uint commandCount, OLECMD[] prgCmds, IntPtr commandText) { switch (prgCmds[0].cmdID) { case ID.InteractiveCommands.ExecuteInInteractiveWindow: return(QueryExecuteInInteractiveWindowStatus(ref pguidCmdGroup, commandCount, prgCmds, commandText));; default: return(NextCommandTarget.QueryStatus(ref pguidCmdGroup, commandCount, prgCmds, commandText)); } }
private int QueryCSharpGroupStatus(ref Guid pguidCmdGroup, uint commandCount, OLECMD[] prgCmds, IntPtr commandText) { switch (prgCmds[0].cmdID) { case ID.CSharpCommands.OrganizeRemoveAndSort: case ID.CSharpCommands.ContextOrganizeRemoveAndSort: return(QuerySortAndRemoveUnusedUsingsStatus(ref pguidCmdGroup, commandCount, prgCmds, commandText)); default: return(NextCommandTarget.QueryStatus(ref pguidCmdGroup, commandCount, prgCmds, commandText)); } }
private int QueryVisualStudio2000Status(ref Guid pguidCmdGroup, uint commandCount, OLECMD[] prgCmds, IntPtr commandText) { switch ((VSConstants.VSStd2KCmdID)prgCmds[0].cmdID) { case VSConstants.VSStd2KCmdID.FORMATDOCUMENT: prgCmds[0].cmdf = (uint)(OLECMDF.OLECMDF_ENABLED | OLECMDF.OLECMDF_SUPPORTED); return(VSConstants.S_OK); default: return(NextCommandTarget.QueryStatus(ref pguidCmdGroup, commandCount, prgCmds, commandText)); } }
private int QueryRoslynGroupStatus(ref Guid pguidCmdGroup, uint commandCount, OLECMD[] prgCmds, IntPtr commandText) { switch (prgCmds[0].cmdID) { case ID.RoslynCommands.GoToImplementation: prgCmds[0].cmdf = (uint)(OLECMDF.OLECMDF_ENABLED | OLECMDF.OLECMDF_SUPPORTED); return(VSConstants.S_OK); default: return(NextCommandTarget.QueryStatus(ref pguidCmdGroup, commandCount, prgCmds, commandText)); } }
private int QueryAppCommandStatus(ref Guid pguidCmdGroup, uint commandCount, OLECMD[] prgCmds, IntPtr commandText) { switch ((VSConstants.AppCommandCmdID)prgCmds[0].cmdID) { case VSConstants.AppCommandCmdID.BrowserBackward: case VSConstants.AppCommandCmdID.BrowserForward: prgCmds[0].cmdf = (uint)(OLECMDF.OLECMDF_ENABLED | OLECMDF.OLECMDF_SUPPORTED); return(VSConstants.S_OK); default: return(NextCommandTarget.QueryStatus(ref pguidCmdGroup, commandCount, prgCmds, commandText)); } }
private int QueryCSharpGroupStatus(ref Guid pguidCmdGroup, uint commandCount, OLECMD[] prgCmds, IntPtr commandText) { switch (prgCmds[0].cmdID) { case ID.CSharpCommands.OrganizeRemoveAndSort: case ID.CSharpCommands.ContextOrganizeRemoveAndSort: prgCmds[0].cmdf = (uint)(OLECMDF.OLECMDF_ENABLED | OLECMDF.OLECMDF_SUPPORTED); return(VSConstants.S_OK); default: return(NextCommandTarget.QueryStatus(ref pguidCmdGroup, commandCount, prgCmds, commandText)); } }
private int QueryVisualStudio97Status(ref Guid pguidCmdGroup, uint commandCount, OLECMD[] prgCmds, IntPtr commandText) { switch ((VSConstants.VSStd97CmdID)prgCmds[0].cmdID) { case VSConstants.VSStd97CmdID.GotoDefn: case VSConstants.VSStd97CmdID.FindReferences: case VSConstants.VSStd97CmdID.SyncClassView: prgCmds[0].cmdf = (uint)(OLECMDF.OLECMDF_ENABLED | OLECMDF.OLECMDF_SUPPORTED); return(VSConstants.S_OK); default: return(NextCommandTarget.QueryStatus(ref pguidCmdGroup, commandCount, prgCmds, commandText)); } }
private int QueryInteractiveCommandStatus(ref Guid pguidCmdGroup, uint commandCount, OLECMD[] prgCmds, IntPtr commandText) { switch ((InteractiveCommandIds)prgCmds[0].cmdID) { case InteractiveCommandIds.ExecuteInInteractiveWindow: return QueryExecuteInInteractiveWindowStatus(ref pguidCmdGroup, commandCount, prgCmds, commandText); case InteractiveCommandIds.CopyToInteractiveWindow: return QueryCopyToInteractiveWindowStatus(ref pguidCmdGroup, commandCount, prgCmds, commandText); default: return NextCommandTarget.QueryStatus(ref pguidCmdGroup, commandCount, prgCmds, commandText); } }
private int GetCommandState <T>( Func <ITextView, ITextBuffer, T> createArgs, ref Guid pguidCmdGroup, uint commandCount, OLECMD[] prgCmds, IntPtr commandText) where T : CommandArgs { var result = VSConstants.S_OK; var guidCmdGroup = pguidCmdGroup; CommandState executeNextCommandTarget() { result = NextCommandTarget.QueryStatus(ref guidCmdGroup, commandCount, prgCmds, commandText); var isAvailable = ((OLECMDF)prgCmds[0].cmdf & OLECMDF.OLECMDF_ENABLED) == OLECMDF.OLECMDF_ENABLED; var isChecked = ((OLECMDF)prgCmds[0].cmdf & OLECMDF.OLECMDF_LATCHED) == OLECMDF.OLECMDF_LATCHED; return(new CommandState(isAvailable, isChecked, GetText(commandText))); } CommandState commandState; var subjectBuffer = GetSubjectBufferContainingCaret(); if (subjectBuffer == null) { commandState = executeNextCommandTarget(); } else { commandState = CurrentHandlers.GetCommandState <T>( subjectBuffer.ContentType, args: createArgs(ConvertTextView(), subjectBuffer), lastHandler: executeNextCommandTarget); } var enabled = commandState.IsAvailable ? OLECMDF.OLECMDF_ENABLED : OLECMDF.OLECMDF_INVISIBLE; var latched = commandState.IsChecked ? OLECMDF.OLECMDF_LATCHED : OLECMDF.OLECMDF_NINCHED; prgCmds[0].cmdf = (uint)(enabled | latched | OLECMDF.OLECMDF_SUPPORTED); if (!string.IsNullOrEmpty(commandState.DisplayText) && GetText(commandText) != commandState.DisplayText) { SetText(commandText, commandState.DisplayText); } return(result); }
private int QueryVisualStudio2000Status(ref Guid pguidCmdGroup, uint commandCount, OLECMD[] prgCmds, IntPtr commandText) { switch ((VSConstants.VSStd2KCmdID)prgCmds[0].cmdID) { case VSConstants.VSStd2KCmdID.FORMATDOCUMENT: return(QueryFormatDocumentStatus(prgCmds)); case VSConstants.VSStd2KCmdID.FORMATSELECTION: return(QueryFormatSelectionStatus(prgCmds)); case CmdidToggleConsumeFirstMode: return(QueryToggleConsumeFirstModeStatus(ref pguidCmdGroup, commandCount, prgCmds, commandText)); case VSConstants.VSStd2KCmdID.COMMENT_BLOCK: case VSConstants.VSStd2KCmdID.COMMENTBLOCK: return(QueryCommentBlockStatus(ref pguidCmdGroup, commandCount, prgCmds, commandText)); case VSConstants.VSStd2KCmdID.UNCOMMENT_BLOCK: case VSConstants.VSStd2KCmdID.UNCOMMENTBLOCK: return(QueryUncommentBlockStatus(ref pguidCmdGroup, commandCount, prgCmds, commandText)); case CmdidNextHighlightedReference: case CmdidPreviousHighlightedReference: return(QueryNavigateHighlightedReferenceStatus(prgCmds)); case VSConstants.VSStd2KCmdID.COMPLETEWORD: return(QueryCompleteWordStatus(prgCmds)); case VSConstants.VSStd2KCmdID.SHOWMEMBERLIST: return(QueryShowMemberListStatus(prgCmds)); case VSConstants.VSStd2KCmdID.PARAMINFO: return(QueryParameterInfoStatus(prgCmds)); case VSConstants.VSStd2KCmdID.QUICKINFO: return(QueryQuickInfoStatus(prgCmds)); case VSConstants.VSStd2KCmdID.OUTLN_START_AUTOHIDING: return(QueryStartAutomaticOutliningStatus(ref pguidCmdGroup, commandCount, prgCmds, commandText)); case VSConstants.VSStd2KCmdID.OPENFILE: return(QueryOpenFileStatus(ref pguidCmdGroup, commandCount, prgCmds, commandText)); default: return(NextCommandTarget.QueryStatus(ref pguidCmdGroup, commandCount, prgCmds, commandText)); } }
private int QuerySortAndRemoveUnusedUsingsStatus(ref Guid pguidCmdGroup, uint commandCount, OLECMD[] prgCmds, IntPtr commandText) { var textBuffer = GetSubjectBufferContainingCaret(); if (textBuffer != null) { if (CodeAnalysis.Workspace.TryGetWorkspace(textBuffer.AsTextContainer(), out var workspace)) { var organizeImportsService = workspace.Services.GetLanguageServices(textBuffer).GetService <IOrganizeImportsService>(); if (organizeImportsService != null) { SetText(commandText, organizeImportsService.SortAndRemoveUnusedImportsDisplayStringWithAccelerator); } } } return(NextCommandTarget.QueryStatus(ref pguidCmdGroup, commandCount, prgCmds, commandText)); }
private int QueryOrganizeMenu(ref Guid pguidCmdGroup, uint commandCount, OLECMD[] prgCmds, IntPtr commandText) { var textBuffer = GetSubjectBufferContainingCaret(); if (textBuffer != null) { Workspace workspace; if (Workspace.TryGetWorkspace(textBuffer.AsTextContainer(), out workspace)) { var organizeImportsService = workspace.Services.GetLanguageServices(textBuffer).GetService<IOrganizeImportsService>(); if (organizeImportsService != null) { SetText(commandText, organizeImportsService.OrganizeImportsDisplayStringWithAccelerator); } } } return NextCommandTarget.QueryStatus(ref pguidCmdGroup, commandCount, prgCmds, commandText); }
public int QueryStatus(ref Guid pguidCmdGroup, uint commandCount, OLECMD[] prgCmds, IntPtr commandText) { Contract.ThrowIfFalse(commandCount == 1); Contract.ThrowIfFalse(prgCmds.Length == 1); // TODO: We'll need to extend the command handler interfaces at some point when we have commands that // require enabling/disabling at some point. For now, we just enable the few that we care about. if (pguidCmdGroup == VSConstants.VSStd2K) { return(QueryVisualStudio2000Status(ref pguidCmdGroup, commandCount, prgCmds, commandText)); } else if (pguidCmdGroup == Guids.CSharpGroupId) { return(QueryCSharpGroupStatus(ref pguidCmdGroup, commandCount, prgCmds, commandText)); } else if (pguidCmdGroup == VSConstants.GUID_VSStandardCommandSet97) { return(QueryVisualStudio97Status(ref pguidCmdGroup, commandCount, prgCmds, commandText)); } #if INTERACTIVE else if (pguidCmdGroup == InteractiveGuids.InteractiveCommandSetId) { return(QueryInteractiveCommandStatus(ref pguidCmdGroup, commandCount, prgCmds, commandText)); } #endif else if (pguidCmdGroup == VSConstants.VsStd14) { return(QueryVisualStudio2014Status(ref pguidCmdGroup, commandCount, prgCmds, commandText)); } else if (pguidCmdGroup == VSConstants.GUID_AppCommand) { return(QueryAppCommandStatus(ref pguidCmdGroup, commandCount, prgCmds, commandText)); } else if (pguidCmdGroup == Guids.RoslynGroupId) { return(QueryRoslynGroupStatus(ref pguidCmdGroup, commandCount, prgCmds, commandText)); } else { return(NextCommandTarget.QueryStatus(ref pguidCmdGroup, commandCount, prgCmds, commandText)); } }
public override int QueryStatus(ref Guid pguidCmdGroup, uint cCmds, OLECMD[] prgCmds, IntPtr pCmdText) { return(NextCommandTarget.QueryStatus(ref pguidCmdGroup, cCmds, prgCmds, pCmdText)); }
private int QueryVisualStudio2000Status(ref Guid pguidCmdGroup, uint commandCount, OLECMD[] prgCmds, IntPtr commandText) { switch ((VSConstants.VSStd2KCmdID)prgCmds[0].cmdID) { case VSConstants.VSStd2KCmdID.FORMATDOCUMENT: return(QueryFormatDocumentStatus(prgCmds)); case VSConstants.VSStd2KCmdID.FORMATSELECTION: return(QueryFormatSelectionStatus(prgCmds)); case VSConstants.VSStd2KCmdID.ECMD_INSERTCOMMENT: return(QueryInsertCommentStatus(ref pguidCmdGroup, commandCount, prgCmds, commandText)); case CmdidToggleConsumeFirstMode: return(QueryToggleConsumeFirstModeStatus(ref pguidCmdGroup, commandCount, prgCmds, commandText)); case VSConstants.VSStd2KCmdID.COMMENT_BLOCK: case VSConstants.VSStd2KCmdID.COMMENTBLOCK: return(QueryCommentBlockStatus(ref pguidCmdGroup, commandCount, prgCmds, commandText)); case VSConstants.VSStd2KCmdID.UNCOMMENT_BLOCK: case VSConstants.VSStd2KCmdID.UNCOMMENTBLOCK: return(QueryUncommentBlockStatus(ref pguidCmdGroup, commandCount, prgCmds, commandText)); case CmdidNextHighlightedReference: case CmdidPreviousHighlightedReference: return(QueryNavigateHighlightedReferenceStatus(prgCmds)); case VSConstants.VSStd2KCmdID.COMPLETEWORD: return(QueryCompleteWordStatus(prgCmds)); case VSConstants.VSStd2KCmdID.SHOWMEMBERLIST: return(QueryShowMemberListStatus(prgCmds)); case VSConstants.VSStd2KCmdID.PARAMINFO: return(QueryParameterInfoStatus(prgCmds)); case VSConstants.VSStd2KCmdID.QUICKINFO: return(QueryQuickInfoStatus(prgCmds)); case VSConstants.VSStd2KCmdID.RENAME: return(QueryRenameStatus(ref pguidCmdGroup, commandCount, prgCmds, commandText)); case VSConstants.VSStd2KCmdID.EXTRACTINTERFACE: return(QueryExtractInterfaceStatus(ref pguidCmdGroup, commandCount, prgCmds, commandText)); case VSConstants.VSStd2KCmdID.EXTRACTMETHOD: return(QueryExtractMethodStatus(ref pguidCmdGroup, commandCount, prgCmds, commandText)); case CmdidContextMenuViewCallHierarchy: return(QueryViewCallHierarchyStatus(ref pguidCmdGroup, commandCount, prgCmds, commandText)); case VSConstants.VSStd2KCmdID.INSERTSNIPPET: return(QueryInsertSnippetStatus(ref pguidCmdGroup, commandCount, prgCmds, commandText)); case VSConstants.VSStd2KCmdID.SURROUNDWITH: return(QuerySurroundWithStatus(ref pguidCmdGroup, commandCount, prgCmds, commandText)); case VSConstants.VSStd2KCmdID.BACKTAB: return(QueryBackTabStatus(prgCmds)); case VSConstants.VSStd2KCmdID.ENCAPSULATEFIELD: return(QueryEncapsulateFieldStatus(ref pguidCmdGroup, commandCount, prgCmds, commandText)); case VSConstants.VSStd2KCmdID.REMOVEPARAMETERS: return(QueryRemoveParametersStatus(ref pguidCmdGroup, commandCount, prgCmds, commandText)); case VSConstants.VSStd2KCmdID.REORDERPARAMETERS: return(QueryReorderParametersStatus(ref pguidCmdGroup, commandCount, prgCmds, commandText)); case VSConstants.VSStd2KCmdID.OUTLN_START_AUTOHIDING: return(QueryStartAutomaticOutliningStatus(ref pguidCmdGroup, commandCount, prgCmds, commandText)); default: return(NextCommandTarget.QueryStatus(ref pguidCmdGroup, commandCount, prgCmds, commandText)); } }