How does intellisense work in Visual Studio?

Hope this is the right question: how does intellisense work in VS2008? I am for what is known about the algorithm that it uses to search for sentences when it pops up ("." Is just one obvious trigger), how its behavior can be changed, if at all possible, etc.

To put this question in context: The main problem I'm trying to solve is to activate and deactivate intellisense in parts of the editor’s screen and how to change where it searches to fill in the offer window.

All information is welcome.

+6
visual-studio intellisense
source share
8 answers

Take a look at the DIY Intellisense article on CodeProject.

+9
source share
However, it is more interesting to redesign it. Consider the problem:
  • you need to identify the words of interest
  • you need to find possible options.
  • you need to introduce them

Now the first step means you need to parse the code. You have C / C ** keywords, you pre-analyze various declarations of functions and classes and load them into some kind of data structure. Then you parse the code and save the names of classes, variables, etc. And put them in the same data structure.

The second step means that you need a data structure that can efficiently search for a partial word and get all the words that have this prefix. You can do this with regular expressions, but it is not very efficient. An effective data structure for such a search is the trie, which is discussed here on SO .

Once you have a list of features, you simply submit it. You probably want to keep a link to the root of the feature tree so that you can search for them in real time as someone types more letters.

+8
source share

Have you seen this thread in msdn?

+1
source share

Eclipse also has this feature, and it is an open source project. Why not check out how Eclipse does this by actually looking at the code?

0
source share

This question is too broad. Since there are many different languages, the VS IDE supports out of the box. And there are N DSL and IDE enhancement numbers that support alternate intellisense, this implies a series of answers. If you're talking about C #, see the "Tools | Variants | Text Editor | C # | Intellisense" section for the available completion options. As for the [s] algorithm, you would look for assembly metadata, abundant caching of type members, MRU list for the last member selected for a particular type, etc. If you have a more specific question, I would suggest you clarify.

See the DSL (ironpython) example and its implementation here .

0
source share

I have not seen a text editor in VS that limits the appearance of IntelliSense. It all depends on the language. If your cursor is at a point where IntelliSense can contribute to a valid token, this will be used.

I believe that there is some interaction with the project system used, but as far as I know. I also believe that there is a sample project in the Visual Studio SDK, and this may give you an idea.

0
source share

In such cases, I sometimes use my own version of InteliSense, which I developed for AutoHotKey when I need specific behavior. The point of this script is that it can be used with any editor or, basically, with any control that accepts text. It works by recording text input and interpreting it in a syntax file.

Perhaps you can use it as a basis for what you want to achieve. I have used ISense successfully with several languages ​​that do not have such a thing as Csound or even batch scripts. It will be possible to expand it to support C # using input monitoring in combination with Reflection.

In any case, with AHK you can even control VS intelissense by "taking" a list of the items it represents and filtering them, or similar things. You may have small problems with the boundaries of the process, but nothing can be fixed.

Intellisense ius, usually AFAIK, is implemented using different methods. I read that Delphi is so fast that it implements isense by recompiling the project on each token, and therefore the reason C ++ Builder does not make sense because its compilation is very slow.

0
source share

As for your way of changing what it looks like, the short answer is you cannot. Intellisense is mostly provided by reflecting the builds included in your project (and some other C ++ tricks). What you get is the result of processing VS through all the assemblies you assembled and all assemblies from the GAC.

However, if you want to provide explicit intellisense results from the project you are working on, see IVsContextualIntellisenseFilterProvider

Finally, for some insight into the process behind the scenes, check out this blog post.

0
source share

All Articles