示例#1
0
        private static void ExtractClassFromTreeTypeDeclaration(TypeDeclarationContext tmpElement, ClassContainer tmpClass)
        {
            for (var tmpI = 0; tmpI < tmpElement.ChildCount; tmpI++)
            {
                var tmpChild = tmpElement.GetChild(tmpI);
                var tmpType  = tmpChild.GetType().Name;
                if (tmpChild is IClassAndInterfaceBaseData)
                {
                    var tmpContext = tmpChild as IClassAndInterfaceBaseData;
                    tmpClass.Type = new TypeContainer(tmpContext.IDENTIFIER().GetText());

                    if (tmpContext.typeParameters() != null)
                    {
                        var tmpClassGenericTypes = GetGenericTypesFromGenericArgumentsChildren(tmpClass, tmpContext.typeParameters().GetChildren());
                        tmpClass.Type.GenericTypes.AddRange(tmpClassGenericTypes);
                    }
                }
                if (tmpChild is ClassOrInterfaceModifierContext)
                {
                    //var tmpContext = tmpChild as ClassOrInterfaceModifierContext;
                    tmpClass.ModifierList.AddRange(tmpChild.GetChildren().Select(inItem => inItem.GetText()));
                }
                else if (tmpChild is InterfaceDeclarationContext)
                {
                    tmpClass.ModifierList.Add("interface");
                    var tmpContext = tmpChild as InterfaceDeclarationContext;

                    if (tmpContext.typeList() != null)
                    {
                        foreach (var tmpEntry in tmpContext.typeList().typeType())
                        {
                            var tmpTypeListType = GetTypeContainer(tmpEntry);
                            tmpClass.InterfaceList.Add(tmpTypeListType);
                        }
                    }

                    var tmpAdd = false;
                    for (var tmpContextI = 0; tmpContextI < tmpContext.ChildCount; tmpContextI++)
                    {
                        if (!(tmpContext.children[tmpContextI] is ITerminalNode))
                        {
                            continue;
                        }
                        var tmpChildText = tmpContext.children[tmpContextI].GetText();
                        if (tmpChildText == "{")
                        {
                            break;
                        }
                        if (tmpChildText == "implements")
                        {
                            tmpAdd = true;
                            continue;
                        }
                        if (tmpAdd)
                        {
                            if (tmpChildText == ",")
                            {
                                continue;
                            }
                            tmpClass.InterfaceList.Add(new TypeContainer(tmpChildText));
                        }
                    }

                    var tmpComment = "";
                    if (tmpContext.interfaceBody() != null)
                    {
                        for (var tmpI2 = 0; tmpI2 < tmpContext.interfaceBody().ChildCount; tmpI2++)
                        {
                            var tmpSubChild = tmpContext.interfaceBody().GetChild(tmpI2);
                            if (tmpSubChild is InterfaceBodyDeclarationContext)
                            {
                                ResolveInterfaceDeclaration(tmpClass, tmpComment, tmpSubChild);
                                //tmpClass.InnerClasses
                                tmpComment = "";
                            }
                            else if (tmpSubChild is ErrorNodeImpl)
                            {
                                tmpComment = tmpSubChild.GetText();
                            }
                            else if (tmpSubChild is TerminalNodeImpl)
                            {
                            }
                            else
                            {
                            }
                        }
                    }
                }
                else if (tmpChild is ClassDeclarationContext)
                {
                    FillClassContext(tmpClass, tmpChild as ClassDeclarationContext);
                }
                else
                {
                }
            }
        }