Example #1
0
		public Span Span(SpanKind kind, params ISymbol[] symbols)
		{
			var builder = new SpanBuilder();
			builder.Kind = kind;

			foreach (var symbol in symbols)
			{
				builder.Accept(symbol);
			}

			var span = builder.Build();
			if (_last != null)
			{
				span.Previous = _last;
				_last.Next = span;
			}
			_last = span;

			return span;
		}
Example #2
0
 /// <summary>
 /// Initialises a new instance of <see cref="Span"/>
 /// </summary>
 /// <param name="builder">The span builder.</param>
 public Span(SpanBuilder builder)
 {
     ReplaceWith(builder);
 }
Example #3
0
		/// <summary>
		/// Initialises a new instance of <see cref="Span"/>
		/// </summary>
		/// <param name="builder">The span builder.</param>
		public Span(SpanBuilder builder)
		{
			ReplaceWith(builder);
		}
Example #4
0
		/// <summary>
		/// Replaces the content of the span with that built form the given builder.
		/// </summary>
		/// <param name="builder">The span builder.</param>
		public void ReplaceWith(SpanBuilder builder)
		{
			Collapsed = builder.Collapsed;
			Kind = builder.Kind;
			Symbols = builder.Symbols;
			_start = builder.Start;

			builder.Reset();

			Content = Symbols.Aggregate(
				new StringBuilder(),
				(sb, sym) => sb.Append(sym.Content),
				sb => sb.ToString());
		}