Loading files
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
namespace Hast.VhdlBuilder.Representation.Declaration;
/// <summary>
/// A VHDL block comment, consisting of multiple comment lines.
/// </summary>
/// <seealso cref="LineComment"/>
[DebuggerDisplay("{ToVhdl(Hast.VhdlBuilder.Representation.VhdlGenerationOptions.Debug)}")]
public class BlockComment : IVhdlElement
{
public IList<string> Lines { get; }
/// <summary>
/// Gets or sets a value indicating whether the comment won't be omitted even if this is configured in <see
/// cref="IVhdlGenerationOptions"/>.
/// </summary>
public bool CantBeOmitted { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="BlockComment"/> class. Initialized with a string that contains a
/// newline character-delimited block of text, corresponding to lines of the block comment.
/// </summary>
public BlockComment(string textBlock)
: this(textBlock.Split([Environment.NewLine], StringSplitOptions.None))
{
}
public BlockComment(params string[] lines)
: this() => Lines = [.. lines];
public BlockComment() => Lines = [];
public string ToVhdl(IVhdlGenerationOptions vhdlGenerationOptions)
{
if (vhdlGenerationOptions.OmitComments && !CantBeOmitted) return string.Empty;
var stringBuilder = new StringBuilder(Lines.Count);
foreach (var line in Lines)
{
stringBuilder.Append(new LineComment(line) { CantBeOmitted = true }.ToVhdl(vhdlGenerationOptions));
}
return stringBuilder.ToString();
}
}
7f9864208This file is pinned to the selected release. Download the original to open it in your design tool.