Beispiel #1
0
        /// <summary>
        /// Renders the <paramref name="value"/> as a <see cref="string"/> given the
        /// <paramref name="options"/>.
        /// </summary>
        /// <param name="value"></param>
        /// <param name="options"></param>
        /// <returns></returns>
        public static string ToDescriptorString(this IVariant value, IStringRenderingOptions options)
        {
            // We want first, best possible pairing given the Variant Value.
            var pair = RenderingCallbacks.FirstOrDefault(x => x.Item1 == value.VariantType || x.Item1.IsAssignableFrom(value.VariantType));
            var renderingCallback = pair == null ? (x, o) => $"{x}" : pair.Item2;

            // TODO: TBD: potential Nullness going on here?
            return(renderingCallback.Invoke(value?.Value, options));
        }
Beispiel #2
0
        /// <inheritdoc />
        public override string ToDescriptorString(IStringRenderingOptions options)
        {
            const string dot = ".";

            string RenderGlobalScope() => IsGlobalScope ? dot : Empty;

            return(RenderGlobalScope()
                   + Join(dot, this.Select(x => x.ToDescriptorString(options)))
                   );
        }
        /// <inheritdoc />
        public override string ToDescriptorString(IStringRenderingOptions options)
        {
            string GetComments(params WhiteSpaceAndCommentOption[] masks)
            => options.WhiteSpaceAndCommentRendering.RenderMaskedComments(masks);

            return($"{GetComments(MultiLineComment)}"
                   + $" {Name.ToDescriptorString(options)} {GetComments(MultiLineComment)}"
                   + $" {EqualSign} {GetComments(MultiLineComment)}"
                   + $" {Value.ToDescriptorString(options)} {GetComments(MultiLineComment)}"
                   );
        }
Beispiel #4
0
        public void FloatingPointLiteralConstantSupported(OptionIdentifierPath optionName, IVariant constant, IStringRenderingOptions options)
        {
            /* TODO: TBD: This is STILL an issue some FOUR MONTHS later.
             * http://youtrack.jetbrains.com/issue/RSRP-471906 / "R# ignoring my xunit user furnished configuration" */

            GetRange <object>(optionName, constant, options).AllNotNull();

            RenderingOptions = options;

            ExpectedProto.Items.Add(
                new OptionStatement {
                Name = optionName, Value = Assert.IsAssignableFrom <IVariant <double> >(constant)
            }
                );
        }
        // ReSharper disable once PossibleMultipleEnumeration
        /// <summary>
        /// Renders the <see cref="IOption"/> <typeparamref name="T"/> <paramref name="values"/>
        /// given <paramref name="options"/>.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="values"></param>
        /// <param name="options"></param>
        /// <returns></returns>
        public static string RenderOptions <T>(this IEnumerable <T> values, IStringRenderingOptions options)
            where T : IOption // TODO: TBD: perhaps IOption? or ICanRenderString
        {
            string GetComments(params WhiteSpaceAndCommentOption[] masks)
            => options.WhiteSpaceAndCommentRendering.RenderMaskedComments(masks);

            return(values.Any()
                ? $"{GetComments(MultiLineComment)}"
                   + $"{OpenSquareBracket}"
                   + $"{GetComments(MultiLineComment)}"
                   // ReSharper disable once PossibleMultipleEnumeration
                   + $"{Join($"{Comma} ", values.Select(x => x.ToDescriptorString(options)))}"
                   + $"{GetComments(MultiLineComment)}"
                   + $"{CloseSquareBracket}"
                   + $"{GetComments(MultiLineComment)}"
                : Empty);
        }
 /// <inheritdoc />
 protected override string RenderItem(Identifier item, IStringRenderingOptions options)
 => item.ToDescriptorString(options);
 /// <summary>
 /// Renders the <paramref name="value"/> given the <paramref name="options"/>.
 /// </summary>
 /// <param name="value"></param>
 /// <param name="options"></param>
 /// <returns></returns>
 public static string ToDescriptorString(this KeyType value, IStringRenderingOptions options)
 => ToDescriptorString((ProtoType)(int)value, options);
 /// <summary>
 /// Renders the <paramref name="value"/> given the <paramref name="options"/>.
 /// </summary>
 /// <param name="value"></param>
 /// <param name="options"></param>
 /// <returns></returns>
 public static string ToDescriptorString(this ProtoType value, IStringRenderingOptions options)
 => ValueMapping[value];
Beispiel #9
0
 /// <summary>
 /// Renders the <paramref name="value"/> given the <paramref name="options"/>.
 /// </summary>
 /// <param name="value"></param>
 /// <param name="options"></param>
 /// <returns></returns>
 public static string ToDescriptorString(this LabelKind value, IStringRenderingOptions options)
 => $"{ValueMapping[value]}";
Beispiel #10
0
 /// <inheritdoc />
 protected override string RenderItem(RangeDescriptor item, IStringRenderingOptions options)
 => $"{item.ToDescriptorString(options)}";