{"id":5123,"date":"2008-02-29T12:49:00","date_gmt":"2008-02-29T12:49:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/vcblog\/2008\/02\/29\/intellisense-part-2-the-future\/"},"modified":"2019-02-18T18:54:10","modified_gmt":"2019-02-18T18:54:10","slug":"intellisense-part-2-the-future","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/cppblog\/intellisense-part-2-the-future\/","title":{"rendered":"IntelliSense, Part 2 (The Future)"},"content":{"rendered":"<p class=\"MsoNormal\"><font face=\"Calibri\" size=\"3\">Hi, Jim Springfield again.<span>&nbsp; <\/span>This post covers our current work to fundamentally change how we implement Intellisense and code browsing for C++ in Visual Studio 10.<span>&nbsp; <\/span>I previously covered the history of Intellisense and outlined many of the problems that we face.<span>&nbsp; <\/span>See here <\/font><a href=\"http:\/\/blogs.msdn.com\/vcblog\/archive\/2007\/12\/18\/intellisense-history-part-1.aspx\"><font face=\"Calibri\" size=\"3\">http:\/\/blogs.msdn.com\/vcblog\/archive\/2007\/12\/18\/intellisense-history-part-1.aspx<\/font><\/a><font face=\"Calibri\" size=\"3\"> for that posting and more detailed information.<\/font><\/p>\n<p class=\"MsoNormal\"><font face=\"Calibri\" size=\"3\">As Visual C++ has evolved over the years there has been tension between getting code information quickly and getting it accurately.<span>&nbsp; <\/span>We have moved from fast and not very accurate to sometimes fast and mostly accurate in Visual Studio 2008.<span>&nbsp; <\/span>The main reason for the slowness has been the need to reparse .cpp files when a header is changed.<span>&nbsp; <\/span>For large projects with some common headers, this can mean reparsing just about everything when a header is edited or a configuration or compile option is changed.<span>&nbsp; <\/span>We are mostly accurate except that we only capture one parse of a header file even though it could be parsed differently depending on the .cpp that includes it (i.e. different #defines, compile options, etc).<\/font><\/p>\n<p class=\"MsoNormal\"><font face=\"Calibri\" size=\"3\">For Visual Studio 10, which is the next release after Visual Studio 2008, we are going to do a lot of things differently.<span>&nbsp; <\/span>For one, the NCB file is being eliminated.<span>&nbsp; <\/span>The NCB file was very similar to a BSC file and the IDE needed to load the entire thing into memory in order to use it.<span>&nbsp; <\/span>It was very hard to add new features to it (i.e. template support was bolted on) and some lookups required walking through a lot of information.<span>&nbsp; <\/span>Instead of this, we will be using SQL Server Compact for our data store.<span>&nbsp; <\/span>We did a lot of prototyping to make sure that it was the right choice and it exceeded our expectations.<span>&nbsp; <\/span>Using Compact will allow us to easily make changes to our schema, change indexes if needed, and avoid loading the entire thing into memory.<span>&nbsp; <\/span>We currently have this implemented and we are seeing increased performance and lower memory usage.<\/font><\/p>\n<p class=\"MsoNormal\"><i><font size=\"3\"><font face=\"Calibri\">SQL Server&nbsp;Compact is an in-process version of SQL that uses a single file for the storage.<span>&nbsp; <\/span>It was originally developed for Windows CE and is very small and efficient, while retaining the flexibility of SQL.<\/p>\n<p><\/font><\/font><\/i><\/p>\n<p class=\"MsoNormal\"><font face=\"Calibri\" size=\"3\">Also, there is a new parser for populating this store.<span>&nbsp; <\/span>This parser will perform a file-based parse of the files in the solution in a way which is independent of any configuration or compile options and does not look inside included headers.<span>&nbsp; <\/span>Because of this, a change to a header will not cause a reparse of all the files that include it, which avoids one of the fundamental problems today.<span>&nbsp; <\/span>The parser is also designed to be extremely resilient and will be able to handle ambiguous code, mismatched braces or parentheses, and supports a &ldquo;hint&rdquo; file.<span>&nbsp; <\/span>Due to the nature of C\/C++ macros and because we aren&rsquo;t parsing into headers, there is good bit of code that would be misunderstood.<span>&nbsp; <\/span>The hint file will contain definitions for certain macros that fundamentally change the parsing and therefore understanding of a file.<span>&nbsp; <\/span>As shipped, the hint file will contain all known macros of this type from the Windows SDK, MFC, ATL, etc.<span>&nbsp; <\/span>This can be extended or modified and we are hoping to be able to identify potential macros in the source code.<span>&nbsp; <\/span>Since we will be looking at every header, we want to be able to propose recommended additions to the hint file.<\/font><\/p>\n<p class=\"MsoNormal\"><font face=\"Calibri\" size=\"3\">However, this style of parsing means that we don&rsquo;t get completely accurate information in all cases, which is especially desirable in the Intellisense scenarios of auto-complete, parameter info, and quick info.<span>&nbsp; <\/span>To handle this, we will be doing a full parse of a translation unit (i.e. .cpp file) when it is opened in the IDE.<span>&nbsp; <\/span>This parse will be done in the fullest sense possible and will use all compile options and other configuration settings.<span>&nbsp; <\/span>All headers will be included and parsed in the exact context that they are being used for.<span>&nbsp; <\/span>We believe we can do this initial parse for most translation units very quickly with most not taking more than a second or two.<span>&nbsp; <\/span>It should be comparable to how long it takes to actually compile that translation unit today, although since we won&rsquo;t be doing code-generation and optimization, it should be faster than that.<span>&nbsp; <\/span>Additionally, this parse will be done in the background and won&rsquo;t block use of the IDE.<span>&nbsp; <\/span>As changes are made to the .cpp or included headers, we will be tracking the edits made and incrementally reparsing only those bits that need to be parsed.<\/font><\/p>\n<p class=\"MsoNormal\"><font face=\"Calibri\" size=\"3\">The database created from the file-based parse will be used for ClassView, CodeModel, NavBar, and other browsing based operations.<span>&nbsp; <\/span>In the case of &ldquo;Find All References&rdquo;, the database will be used to identify <i>possible<\/i> candidates and the full parser will then be used to positively identify the actual references.<\/font><\/p>\n<p class=\"MsoNormal\"><font face=\"Calibri\" size=\"3\">We have also been thinking about some longer term ideas that build on this.<span>&nbsp; <\/span>This includes using a full SQL server to store information about source code, which multiple people can use.<span>&nbsp; <\/span>It would allow you to lookup code that isn&rsquo;t even on your machine.<span>&nbsp; <\/span>For example, you could do a &ldquo;goto definition&rdquo; in your source and be taken to a file that isn&rsquo;t even on your machine.<span>&nbsp; <\/span>This could be integrated with TFS so that the store is automatically updated as code is checked in, potentially even allowing you to query stuff over time.<span>&nbsp; <\/span>Another idea would b\ne to populate a SQL database with information from a full build of your product.<span>&nbsp; <\/span>This would include very detailed information (i.e. like a BSC file) but shared among everyone and including all parts of an application.<span>&nbsp; <\/span>This would be very useful as you could identify all callers of a method when you are about to make a change to it.<\/font><\/p>\n<p class=\"MsoNormal\"><font face=\"Calibri\" size=\"3\">What are your ideas if you had this type of information?<span>&nbsp; <\/span>Let us know!<\/font><\/p>\n<p class=\"MsoNormal\"><font face=\"Calibri\" size=\"3\">Jim Springfield<\/font><\/p>\n<p class=\"MsoNormal\"><font face=\"Calibri\" size=\"3\">Visual C++ Architect<\/font><\/p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hi, Jim Springfield again.&nbsp; This post covers our current work to fundamentally change how we implement Intellisense and code browsing for C++ in Visual Studio 10.&nbsp; I previously covered the history of Intellisense and outlined many of the problems that we face.&nbsp; See here http:\/\/blogs.msdn.com\/vcblog\/archive\/2007\/12\/18\/intellisense-history-part-1.aspx for that posting and more detailed information. As Visual C++ [&hellip;]<\/p>\n","protected":false},"author":289,"featured_media":35994,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-5123","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cplusplus"],"acf":[],"blog_post_summary":"<p>Hi, Jim Springfield again.&nbsp; This post covers our current work to fundamentally change how we implement Intellisense and code browsing for C++ in Visual Studio 10.&nbsp; I previously covered the history of Intellisense and outlined many of the problems that we face.&nbsp; See here http:\/\/blogs.msdn.com\/vcblog\/archive\/2007\/12\/18\/intellisense-history-part-1.aspx for that posting and more detailed information. As Visual C++ [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/5123","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/users\/289"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/comments?post=5123"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/5123\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/media\/35994"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/media?parent=5123"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/categories?post=5123"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/tags?post=5123"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}