public void AddContinuationLine(AbsoluteCodeLine line) { var last = _lines.Last(); line.IsDeclarationContinuation = last.HasDeclarationContinuation && !line.ContainsOnlyComment; _lines.Add(line); }
private IEnumerable <LogicalCodeLine> BuildLogicalCodeLines(IEnumerable <string> lines, out IIndenterSettings settings) { settings = _settings.Invoke(); var logical = new List <LogicalCodeLine>(); LogicalCodeLine current = null; AbsoluteCodeLine previous = null; foreach (var line in lines) { var absolute = new AbsoluteCodeLine(line, settings, previous); if (current == null) { current = new LogicalCodeLine(absolute, settings); logical.Add(current); } else { current.AddContinuationLine(absolute); } if (!absolute.HasContinuation) { current = null; } previous = absolute; } return(logical); }
public AbsoluteCodeLine(string code, IIndenterSettings settings, AbsoluteCodeLine previous) { _settings = settings; Previous = previous; if (code.EndsWith(StupidLineEnding)) { _code = code.Substring(0, code.Length - StupidLineEnding.Length); _stupidLineEnding = true; } else { _code = code; } Original = code; _escaper = new StringLiteralAndBracketEscaper(_code); _code = _escaper.EscapedString; ExtractLineNumber(); ExtractEndOfLineComment(); _segments = _code.Split(new[] { ": " }, StringSplitOptions.None); }
private void RebuildContinuedLine() { if (_rebuilt != null) { return; } if (_lines.Count == 1) { _rebuilt = _lines.First(); return; } var code = _lines.Aggregate(string.Empty, (c, line) => c + line.ContinuationRebuildText); _rebuilt = new AbsoluteCodeLine(code, _settings); }
public LogicalCodeLine(AbsoluteCodeLine first, IIndenterSettings settings) { _lines.Add(first); _settings = settings; }
public void AddContinuationLine(AbsoluteCodeLine line) { _lines.Add(line); }