VCFileCodeModel CodeElementFromPoint Problem RRS feed

  • Question

  • Hi,

    Does anyone notice that CodeElementFromPoint can not get the VCCodeClass from exactly the same text point  compared to Visual Studio IDE? The details can be represented as below:

    For given the VC Code as 

    #define DD(TYPE) private: TYPE value; 
    class AA
    	DD(unsigned short)
    I firstly set cursor at the third line inside the class name 'AA'. The the property window of IDE will show as

    However, when use VCFileCodeModel's CodeElementFromPoint for all values of vsCMElement, the function returns null as a result. Then when I remove the second line inside the class 'AA' which is 'DD(unsigned short)', the function returns a VCCodeClass representing the class 'AA'.
    Does the VC++ Package preinstalled in the IDE does a different VC Code Model for itself, otherwise how can I solve it? 

    IDE: VS2013 update 3

    Windows: Windows8.1

    VSSDK: VS2013 SDK

    msdn 论坛回复

    Saturday, September 20, 2014 7:55 AM

All replies

  • Hi Vincky,

    I've reproduced your problem, this could be a bug in VCCodeModel, I recommend that you submit a feedback in Microsoft Connect here:


    My guess is that the definer in C++ does not belong to any code model elements, the property window in VS IDE may only show the closest  or parent element, but not the current unknown element itself.

    #define Directive (C/C++)

    vsCMElement Enumeration

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, September 23, 2014 7:42 AM
  • Hi,

    As of VS 2013, the Visual Studio compilers don't use the automation code model (for example, the code model doesn't parse inside methods to get method constants and variables).

    The CodeElementFromPoint method is specially buggy. As a workaround you can iterate each code element of the file code model, get its start/end points and select the closest one to the desired location.

    Don't bother to report bugs to Microsoft about this (I have reported a few ones in the past). The true solution is to expose the internal parser/compilers of VS to extensions, which what the .NET Compiler Platform (formerly "Roslyn") is all about:


    Unfortunately VC++ is not included in the first previews, only C# and VB.NET.

    * My new blog about VSX: http://www.visualstudioextensibility.com * Twitter: https://twitter.com/VSExtensibility * MZ-Tools productivity extension for Visual Studio: http://www.mztools.com.

    Tuesday, September 23, 2014 3:33 PM
  • Hi Carlos,

    I had looked into the corresponding VCFileCodeModel's code elements while there is no class 'AA' including any child code element.

    msdn 论坛回复

    Tuesday, September 23, 2014 3:37 PM