Partager via


ViewFilter Class

Definition

Important

This API is not CLS-compliant.

ViewFilter provides a default implementation of IVsTextViewFilter providing a handling of the following VS commands:

VsCommands.GotoDefn VsCommands.GotoDecl VsCommands.GotoRef VsCommands2K.COMMENT_BLOCK VsCommands2K.UNCOMMENT_BLOCK VsCommands2K.SHOWMEMBERLIST VsCommands2K.COMPLETEWORD VsCommands2K.PARAMINFO VsCommands2K.QUICKINFO VsCommands2K.OUTLN_STOP_HIDING_ALL VsCommands2K.OUTLN_START_AUTOHIDING VsCommands2K.SHOWCONTEXTMENU

Most of the work is delegated to the Source object.

public ref class ViewFilter : IDisposable, Microsoft::VisualStudio::OLE::Interop::IOleCommandTarget, Microsoft::VisualStudio::TextManager::Interop::IVsExpansionEvents, Microsoft::VisualStudio::TextManager::Interop::IVsTextViewEvents, Microsoft::VisualStudio::TextManager::Interop::IVsTextViewFilter
[System.CLSCompliant(false)]
[System.Runtime.InteropServices.ComVisible(true)]
public class ViewFilter : IDisposable, Microsoft.VisualStudio.OLE.Interop.IOleCommandTarget, Microsoft.VisualStudio.TextManager.Interop.IVsExpansionEvents, Microsoft.VisualStudio.TextManager.Interop.IVsTextViewEvents, Microsoft.VisualStudio.TextManager.Interop.IVsTextViewFilter
[System.Runtime.InteropServices.ComVisible(true)]
public class ViewFilter : IDisposable, Microsoft.VisualStudio.OLE.Interop.IOleCommandTarget, Microsoft.VisualStudio.TextManager.Interop.IVsExpansionEvents, Microsoft.VisualStudio.TextManager.Interop.IVsTextViewEvents, Microsoft.VisualStudio.TextManager.Interop.IVsTextViewFilter
[<System.CLSCompliant(false)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type ViewFilter = class
    interface IVsTextViewFilter
    interface IVsTextViewEvents
    interface IOleCommandTarget
    interface IDisposable
    interface IVsExpansionEvents
[<System.Runtime.InteropServices.ComVisible(true)>]
type ViewFilter = class
    interface IVsTextViewFilter
    interface IVsTextViewEvents
    interface IOleCommandTarget
    interface IDisposable
    interface IVsExpansionEvents
Public Class ViewFilter
Implements IDisposable, IOleCommandTarget, IVsExpansionEvents, IVsTextViewEvents, IVsTextViewFilter
Inheritance
ViewFilter
Attributes
Implements

Remarks

In addition to the cursor, Enter, Backspace, and Delete key commands, this base class provides support for the following commands:

Command Description
AUTOCOMPLETE IntelliSense: select member from member list.
SHOWMEMBERLIST IntelliSense: show member list.
COMPLETEWORD IntelliSense: complete word being typed.
PARAMINFO IntelliSense: show parameter information.
QUICKINFO IntelliSense: show information about an identifier.
GotoDefn Editing (advanced): go to definition.
GotoDecl Editing (advanced): go to declaration.
GotoRef Editing (advanced): go to a reference.
COMMENT_BLOCK Editing (advanced): comment a span of code.
UNCOMMENT_BLOCK Editing (Advanced): uncomment a span of code.
OUTLN_STOP_HIDING_ALL Editing (outlining): stop outlining.
OUTLN_START_AUTOHIDING Editing (outlining): toggle outlining.
SHOWCONTEXTMENU Editing: show a context menu.

Notes to Inheritors

This class already implements all of the support for IntelliSense as well as various advanced editing features. However, if you want to support additional commands in your language service, then you must derive a class from this class and override the appropriate methods:

In addition, you must override the CreateViewFilter(CodeWindowManager, IVsTextView) method in the LanguageService class to create an instance of your version of the ViewFilter class.

Notes to Callers

This class is instantiated in the CreateViewFilter(CodeWindowManager, IVsTextView) method of the LanguageService class that is in turn called from the OnNewView(IVsTextView) method in the CodeWindowManager class when a view is attached to a source file.

Constructors

ViewFilter(CodeWindowManager, IVsTextView)

Initializes a new instance of the ViewFilter class.

Properties

CodeWindowManager

Returnt the CodeWindowManager that created this view filter.

IsExecutingCommand

Determines whether or not the filter is executing commands.

IsExpansionUIActive

Determines if the code snippet expansion user interface (UI) is active.

SnippetBound

Gets or sets whether or not a key has been bound to the Invoke Snippet From Shortcut command.

Source

Return the Source object encapsulating the text buffer.

TextTipData
Obsolete.

Get or set the TextTipData object used for displaying tool tips.

TextView

Return the IVsTextView associated with this filter.

Methods

CanReformat()

This method returns true if the FormatDocument and FormatSelection commands are to be enabled. Default returns false if debugging, otherwise it returns the result for Preferences.EnableFormatSelection.

Close()

Closes down the view filter, releasing any allocated resources.

CommentSelection()

Handles the COMMENT_BLOCK command to comment out the current selection in the view.

CreateTextTipData()
Obsolete.

Creates the TextTipData object and returns it

Dispose()

Frees up any resources allocated when the ViewFilter class was created.

ExecCommand(Guid, UInt32, UInt32, IntPtr, IntPtr)

Override this method to intercept the IOleCommandTarget::Exec call.

Finalize()

Performs final clean up just before the ViewFilter object is destroyed.

GetDataTipText(TextSpan[], String)

If Preferences.EnableQuickInfo is true then this method kicks of a parse with the reason ParseReason.QuickInfo to find information about the current token. If the parse finds something (returned via the AuthoringScope.GetDataTipText) then it is displayed using the TextTipData object. When the asynchronous parse is finished GetFullDataTipText is called to pop up the tip.

GetExpansionProvider()

Returns an ExpansionProvider object.

GetFullDataTipText(String, TextSpan, String)

This method checks to see if the IVsDebugger is running, and if so, calls it to get additional information about the current token and returns a combined result. You can return an HRESULT here like TipSuccesses2.TIP_S_NODEFAULTTIP.

GetPairExtents(Int32, Int32, TextSpan[])

Returns the extent of the innermost matching pair of language elements that contains the given location.

GetSelection()

Returns the current selection, adjusted to become a positive text span

GetWordExtent(Int32, Int32, UInt32, TextSpan[])

Returns the result of Source.GetWordExtent.

HandleGoto(VSConstants+VSStd97CmdID)

Handles VsCommands.GotoDefn, VsCommands.GotoDecl and VsCommands.GotoRef by calling OnSyncGoto on the Source object and opening the text editor on the resulting URL, then scrolling to the resulting span.

HandlePostExec(Guid, UInt32, UInt32, IntPtr, IntPtr, Boolean)

This method hooks up HandleSmartIndent and Source.OnCommand.

HandlePreExec(Guid, UInt32, UInt32, IntPtr, IntPtr)

Handles pre-processing before a command is executed.

HandleQuickInfo()

This method is called to handle the VsCommands2K.QUICKINFO command.

HandleSmartIndent()

Handles smart indentation.

InnerExec(Guid, UInt32, UInt32, IntPtr, IntPtr)

Executes an IOleCommandTarget command.

OnAfterSnippetsKeyBindingChange(UInt32, UInt32, Int32)

Called after there has been a change in the key binding for the Invoke Snippet From Shortcut command.

OnAfterSnippetsUpdate()

Called whenever a folder that contains snippets has been updated and the snippets from that folder have been read in.

OnAutoComplete()

Called when the AUTOCOMPLETE command is received.

OnChangeCaretLine(IVsTextView, Int32, Int32)

Called when the caret moves to another line.

OnChangeScrollInfo(IVsTextView, Int32, Int32, Int32, Int32, Int32)

Called when the scroll information for the specified scroll bar has changed.

OnKillFocus(IVsTextView)

Called when the specified view loses focus.

OnSetBuffer(IVsTextView, IVsTextLines)

Called when the buffer of lines is being set or changed in the given view.

OnSetFocus(IVsTextView)

Called when the specified view gains focus.

QueryCommandStatus(Guid, UInt32)

Override this method to intercept the IOleCommandTarget::QueryStatus call.

QueryParameterList(Guid, UInt32, UInt32, IntPtr, IntPtr)

The parameter list of a command is queried by calling Exec with the LOWORD of nCmdexecopt set to OLECMDEXECOPT_SHOWHELP (instead of the more usual OLECMDEXECOPT_DODEFAULT), the HIWORD of nCmdexecopt set to VSCmdOptQueryParameterList, pvaIn set to NULL, and pvaOut pointing to an empty VARIANT ready to receive the result BSTR. This should be done only for commands that are marked with the ALLOWPARAMS flags in the command table.

ReformatDocument()

Handles the FORMATDOCUMENT command to reformat the entire document.

ReformatSelection()

Handles the FORMATSELECTION command to reformat a selection.

RegisterExpansionManagerEventHandlers(IVsExpansionManager)

Registers event handlers IVsExpansionEvents.

RegisterTextViewEventHandlers(IVsTextView)

Register text view event handlers.

ShowContextMenu(Int32, Guid, IOleCommandTarget, Int32, Int32)

Handles the SHOWCONTEXTMENU command to show a context menu.

TypeChar(Char)

Executes a TYPECHAR on the current command target chain.

UncommentSelection()

Handles the UNCOMMENTBLOCK command to uncomment the current selection in the current view.

Explicit Interface Implementations

IOleCommandTarget.Exec(Guid, UInt32, UInt32, IntPtr, IntPtr)

Handles execution of a supported command.

IOleCommandTarget.QueryStatus(Guid, UInt32, OLECMD[], IntPtr)

Determines if the specified commands in the given command group are supported.

Applies to