Intellisense and Browsing with C++0x

Intellisense and Browsing with C++0x

  • Comments 12

Hello Everyone,

My name is Sunny Gupta and I am a SDET on VC++ IDE & Compiler team. In this blog I will be talking about the IDE support for Cpp0x.

 

What is C++0x??

C++0x is the name for the next version of the C++ Programming Language Standard.  For VC 10, the C++ 0x features that have been implemented in the compiler so far are “auto”, “lambdas”, “rvalue references”, “decltype”, “nullptr” and “static_assert”.

Details about these can be read from:

·          Lambda-auto-static_assert

·         Rvalue-reference

·         Decltype

 

It will be super cool if the IDE could provide Intellisense and Browsing for all these new features, is VS team going to do that?

-          Yes, Beta2 is going to have all the intellisense and browsing functionality for these c++ language changes.

 

Brief Overview of what to expect.

Before I explain the details of feature I would like to list the cool things.

·         A static_assert getting squiggled (red wavy underline under the word indicating some error) with the assert message as the error message.

·         Getting parameter help(tool tip about the parameter of the lambda) on lambdas

·         Quick info(tool tip that pops up on mouse hove) showing the actual type of an object that is declared using auto

·         Complete intellisense for rvalue references as lvalue reference.

·         Quick info, Auto Complete etc ., working inside the decltype statement.

 

Outline of the Feature

The feature can be better explained with the help of some screenshots: I will be demonstrating just few of the many intellisense/browsing options available.

 

Design and Development of the feature

We had one main goal while designing this feature. That goal was intellinsense parity for cpp0x with all the other cpp constructs. We had the following things in mind during designing the feature:

·         Writing and using lambda should be as easy as writing and using a regular C++ function.

·         Intellisense on an object declared using ‘auto’ or ‘decltype’ should be the same if the object was declared using the actual type name

·         Writing a static assert should be as easy as making a function call to some inbuilt function.

·         Intellisense for rvalue reference should behave the same was as it used to behave for an lvalue reference

 

Development involved integration of the new cpp0x features with the current intellisense engine. The challenging part was ensuring the IDE shows the expected intellisense and browses to the correct location. Example: Ensuring that on the IDE a lambda is represented as a function with return type and arguments. Lambdas are actually classes with overloaded operator (). So a lambda statement internally creates a class with overloaded operator (). During development just integrating the cpp0x with the intellisense engine would results into lambda being represented as ‘operator ()’ in the tooltips. Instead of lambda name. We had to makes sure where ever the lambda will be shows, class view, Quick info, Call Hierarchy etc., it should not be displayed as ‘operator()’ and a proper readable signature should be shown.

 

 

Testing

I was the QA for the feature. Since this was not an isolated feature, the challenging part was to ensure complete intellinsense and browsing functionality inside the IDE for these new c++ language features. Dedicated testing was needed for browsing (Quick Symbol Search, Class View, Navbar, Gotodef etc.) and intellisense (Quick Info, Auto Complete, parameter help and squiggles). This feature is an IDE feature so equal importance was given to IDE testing along with the engine level testing.  

Example of an IDE tests is: Ensuring that on mouse hover over a static assert squiggle shows the correct error message tool tip.

Example of an Engine level test: ensuring that the Intellisense compiler API returns correct intellisense results. These API are called from the editor to display the results.

More information on testing can be gained from the blog : Testing VC++ Compiler and Intellisense

 

Customer Impact & Summary

Having this will enable customer to easily and accurately use cpp0x. Since cpp0x inevitable creates a thin level of wrapping on the underlying Cpp implementation, having intellisense and browsing will ensure better readability of the code. It would be a pity if such great C++ features are not used because the IDE is not intelligent enough to help the programmer navigate their complexity.  With the changes we have made to the IDE and IntelliSense engine, we certainly hope we have taken care of that problem.  We are excited about these new features and we hope you will like them too.

  • As someone who still spends 70% of their time working in unmanaged C++ this is all great stuff and while my heart belongs to managed code, the investment you folks appear to me making in C++ is *greatly* appreciated. Any news on when we might expect the next public (post beta) build of Visual Studio 2010?

  • I once read that nullptr was not going to be included in VC2010. Have you implemented it? Would be really nice :)

  • 'nullptr' is already there for testing references in C++/CLI. For example:

    Microsoft::VisualC::MFC::IView^ view = dynamic_cast<Microsoft::VisualC::MFC::IView^>(GetControl());

    if(view != nullptr)

      view->OnInitialUpdate();

    I presume you mean in *native* C++?

  • Is there already a date for the VS2010 Beta 2 release?

  • It would be nice if intellisense could:

    a)Remove defaulted template types

    => std::vector< int >

    b)Use the specific dependant type when known => void pushback( const int& )

    c)Not leak implementation details =>

    std:vector< int >::iterator

  • Yes , I meant "nullptr" for native C++, will it be implemented?

  • Why doesn't Visual Studio include int , void ,char , return , #define , #include etc.. in Intellisense

  • @Sandeep:

    Thank you for the feedback.  While we can't make any promises at this time, we do acknowledge that it is definitely useful to have IntelliSense for keywords and preprocessor directives like the ones you mentioned.

  • I second Ian's comments. If it could do those three things I might even consider using Visual Studio...

  • A somewhat unrelated question regarding possible new features.

    I have previously asked whether VC10 will have range-based for loop (from C++0x, not the existing "for each"). The answer was no, and the rationale given was that it depends on concepts, which aren't being implemented.

    Well, now concepts are gone, and range-based for has been revised to remove the dependency (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2930.html), and the modified version seems to be very close to how "for each" already works, except that it uses std::begin and std::end rather than member begin/end functions directly.

    Does this mean there's a possibility that range for will be supported in this release?

  • [pminaev]

    > Does this mean there's a possibility that range for

    > will be supported in this release?

    Unfortunately, no. If the range-based for-loop had been deconceptified earlier, then we might have been able to weasel it into VC10. But at this point - long after the release of Beta 1 - it's too late. For comparison, rvalue references v2 happened uncomfortably late for us to deal with them in VC10 (they're checked in and working fine now, but it took a while).

    The good news is that now we're much more likely to get the range-based for-loop sooner rather than later.

  • > The good news is that now we're much more likely to get the range-based for-loop sooner rather than later.

    Does this hint at "VS11 rather than VS12", or at "feature pack rather than next major release"? ;)

Page 1 of 1 (12 items)