private static void RegisterType()

in EnvDTE.Host/Callback/Util/PsiElementRegistrar.cs [37:71]


        private static void RegisterType<TPsi>(int id) where TPsi : ITreeNode =>
            KnownPsiTypes.Add((typeof(TPsi), id));

        /// <summary>
        /// Elements that have not been registered are ignored by default.
        /// However, it is sometimes interesting to replace the entire element with its children.
        /// That is the case, for example, for namespaces and classes. The PSI structure of them is the following:
        /// INamespaceDeclaration("ConsoleApplication1")
        ///     INamespaceBody
        ///         IClassDeclaration("Class1")                    (?)
        ///         IClassDeclaration("Class2")
        /// The EnvDTE structure of them is the following:
        /// CodeNamespace("ConsoleApplication1")
        ///     CodeClass("Class1")
        ///     CodeClass("Class2")
        /// </summary>
        private static void ReplaceWithChildren<TType>() => TypesToReplaceWithChildren.Add(typeof(TType));

        static PsiElementRegistrar()
        {
            RegisterType<ICSharpNamespaceDeclaration, INamespace>(1);
            RegisterType<IClassDeclaration, IClass>(ClassDeclarationId);
            RegisterType<IStructDeclaration, IStruct>(3);
            RegisterType<IInterfaceDeclaration, IInterface>(4);
            RegisterType<IFunctionDeclaration, IFunction>(5);
            RegisterType<IParameterDeclaration, IParameter>(6);
            RegisterType<IAttribute>(7);

            ReplaceWithChildren<INamespaceBody>();
            ReplaceWithChildren<IClassBody>();
            ReplaceWithChildren<IFormalParameterList>();
            ReplaceWithChildren<IAttributeSection>();
            ReplaceWithChildren<IAttributeSectionList>();
            ReplaceWithChildren<IAttributeList>();
        }