In This Article

Sessions

An IntelliPrompt session is essentially a controller for a certain type of IntelliPrompt UI. Each type of IntelliPrompt UI (completion list, quick info, etc.) has a related session. The IntelliPrompt UI and functionality can be activated by "opening" the related session.

Built-In Sessions

IntelliPrompt functionality is active only while related sessions are open. For instance, a completion list is displayed only while its session is open.

SyntaxEditor includes several built-in IntelliPrompt sessions, however you can create your own as well.

These sessions are currently included:

Provider Language Services for Built-In Sessions

There are several provider interfaces that can be registered as language services. These providers make it very easy to respond to certain editor events and respond with the appropriate IntelliPrompt sessions.

These providers are currently included:

Session Types

Each IntelliPrompt session must be associated with a specific session type. A session type is represented by the IIntelliPromptSessionType interface.

This interface requires that each type specify a unique string-based Key that identifies it. It also has an AreMultipleSessionsAllowed property that returns whether more than one session of that type are permitted at a time. If that property is false and a second session of the same types is added to the manager (see below), the first session will be removed.

The IntelliPromptSessionType class implements IIntelliPromptSessionType and can be used if you need to create your own session type.

Tip

The IntelliPromptSessionTypes class has a number of static properties that return the most common IIntelliPromptSessionType instances such as session types for Quick Info, Completion List, etc.

Opening and Closing Sessions

When a session is "open", it is active within the user interface. The IIntelliPromptSession.IsOpen property indicates if a session is currently open.

A session can be opened by calling the Open method. This method accepts two parameters: the IEditorView in which the session should be opened and the TextRange in the view that is affected by the session. The text range is most often the selection range or the text range of the word surrounding the caret.

When a session opens, its Opened event is raised.

Note

Some session implementations may add additional Open method overloads that should be used for that session implementation instead of the basic Open method.

A session can be closed by calling the Close method. This method accepts a Boolean parameter that indicates whether the session was cancelled or not.

When a session opens, its Closed event is raised. The event arguments of this event specify whether the session was cancelled.

Session Information

Each IIntelliPromptSession contains these members that provide some useful information about the session:

Member Description
SessionType Property Gets the IIntelliPromptSessionType that identifies the type of session.
SnapshotRange Property Gets the TextSnapshotRange containing the original TextRange in the ITextSnapshot that triggered the session. This member should only be used while the session is open.
View Property Gets the IEditorView in which the session is opened. This member should only be used while the session is open.

Managing Sessions at Run-Time

The SyntaxEditor class has a IntelliPrompt property that is of type IIntelliPromptManager and provides access to all of the open sessions within the SyntaxEditor.

The Sessions collection lists all the open sessions and can be enumerated.

The CloseAllSessions method closes all open sessions, while the CloseSessions member only closes sessions of a particular IIntelliPromptSessionType.

Requesting Built-In IntelliPrompt Session Types

Sometimes you may wish to programmatically request that a certain type of IntelliPrompt session be opened, but you want the current set of IntelliPrompt providers (generally designated from language services) to decide if an IntelliPrompt session should open and what should be in it. An example scenario is if your language checks to see when the . character is typed via an event sink service. When that event occurs, it raises a request to see if an IntelliPrompt completion session should open.

The IEditorView.IntelliPrompt object has methods for requesting built-in session types:

Member Description
RequestAutoComplete Method Performs an auto-complete if the language supports an IntelliPrompt completion session at the current offset.
RequestCompletionSession Method Displays a completion list if the language supports an IntelliPrompt completion session at the current offset.
RequestInsertSnippetSession Method Displays IntelliPrompt "expansion" code snippet selection at the current offset.
RequestParameterInfoSession Method Displays IntelliPrompt parameter info based on the current context.
RequestQuickInfoSession Method Displays IntelliPrompt quick info based on the current context.
RequestSurroundWithSession Method Displays IntelliPrompt "surrounds with" code snippet selection at the current offset.