Example #1
0
        public override void Init()
        {
            try
            {
                Declaration declarationNode = this.SimpleDeclaration.DeclarationNode;

                if (declarationNode != null)
                {
                    CppDeclarationSymbol symbol = declarationNode.GetSymbol();

                    if (symbol != null)
                    {
                        ICppParserSymbol parentSymbol = symbol.Parent;

                        CppQualifiedName parentQualfiedName = parentSymbol.GetQualifiedName();
                        string           parentQualName     = parentQualfiedName.GetNameStr();

                        string parentShortName = parentSymbol.GetShortName();

                        ICppParserSymbol classByMemberSymbol = parentSymbol.GetClassByMember();

                        string classByMemberShortName = classByMemberSymbol.GetShortName();

                        ICppParserSymbol enclosingClassSymbol = parentSymbol.GetEnclosingClass(true);
                        CppQualifiedName qualifiedInnerName   = parentSymbol.GetQualifiedInnerName();

                        CppQualType cppQualType = symbol.GetDeclSpecType();
                        string      debugStr    = cppQualType.DbgDescription;

                        CppTypeVisitor cppTypeVisitor = new CppTypeVisitor();


                        if (cppQualType.RefFlag != ReferenceFlag.Empty)
                        {
                            cppQualType.Accept(cppTypeVisitor);

                            string typeStr = cppTypeVisitor.TypeStr;
                            string dbgStr  = cppTypeVisitor.DbgStr;

                            this.ItemName = cppTypeVisitor.Name;

                            switch (cppTypeVisitor.CppType)
                            {
                            case CppTypeVisitorType.Class:
                                this.PenWebDeclarationType = PenWebDeclarationType.ClassDef;
                                break;

                            case CppTypeVisitorType.Enum:
                                this.PenWebDeclarationType = PenWebDeclarationType.EnumDef;
                                break;

                            default:
                                break;
                            }
                        }

                        /*
                         * CppQualifiedName cppQualifiedName = symbol.GetQualifiedName();
                         *
                         * ICppQualifiedNamePart namePart = cppQualifiedName.Name;
                         *
                         * string partStr = namePart.ToString();
                         *
                         * var subQualifier = cppQualifiedName.Qualifier;
                         *
                         * string qualiferStr = subQualifier.GetNameStr();
                         */


                        if (!String.IsNullOrWhiteSpace(this.ItemName))
                        {
                            Console.WriteLine("");
                        }
                    }
                    else
                    {
                        LogManager.Self.Log($"PenWebSimpleDeclaration() declarationNode.symbol is null");
                    }

                    ICppResolvedTypeFactory cppResolvedTypeFactory = declarationNode.GetTypeFactory();

                    if (cppResolvedTypeFactory != null)
                    {
                        cppResolvedTypeFactory.GetIdentityTypeVisitor();
                    }
                }
                else
                {
                    LogManager.Self.Log($"PenWebSimpleDeclaration() declarationNode is null");
                }


                /*
                 * CompoundStatement compoundStatement = this.SimpleDeclaration.CompoundStatementNode;
                 *
                 * if (compoundStatement != null)
                 * {
                 *
                 * }
                 *
                 * CtorInitializer ctorInitializer = this.SimpleDeclaration.ConstructorInitializerNode;
                 *
                 * if (ctorInitializer != null)
                 * {
                 *
                 * }
                 *
                 * DefaultSpecifier defaultSpecifier  = this.SimpleDeclaration.DefaultSpecifierNode;
                 *
                 * if (defaultSpecifier != null)
                 * {
                 *
                 * }
                 *
                 * CtorBlock constructorBlock = this.SimpleDeclaration.ConstructorBlock;
                 *
                 * ITreeNode simicolonNode = this.SimpleDeclaration.SemicolonNode;
                 *
                 * ITreeNode trailingNode = this.SimpleDeclaration.TrailingNode;
                 */


                base.Init();

                //this.SaveToJson = true;
            }
            catch (Exception e)
            {
                LogManager.Self.Log("PenWebSimpleDeclaration Exception", e);
            }

            this.SimpleDeclaration = null;
        }
Example #2
0
        public override void Init()
        {
            try
            {
                CppDeclarationSymbol symbol = this.Declaration.GetSymbol();

                if (symbol != null)
                {
                    this.VariableName = symbol.GetQualifiedName().GetNameStr();
                }
                else
                {
                    LogManager.Self.Log($"PenWebDeclaration() symbol is null");
                }

                AttributeList attributeList = this.Declaration.AttributeListNode;

                if (attributeList != null)
                {
                    foreach (ITreeNode attribute in attributeList.Children())
                    {
                        var typeId   = attribute.NodeType.ToString();
                        var toString = attribute.ToString();
                    }
                }

                base.Init();

                HierarchySnapshot hierarchySnapshot = new HierarchySnapshot(this);

                PenWebDeclarator penWebDeclarator = this.GetChildByType <PenWebDeclarator>();

                if (penWebDeclarator != null)
                {
                    this.VariableName = penWebDeclarator.ItemName;
                }
                else
                {
                    LogManager.Self.Log($"penWebDeclarator is null");
                }

                if (String.IsNullOrWhiteSpace(this.VariableName))
                {
                    PenWebDeclaratorQualifiedName declaratorQualifiedName = this.GetChildByType <PenWebDeclaratorQualifiedName>();

                    if (declaratorQualifiedName != null)
                    {
                        this.VariableName = declaratorQualifiedName.ItemName;
                    }
                    else
                    {
                        LogManager.Self.Log($"declarationSpecifiers is null");
                    }
                }

                PenWebDeclarationSpecifiers declarationSpecifiers = this.GetChildByType <PenWebDeclarationSpecifiers>();

                if (declarationSpecifiers != null)
                {
                    this.TypeName = declarationSpecifiers.ItemName;
                }
                else
                {
                    LogManager.Self.Log($"penWebDeclarator is null");
                }

                PenWebClassSpecifier penWebClassSpecifier = this.GetParentByType <PenWebClassSpecifier>();

                if (penWebClassSpecifier != null)
                {
                    this.OwningClass = penWebClassSpecifier.ClassName;
                }

                this.CppFunctionCatagory = CppFunctionCatagory.VariableDef;

                if (!String.IsNullOrWhiteSpace(this.TypeName) && !String.IsNullOrWhiteSpace(this.VariableName) && !String.IsNullOrWhiteSpace(this.OwningClass))
                {
                    this.SaveToJson = true;
                }
            }
            catch (Exception e)
            {
                LogManager.Self.Log("PenWebDeclaration Exception", e);
            }

            this.Declaration = null;
        }