public void FirstLine_CheckDiffChangeTypes(string line, DiffChangeType expectType) { var fragment = $"@@ -1 +1 @@\n{line}"; var result = DiffUtilities.ParseFragment(fragment); var firstLine = result.First().Lines.First(); Assert.Equal(expectType, firstLine.Type); }
public InlineCommentTag( IPullRequestSession session, int lineNumber, DiffChangeType diffChangeType) { Guard.ArgumentNotNull(session, nameof(session)); LineNumber = lineNumber; Session = session; DiffChangeType = diffChangeType; }
/// <summary> /// Initializes a new instance of the <see cref="AddInlineCommentTag"/> class. /// </summary> /// <param name="session">The pull request session.</param> /// <param name="commitSha"> /// The SHA of the commit to which a new comment should be added. May be null if the tag /// represents trying to add a comment to a line that hasn't yet been pushed. /// </param> /// <param name="filePath">The path to the file.</param> /// <param name="diffLine">The line in the diff that the line relates to.</param> /// <param name="lineNumber">The line in the file.</param> /// <param name="diffChangeType">The type of represented by the diff line.</param> public AddInlineCommentTag( IPullRequestSession session, string commitSha, string filePath, int diffLine, int lineNumber, DiffChangeType diffChangeType) : base(session, lineNumber, diffChangeType) { CommitSha = commitSha; DiffLine = diffLine; FilePath = filePath; }
internal Brush GetBackground(DiffChangeType diffChangeType) { switch (diffChangeType) { case DiffChangeType.Add: return(GetBackground(addProperties)); case DiffChangeType.Delete: return(GetBackground(deleteProperties)); case DiffChangeType.None: default: return(GetBackground(noneProperties)); } }
public DiffChange(string[] Diff, int DiffIndex) { // Determine what kind of change this is (add/change/delete) var Change = Diff[DiffIndex]; var ChangeTypes = new string[] { "a", "c", "d" }; var ChangeTypeIndex = -1; for (int ChangeIndex = 0; ChangeIndex < ChangeTypes.Length; ++ChangeIndex) { ChangeTypeIndex = Change.IndexOf(ChangeTypes[ChangeIndex]); if (ChangeTypeIndex != -1) { Type = (DiffChangeType)ChangeIndex; break; } } // Get range of changes var SourceRange = Change.Substring(0, ChangeTypeIndex); ParseRange(SourceRange, out SourceStart, out SourceEnd); var DestRange = Change.Substring(ChangeTypeIndex + 1); ParseRange(DestRange, out DestStart, out DestEnd); // Get the actual change contents for (++DiffIndex; DiffIndex < Diff.Length; ++DiffIndex) { var ContentsLine = Diff[DiffIndex]; if (ContentsLine.StartsWith("<")) { OldContents.Add(ContentsLine.Substring(2)); } else if (ContentsLine.StartsWith(">")) { NewContents.Add(ContentsLine.Substring(2)); } else if (!ContentsLine.StartsWith("---")) { break; } } }
/// <summary> /// Initializes a new instance of the <see cref="ShowInlineCommentTag"/> class. /// </summary> /// <param name="session">The pull request session.</param> /// <param name="lineNumber">0-based index of the inline tag</param> /// <param name="diffLineType">The diff type for the inline comment</param> public ShowInlineCommentTag(IPullRequestSession session, int lineNumber, DiffChangeType diffLineType) : base(session, lineNumber, diffLineType) { }
/// <summary> /// Gets the differences of a specified type. /// </summary> /// <param name="diffChangeType">Type of differences.</param> /// <returns>Collection of differences with the specified type.</returns> public IReadOnlyList <ITextSnapshotLine> this[DiffChangeType diffChangeType] { get { return(_dict[diffChangeType]); } }
/// <summary> /// Initializes a new instance of the <see cref="DiffLineEntry"/> class. /// </summary> /// <param name="changeType">Difference type.</param> /// <param name="line">Text line which differs.</param> public DiffLineEntry(DiffChangeType changeType, ITextSnapshotLine line) { _changeType = changeType; _line = line; }