public override Entity VisitEntity([NotNull] DmolParser.EntityContext context) { var dataSectionVisitor = new DataSectionVisitor(ErrorListener); var fields = context.entitySection() .Where(es => es.dataSection() != null) .SelectMany(es => dataSectionVisitor.Visit(es.dataSection())) .Where(f => f != null) .ToList(); var constraintsSectionVisitor = new ConstraintsSectionVisitor(ErrorListener); var constraints = context.entitySection() .Where(es => es.constraintsSection() != null) .SelectMany(es => constraintsSectionVisitor.Visit(es.constraintsSection())) .Where(cs => cs != null) .ToList(); var relationsSectionVisitor = new RelationsSectionVisitor(ErrorListener); var relations = context.entitySection() .Where(es => es.relationsSection() != null) .SelectMany(es => relationsSectionVisitor.Visit(es.relationsSection())) .Where(rs => rs != null) .ToList(); var relatedSectionVisitor = new RelatedSectionVisitor(ErrorListener); var related = context.entitySection() .Where(es => es.relatedSection() != null) .SelectMany(es => relatedSectionVisitor.Visit(es.relatedSection())) .Where(rs => rs != null) .ToList(); return(new Entity(context.entityName().GetText()) { Fields = fields, Constraints = constraints, Relations = relations, Related = related }); }
/// <summary> /// Visit a parse tree produced by <see cref="DmolParser.entity"/>. /// <para> /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/> /// on <paramref name="context"/>. /// </para> /// </summary> /// <param name="context">The parse tree.</param> /// <return>The visitor result.</return> public virtual Result VisitEntity([NotNull] DmolParser.EntityContext context) { return(VisitChildren(context)); }