Visual C++ Code Model

Visual CPP Team

Hi, my name is Vytautas Leonavičius, and I’m recent addition to VC++ IDE dev team. My focus areas are VC Wizards and VC++ Code Model (CM). Today, I’d like to talk about future of the CM.

In a sentence (actually, two sentencesJ), the VC++ CM is a collection of classes that allows a client to get source code reflected in objects. Objects have read and write properties, so, for example, VCCodeClass.Name allows you to get the name of the class. It also allows you to rename a class by assigning a different value to Name property. More on the VC++ CM can be found in MSDN: http://msdn2.microsoft.com/en-us/library/t41260xs(VS.80).aspx

The VC++ CM is used by various Visual Studio components. In particular, VC++ Wizards and Class Designer use it. Such an architecture greatly simplifies those components by deferring source code manipulations to the CM.

Currently C++ Intellisense, Class View, CM and other components use the NCB as an underlying database. As Jason mentions in his post http://blogs.msdn.com/vcblog/archive/2006/08/16/thoughts-on-the-visual-c-abstract-syntax-tree-ast.aspx , in VC10, we’re moving to a new architecture. We’re expecting to improve the following aspects of CM:

·         As CM is based on NCB today, it has to do additional C++ code parsing. This is primarily caused by a limitation of NCB architecture, where no column information is provided for source code elements (a C++ program can be written in one line). The new architecture will provide column information. Methods doing a lot of text processing, like VCCodeElement.StartPointOf, will become faster.

·         The NCB had not been originally designed to support templates and namespaces. Although NCB supports both today, the support is far from perfect. That causes processing overhead in the VC++ CM and various correctness issues. The new architecture is designed from scratch and takes into account modern C++ coding realities.

·         The NCB contains a snapshot of source code in one macro state. That means, if we have code like:

#define X

 

#ifdef X

class A {};

#else

class B {};

#endif

only class A will make it to NCB. The new architecture is based on different principles. The database will contain both definitions and the CM will be able to provide a true reflection of source code in this scenario.

·         VCCodeElement.CodeElementFromFullName/ VCCodeElement.CodeTypeFromFullName will support wildcards.

·         We expect VCCodeModel.Synchronize to become faster, because population of the underlying database is going to be based on different principles than it is today.

The VC++ team is looking forward to hear your feedback. Any suggestions, comments and feedback about what we can do to make VC++ Code Model better are welcome.

Vytas/Visual C++

 

0 comments

Discussion is closed.

Feedback usabilla icon