public override PropertyDefinitionCollection VisitClass_member_declaration(CSharpParser.Class_member_declarationContext context)
        {
            var memberDeclaration = context.common_member_declaration()?.typed_member_declaration();

            if (memberDeclaration == null)
            {
                return(this.Collection);
            }

            var modifiers = context.all_member_modifiers()?.all_member_modifier();

            if (modifiers == null || modifiers.All(modifier => modifier.Start.Text != "public"))
            {
                return(this.Collection);
            }

            var property = memberDeclaration.property_declaration();

            if (property == null)
            {
                return(this.Collection);
            }

            var name            = property.member_name().Start.Text;
            var type            = memberDeclaration.type();
            var argVisitor      = new TypeArgumentListVisitor(Cache, Reference);
            var typeArgs        = argVisitor.Visit(type);
            var classDefinition = new ClassDefinition {
                BaseName = type.Start.Text, GenericTypeArgs = typeArgs
            };
            var className = classDefinition.Name;

            if (!Cache.ContainsKey(className))
            {
                Cache.Add(className, classDefinition);
            }
            else
            {
                classDefinition = Cache[className];
            }

            Reference.Add(className);

            this.Collection.Add(new PropertyDefinition {
                Name = name, Type = classDefinition
            });

            return(this.Collection);
        }
예제 #2
0
        public static void Parse(this CSharpParser.Class_member_declarationContext context)
        {
            if (context.attributes() != null)
            {
                throw new NotImplementedException("Attributes not implemented yet");
            }

            Modifiers modifiers = context.all_member_modifiers() != null?context.all_member_modifiers().Parse() : 0;

            Console.WriteLine("Modifiers " + modifiers);

            if (context.destructor_definition() != null)
            {
                throw new NotImplementedException("Destructors not implemented yet");
            }
            else if (context.common_member_declaration() != null)
            {
                context.common_member_declaration().Parse();
            }
            else
            {
                throw new NotSupportedException("Unknown member type");
            }
        }
예제 #3
0
        public override void EnterClass_member_declaration(CSharpParser.Class_member_declarationContext context)
        {
            var cmdecl = context.common_member_declaration();

            if (cmdecl == null)
            {
                return;
            }
            var nm = GetContextName(cmdecl);

            var parseItem = new CsharpParseItem {
                Name = nm
            };

            AssignAccessMods(parseItem, context.all_member_modifiers());
            AssignAttributes(parseItem, context.attributes());
            AssignParameterType2Names(parseItem, cmdecl);;
            AssignStartAndStop(parseItem, context);
            AssignNsAndTypeValues(parseItem);
            Results.TypeMemberBodies.Add(parseItem);
        }