Editor Imports
You can import a number of editor services, factories, and brokers that provide your extension with different kinds of access to the core editor. For example, you can import the ITextStructureNavigatorSelectorService to provide you with a ITextStructureNavigator for a given content type. (This navigator allows you perform different kinds of searches on a text buffer.)
To use an editor import, you import it as a field or property of a class that exports a Managed Extensibility Framework component part.
Note
For more information about the Managed Extensibility Framework, see Managed Extensibility Framework (MEF).
Import Syntax
The following example shows how to import the editor options factory service.
[Import]
internal IEditorOptionsFactoryService EditorOptions { get; set; }
If you want to import the service as a field and not a property, you should set it to null in the declaration in order to avoid the compiler warnings about not assigning to a variable:
[Import]
internal IEditorOptionsFactoryService m_editorOptions = null;
For more examples of using imports, see the following walkthroughs:
Walkthrough: Creating a Margin Glyph
Walkthrough: Customizing the Text View
Walkthrough: Highlighting Text
Walkthrough: Displaying QuickInfo Tooltips
Walkthrough: Displaying Signature Help
Walkthrough: Displaying Statement Completion
Walkthrough: Displaying SmartTags
Importing the Service Provider
You can also import a SVsServiceProvider (found in the assembly Microsoft.VisualStudio.Shell.Immutable.10.0) in the same way to get access to Visual Studio services:
[Import]
internal SVsServiceProvider ServiceProvider = null;
See Walkthrough: Accessing the DTE Object from an Editor Extension for more information.
Services
Editor services are generally single entities that provide a service and are shared across multiple components.
Import |
Provides |
---|---|
The relationship between file extensions and IContentType objects. |
|
The collection of IContentType objects. |
|
IVsFontsAndColorsInformation objects |
|
Many editor adapter objects: |
|
An IIncrementalSearch object for a given text view. |
|
An ITextBuffer. |
|
An ITextDocument. |
|
An IDifferenceCollection<T> of differences. |
|
An IHierarchicalDifferenceCollection of differences. |
|
An IProjectionBuffer or an IElisionBuffer. |
|
An IBufferGraph for a set of ITextBuffer objects. |
|
An IClassifier for a ITextBuffer. |
|
An IClassifier for a ITextView. |
|
An IClassificationFormatMap for a ITextView. |
|
An IEditorFormatMap for a ITextView. |
|
Maintains the collection of IClassificationType objects. |
|
An ITagAggregator<T> for a text buffer. |
|
An ITagAggregator<T> for a text view. |
|
The IEditorOptions for the specified scope. |
|
An IScrollMap for a text view. |
|
An ISmartIndent for a ITextView. |
|
Gets the automatic indentation through the ISmartIndentProvider objects. |
|
Manages the IWpfTextViewHost for a IWpfTextView. |
|
Generates RTF-formatted text from a set of snapshot spans. |
|
An ITextAndAdornmentSequencer for an ITextView. |
|
A TextParagraphProperties for formatting text lines in a view. |
|
A IEditorOperations object for an ITextView. |
|
Searches a text snapshot. |
|
An ITextStructureNavigator for an ITextBuffer by IContentType. |
|
An IOutliningManager for a text view. |
|
A standard set of glyphs. |
|
An IIntellisenseSessionStack for a ITextView. |
|
Tracks keyboard handling. |
|
Standard IClassificationType objects. |
|
Maintains the relationship between text buffers and ITextUndoHistory objects. |
Other Imports
Provider factories and brokers are generally entities that can have multiple instances in multiple components.
Import |
Provides |
---|---|
A SimpleTagger<T> of type ErrorTag) for the given buffer. |
|
A text marker tagger (a SimpleTagger<T> of type TextMarkerTag). |
|
An IToolTipProvider for a given ITextView. |
|