Partager via


Supporting IntelliSense Complete Word (Managed Package Framework)

The IntelliSense Complete Word provides completion on a partially typed word. If the partial word matches more than one possibility, a list of the possibilities is displayed and the user may choose from the list. Otherwise, if there is only one possibility, the word is completed immediately when a completion character is typed. A completion character is typically any character not considered to be part of an identifier.

Implementation Steps

  1. When the user selects Complete Word from the IntelliSense menu, the COMPLETEWORD command is sent to the language service.

  2. The ViewFilter class catches the command and calls the Completion method on the Source class with the parse reason of CompleteWord.

  3. The Source class then handles all the details of calling the ParseSource method parser to get the list of possible word completions and then displaying those words in a tool tip list using the CompletionSet class.

    If there is only one matching word, the Source class automatically inserts the whole word.

An alternative to using the menu is if the scanner returns the trigger value MemberSelect when the first character of an identifier is typed. The base Source class detects this and calls the Completion method directly with the parse reason of MemberSelect. Note that this means the parser must detect the presence or absence of a preceding member selection character and provide a list of members accordingly.

Enabling Support for the Complete Word

You must set the CodeSense registry entry set to 1 to support any IntelliSense operation. You can set this registry entry with a named parameter passed to the ProvideLanguageServiceAttribute user attribute associated with the language package. The language service classes read the value of this registry entry from the EnableCodeSense property on the LanguagePreferences class.

If your parser returns a list of declarations in response to the parse reason value CompleteWord, then word completion is performed.

Implementing Complete Word in the ParseSource Method Parser

Since the implementation of the parser is entirely up to the developer of the language, only general guidelines can be given here as to how to use the AuthoringScope class. For the word completion process, the Source class calls the GetDeclarations method on the AuthoringScope class to obtain a list of possible word matches. How you implement the list is up to you, but you must implement the list in a class that is derived from the Declarations class; the methods on the Declarations class access the list one element at a time and thereby hide the details of the list's implementation. See the Declarations class for details on the methods you must implement.

If the list contains only a single word, then the Source class automatically inserts that word in place of the partial word. If the list contains more than one word, the Source class presents a tool tip list from which the user can select the appropriate choice.

Also look at the example of a Declarations class implementation in Supporting IntelliSense Member Completion (Managed Package Framework).

See Also

Concepts

Language Service Features (Managed Package Framework)

Supporting IntelliSense Member Completion (Managed Package Framework)