CodeSnippetProvider Class
Implements a code snippet provider that can manage the available code snippets and handle requests for display of IntelliPrompt code snippet sessions.
public class CodeSnippetProvider : ICodeSnippetProvider, IOrderable, IKeyedObject, IEditorViewKeyInputEventSink, ITextViewLifecycleEventSink, ITextViewTaggerProvider
- Inheritance:
- object object
- Implements:
- ICodeSnippetProvider IOrderable IKeyedObject IEditorViewKeyInputEventSink ITextViewLifecycleEventSink ITextViewTaggerProvider
Remarks
Instances of this object can be registered with an ISyntaxLanguage using the RegisterService(object, object) method. Once an instance is registered with the language as a service, its features can be used by the language.
Constructors
CodeSnippetProvider()
Implements a code snippet provider that can manage the available code snippets and handle requests for display of IntelliPrompt code snippet sessions.
public CodeSnippetProvider()
Remarks
Instances of this object can be registered with an ISyntaxLanguage using the RegisterService(object, object) method. Once an instance is registered with the language as a service, its features can be used by the language.
CodeSnippetProvider(string)
Implements a code snippet provider that can manage the available code snippets and handle requests for display of IntelliPrompt code snippet sessions.
public CodeSnippetProvider(string key)
| Parameter | Type | Description |
|---|---|---|
| key | string | The string-based key that identifies the provider. |
Remarks
Instances of this object can be registered with an ISyntaxLanguage using the RegisterService(object, object) method. Once an instance is registered with the language as a service, its features can be used by the language.
CodeSnippetProvider(string, params Ordering[]?)
Implements a code snippet provider that can manage the available code snippets and handle requests for display of IntelliPrompt code snippet sessions.
public CodeSnippetProvider(string key, params Ordering[]? orderings)
| Parameter | Type | Description |
|---|---|---|
| key | string | The string-based key that identifies the provider. |
| orderings | Ordering[] | The array of Ordering objects, used to determine how this object is positioned relative to other objects. |
Remarks
Instances of this object can be registered with an ISyntaxLanguage using the RegisterService(object, object) method. Once an instance is registered with the language as a service, its features can be used by the language.
Properties
IsCaseSensitive
Indicates whether code snippet shortcut matching requires a case-sensitive match.
public bool IsCaseSensitive { get; set; }
Property Value
- bool:
trueif code snippet shortcut matching requires a case-sensitive match; otherwise,false. The default value istrue.
Key
The string-based key that identifies the object.
Orderings
The collection of Ordering objects, used to determine how this object is positioned relative to other objects.
RootFolder
The root ICodeSnippetFolder containing code snippets that are accessible by this provider.
Methods
CheckForShortcut(IEditorView)
Checks for a code snippet shortcut before the caret and opens a template session if one was found.
protected bool CheckForShortcut(IEditorView view)
| Parameter | Type | Description |
|---|---|---|
| view | IEditorView | The IEditorView to examine. |
Returns
- bool:
trueif a template session was opened; otherwise,false.
CreateSelectionSession(ICodeSnippetFolder, CodeSnippetTypes)
Creates an ICodeSnippetSelectionSession for use with a RequestSelectionSession(IEditorView, CodeSnippetTypes) call.
protected virtual ICodeSnippetSelectionSession CreateSelectionSession(ICodeSnippetFolder rootFolder, CodeSnippetTypes snippetType)
| Parameter | Type | Description |
|---|---|---|
| rootFolder | ICodeSnippetFolder | The root ICodeSnippetFolder to display. |
| snippetType | CodeSnippetTypes | A CodeSnippetTypes indicating the type of code snippets to include. |
Returns
- ICodeSnippetSelectionSession:
The ICodeSnippetSelectionSession that was created.
GetPossibleShortcutSnapshotRange(TextSnapshotOffset)
Returns a possible code snippet shortcut TextSnapshotRange, located immediately before the specified TextSnapshotOffset.
protected virtual TextSnapshotRange? GetPossibleShortcutSnapshotRange(TextSnapshotOffset snapshotOffset)
| Parameter | Type | Description |
|---|---|---|
| snapshotOffset | TextSnapshotOffset | The TextSnapshotOffset to examine. |
Returns
- TextSnapshotRange?:
The TextSnapshotRange of the possible shortcut; or
nullif there is no possible shortcut.
Remarks
Language implementations may wish to inherit this class and override this method to ensure the shortcut is not within a comment or other literal.
OnViewKeyDown(IEditorView, KeyEventArgs)
Occurs when a key is pressed down while focus is in the specified IEditorView.
protected virtual void OnViewKeyDown(IEditorView view, KeyEventArgs e)
| Parameter | Type | Description |
|---|---|---|
| view | IEditorView | The IEditorView that received the event. |
| e | KeyEventArgs | The event data. |
OnViewKeyUp(IEditorView, KeyEventArgs)
Occurs when a key is released while focus is in the specified IEditorView.
protected virtual void OnViewKeyUp(IEditorView view, KeyEventArgs e)
| Parameter | Type | Description |
|---|---|---|
| view | IEditorView | The IEditorView that received the event. |
| e | KeyEventArgs | The event data. |
RequestSelectionSession(IEditorView, CodeSnippetTypes)
Requests that an ICodeSnippetSelectionSession be opened for the specified IEditorView.
public bool RequestSelectionSession(IEditorView view, CodeSnippetTypes snippetType)
| Parameter | Type | Description |
|---|---|---|
| view | IEditorView | The IEditorView that will host the session. |
| snippetType | CodeSnippetTypes | A CodeSnippetTypes indicating the type of code snippets to include. |
Returns
- bool:
trueif a session was opened; otherwise,false.
RequestTemplateSession(IEditorView, ICodeSnippet)
Requests that an ICodeSnippetTemplateSession be opened for the specified IEditorView.
public bool RequestTemplateSession(IEditorView view, ICodeSnippet codeSnippet)
| Parameter | Type | Description |
|---|---|---|
| view | IEditorView | The IEditorView that will host the session. |
| codeSnippet | ICodeSnippet | The ICodeSnippet template to use. |
Returns
- bool:
trueif a session was opened; otherwise,false.
Inherited Members
- object.GetType()
- object.MemberwiseClone()
- object.ToString()
- object.Equals(object)
- object.Equals(object, object)
- object.ReferenceEquals(object, object)
- object.GetHashCode()