Custom Intellisense Extension

22,009

So in Visual Studio 2010 and later, the extensibility APIs you want to at are under the Microsoft.VisualStudio.Languages.IntelliSense namespace. At a high level, you want to MEF export a ICompletionSourceProvider which will provide the items you need. There are two good blog posts here and here that demonstrate the basic technique.

There are two problems that you'll run into if you wanted to make your screenshot be a reality. (This is why I asked for the scenario, as my advice here would change.) First, this method doesn't legally let you append to an existing completion set, but rather provide a new one. In the UI this appears as two tabs, like the Common/All tabs in the Visual Basic editor. This is a limitation of the current API. You could try to modify one of the existing completion sets in your AugmentCompletionSource but I have no idea if that'd work. It's definitely unsupported, in any case.

Second, it's really hard to know when and where to recommend things. In your example, you said "the IntelliSense for string". Sadly, there aren't any APIs (currently) in VS that let you know what the thing before the dot is. You could do some simple heuristics or try implementing some parser that is Good Enough™ for your scenario, but you'll have to accept for now that you won't have perfect results.

The Roslyn project aims to fix the second issue, so you may find it useful to explore a bit further. Since we expect that lots of people will want to extend completion, we're also thinking about offering other extensibility APIs so you don't have to roll a ICompletionSourceProvider from scratch, but such APIs are not in the current CTP.

[Disclaimer: I'm a member of the Roslyn team who works on IntelliSense.]

Share:
22,009
undefined
Author by

undefined

I have been increasingly saddened and disheartened by the recent goings on at stack exchange. It is clear to me that we the community are not valued, or given the dignity due our contributions to the success of their network, instead we are given platitudes and non apologies. When the community showed strong opposition they simply deleted the question. Its pretty clear to me we are not their people, we are not loved. As a result I have decided to stop contributing, voting, using jobs, and viewing ads across stack exchange. I do not want to support SE in any way as a company. I am also actively looking for alternative communities in which to participate. If you think that you have a good alternative, email me at staticvoid.co.nz. Why must you destroy those who speak out against you? כִּי רִיב לַיהוָה, עִם-יוֹשְׁבֵי הָאָרֶץ--כִּי אֵין-אֱמֶת וְאֵין-חֶסֶד וְאֵין-דַּעַת אֱלֹהִים, בָּאָרֶץ אָלֹה וְכַחֵשׁ, וְרָצֹחַ וְגָנֹב וְנָאֹף; פָּרָצוּ, וְדָמִים בְּדָמִים נָגָעוּ

Updated on January 29, 2020

Comments

  • undefined
    undefined about 4 years

    I am wanting to write an addition to intellisense in Visual Studio.

    Is it possible to extend at all, from my research I haven't found any samples or documentation on intellisense extensions.

    How can I get intellisense to show a simple HelloWorld message like the following (where hello world is added at run time to the intellisense for String):

    enter image description here