Reputation: 539
I am curious to know how, visual studio (2010 onward) intellisense works on compiler errors.
I mean to say that, for example
or
How this intelligence is implemented?
How I can add my own rules, if I want to?
Any guidance/link will help?
Upvotes: 1
Views: 563
Reputation: 114822
Visual Studio employs different ways to surface these kinds of warnings and it depends on the language you're editing (C# vs C++ vs VB.NET etc) what technology is employed.
{
, the syntax definition knows that there must be a }
somewhere further along in the file, and thus these simple checks are done purely on the source code structure.Then there is a more advanced type of validation that can take place, one that actually takes in the context of all the parsed files and/or their binary representation. VB.NET for example employs
And then there are tools like Resharper and Code Rush which build up an in memory representation of the code. Visual Studio also builds up a similar model, though not as feature rich as these IDE productivity tools in many cases
And then there's the information that's added during build
Intellisense uses the data provides by the Visual Studio Language Service and by VSPackages and MsBuild to render the text in the editor. As you can see there are multiple ways in which such a result is gathered. The Visual Studio editor provides a number of extensibility points which you can use to add your own smart tags and adornments to the text.
Plus you have a number of 3rd party tools that provide similar functionality.
A great source for insights in how these things work, are the ASP.NET MVC editors for Visual studio or Python plugins for Visual Studio.
Upvotes: 1