public override ITextArea[] VisitLineStar([NotNull] LineStarContext context) { var result = new List <ITextArea>(); var indentation = context.indentation(); int length = indentation == null ? 0 : indentation.GetText().Length; IndentationTracker.Track(length); var spanVisitor = new TextAreaVisitor().Inherit(this); var bodyContext = context.spanLineStartNoStar(); foreach (var atom in bodyContext) { result.Add(spanVisitor.VisitSpanLineStartNoStar(atom)); } var starText = context.starText(); if (starText != null) { result.Add(spanVisitor.VisitStarText(starText)); } result.First().Indentation = length; return(result.ToArray()); }
public override ITextArea[] VisitLineNoBreak([NotNull] LineNoBreakContext context) { var result = new List <ITextArea>(); var indentation = context.indentation(); int length = indentation == null ? 0 : indentation.GetText().Length; IndentationTracker.Track(length); var spanVisitor = new TextAreaVisitor().Inherit(this); result.Add(spanVisitor.VisitSpanLineStartNoStar(context.spanLineStartNoStar())); var spanContext = context.span(); if (spanContext != null) { foreach (var atom in spanContext) { result.Add(spanVisitor.VisitSpan(atom)); } } if (result.Last().TypeCode == ElementType.Text) { result.Last().Content.Append("\n"); } else { result.Add(new TextArea("\n", result.Last().Scope)); } result.First().Indentation = length; return(result.ToArray()); }
public override ITextArea[] VisitLineNormal([NotNull] LineNormalContext context) { var result = new List <ITextArea>(); var special = context.lineSpecial(); if (special != null) { var text = context.GetText().TrimStart() + "\n"; return(new ITextArea[] { new TextArea(text, new Scope { LineStart = context.Start.Line, LineEnd = context.Stop.Line }) }); } var indentation = context.indentation(); int length = indentation == null ? 0 : indentation.GetText().Length; IndentationTracker.Track(length); var spanVisitor = new TextAreaVisitor().Inherit(this); var start = context.spanLineStartNoStar(); if (start != null) { foreach (var item in start) { result.Add(spanVisitor.VisitSpanLineStartNoStar(item)); } } var bodyContext = context.span(); foreach (var atom in bodyContext) { result.Add(spanVisitor.VisitSpan(atom)); } var noStar = context.spanNoStar(); if (noStar != null) { foreach (var item in noStar) { result.Add(spanVisitor.VisitSpanNoStar(item)); } } if (result.Last().TypeCode == ElementType.Text) { result.Last().Content.Append("\n"); } else { result.Add(new TextArea("\n", result.Last().Scope)); } result.First().Indentation = length; return(result.ToArray()); }