How to extend IntelliSense items?
Asked Answered
H

3

16

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.

Heraldic answered 3/2, 2012 at 18:49 Comment(2)
I guess the scope of what you're trying to do isn't solved by Extension Methods? msdn.microsoft.com/en-us/library/bb383977.aspx Thought I'd ask, just to make sure...Ium
If you're looking to change the behaviour of the IDE, then you're certainly looking at a plugin. If what you want to do can be done within the R# plugin framework, then that would be easier than writing your own VS plugin, but the latter is certainly doable.Isometropia
T
17

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.

Trolley answered 10/2, 2012 at 19:1 Comment(0)
R
2

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).

Rubie answered 6/2, 2012 at 17:49 Comment(4)
@Fraser, That's why it was just a suggestion, not concrete solution. I asked him to take a look and decide. If you are sure that the snippets are totally useless you may edit my answer and remove that link. Or you may tell me that you are sure and I can remove the link. Thanks.Rubie
suggesting that he should take a look at something that is totally unrelated is why I gave -1, that is what down voting is for, marking down answers that are incorrect and show a lack of effort stackoverflow.com/privileges/vote-down if you had read the link you provided, that would have been obvious to you, no?Af
@Fraser, you can do whatever you think is right. BTW, What about the other links I have provided in my answer? Are those okay?Rubie
Here is step by step tutorial how to add custom autocomplete for your html wyndhamhudson.com/adding-custom-intellisense-to-visual-studio-2Diplomacy
W
0

Maybe ReSharper's Live Templates can help you (ReSharper->Live Templates...).

Waxwing answered 8/2, 2012 at 10:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.