private static IReadOnlyList <PatchLine> ParseLines(string content) { var lines = GetLines(content); var headerEnd = GetHeaderEnd(lines); var result = new List <PatchLine>(lines.Count); for (var i = 0; i <= headerEnd; i++) { var kind = PatchLineKind.Header; var text = lines[i]; var line = new PatchLine(kind, text); result.Add(line); } for (var i = headerEnd + 1; i < lines.Count; i++) { var text = lines[i]; PatchLineKind kind; if (text.StartsWith("@@")) { kind = PatchLineKind.Hunk; } else if (text.StartsWith("+")) { kind = PatchLineKind.Addition; } else if (text.StartsWith("-")) { kind = PatchLineKind.Removal; } else if (text.StartsWith(@"\")) { kind = PatchLineKind.NoEndOfLine; } else { kind = PatchLineKind.Context; } var line = new PatchLine(kind, text); result.Add(line); } return(result); }
private static IReadOnlyList<PatchLine> ParseLines(string content) { var lines = GetLines(content); var headerEnd = GetHeaderEnd(lines); var result = new List<PatchLine>(lines.Count); for (var i = 0; i <= headerEnd; i++) { var kind = PatchLineKind.Header; var text = lines[i]; var line = new PatchLine(kind, text); result.Add(line); } for (var i = headerEnd + 1; i < lines.Count; i++) { var text = lines[i]; PatchLineKind kind; if (text.StartsWith("@@")) kind = PatchLineKind.Hunk; else if (text.StartsWith("+")) kind = PatchLineKind.Addition; else if (text.StartsWith("-")) kind = PatchLineKind.Removal; else if (text.StartsWith(@"\")) kind = PatchLineKind.NoEndOfLine; else kind = PatchLineKind.Context; var line = new PatchLine(kind, text); result.Add(line); } return result; }