Quantcast
Channel: Visual Studio Integrate forum
Viewing all articles
Browse latest Browse all 4410

How get nested vc enum class code element's container vc class code element

$
0
0

Recently, I was working on my visual studio package using VCCodeModel for automation. However, I want to get a nested vc enum class's container vc class, but I found that the VCCodeEnum's parent is a object of VCCodeNamespace. How could I get  its container class code element.

The following is the step I were trying to access the container code element.
VC target code:

namespace NS{
    class Container{
        enum class Nested{
            A,
            B};};}


C# code behind:

Firstly, set cursor inside the nested enum class,  get current TextPoint from active document.

Secondly, get CodeElement from TextPoint which returns a VCCodeEnum (Nested) or VCCodeVariable (A or B) (call parent to get VCCodeEnum (Nested)).

Thirdly, call the VCCodeEnum's parent to get the direct parent but finally return a VCCodeNamespace object (NS).


Precondition=>set cursor inside a nested enum class (Nested)

Purpose=>get container code element (NS)


If the current design builtin API for CodeElement is able to  access nested CodeElement's container CodeElement, what should I do? If not, any other solutions?


msdn 论坛回复






Viewing all articles
Browse latest Browse all 4410

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>