/// <inheritdoc />
        public override ConfigValuePart[] VisitReference(ConfigReferenceParser.ReferenceContext context)
        {
            try
            {
                var children = VisitChildren(context);

                var commands = children.OfType <ReferencePart>()
                               .SelectMany(r => r.Commands.ToArray())
                               .ToArray();

                _logger.LogTrace($"ReferencePart is being assembled from '{commands.Length} / {children.Length}' commands");

                // collect the commands of all sub-references into one result-dictionary
                return(new ConfigValuePart[]
                {
                    new ReferencePart(commands.ToDictionary(c => c.Key, c => c.Value))
                });
            }
            catch (Exception e)
            {
                _logger.LogError(e, "failed to parse reference");
                return(new ConfigValuePart[0]);
            }
        }
 /// <summary>
 /// Visit a parse tree produced by <see cref="ConfigReferenceParser.reference"/>.
 /// <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 VisitReference([NotNull] ConfigReferenceParser.ReferenceContext context)
 {
     return(VisitChildren(context));
 }