Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to extend IntelliSense items?

I would like to manually extend the IntelliSense list by various items. I want to be responsible for the action triggered by the item (i.e. code completion and tooltip info). It doesn't matter what items.

Is this possible with an VisualStudio add-in, ReSharper / DXCore or any otherg plugin?

Background:

Some of you may know FOP (feature-oriented programming). FOP would require various changes to intellisense and editor behavior.

Edit:

Another interesting post.

like image 616
Matthias Avatar asked Feb 03 '12 18:02

Matthias


People also ask

How do I change my IntelliSense settings?

Use the IntelliSense options page to modify settings that affect the behavior of IntelliSense for C#. To access this options page, choose Tools > Options, and then choose Text Editor > C# > IntelliSense.

How do you rebuild IntelliSense?

In Visual Studio 2022, open Tools -> Options -> [type in "database" in the search box] -> Text Editor -> C/C++ -> Advanced -> Recreate Database = TRUE, and then reopen the solution. Save this answer.

How do I fix my IntelliSense problem?

If you find IntelliSense has stopped working, the language service may not be running. Try restarting VS Code and this should solve the issue. If you are still missing IntelliSense features after installing a language extension, open an issue in the repository of the language extension.

How do I extend Visual Studio code?

You can browse and install extensions from within VS Code. Bring up the Extensions view by clicking on the Extensions icon in the Activity Bar on the side of VS Code or the View: Extensions command (Ctrl+Shift+X).


2 Answers

This is definitely doable very easily by writing a ReSharper plugin.

  • Start by implementing ICodeCompletionItemsProvider which will provide additional IntelliSense items. The easiest way is to inherit from ItemsProviderOfSpecificContext<TContext> (with TContext being CSharpCodeCompletionContext if you're interested in C# code completion).

  • Your provider will add the additional items in the implementation of AddLookupItems(). You have the chance to provide a custom implementation of ILookupItem here: the Accept() method of this interface will be called when the user chooses the item in the completion popup. Here is your chance to execute the code you need.

Note that this information is for R# 6.1/7.0. I don't think it is much different in previous versions though. Obviously, you have to enable ReSharper IntelliSense instead of Visual Studio IntelliSense for this to work.

like image 121
Julien Lebosquain Avatar answered Oct 12 '22 02:10

Julien Lebosquain


Customized intelliSense for VS2010 XML editor can be added by putting customized xsd files in C:\Program Files\Microsoft Visual Studio 10.0\Xml\Schemas folder but I guess you are looking for something more.

You should take a look at Creating and Using IntelliSense Code Snippets and decide whether it is what you are looking for. This question on programmers.stockexchange might also be helpful. This question also seems similar which suggests CSharpIntellisensePresenter(Free).

like image 32
Sajib Mahmood Avatar answered Oct 12 '22 03:10

Sajib Mahmood