Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 34ac1d2

Browse files
Reverting Inline Reviews
1 parent 5362e1f commit 34ac1d2

19 files changed

+54
-357
lines changed

src/GitHub.InlineReviews/GitHub.InlineReviews.csproj

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@
9292
<Compile Include="Models\PullRequestSessionLiveFile.cs" />
9393
<Compile Include="Models\PullRequestSessionFile.cs" />
9494
<Compile Include="Services\PullRequestStatusBarManager.cs" />
95-
<Compile Include="Tags\InlineTagBase.cs" />
9695
<Compile Include="Tags\MouseEnterAndLeaveEventRouter.cs" />
9796
<Compile Include="Peek\InlineCommentPeekableItem.cs" />
9897
<Compile Include="Peek\InlineCommentPeekableItemSource.cs" />
@@ -111,16 +110,6 @@
111110
<Compile Include="Services\PullRequestSessionManager.cs" />
112111
<Compile Include="Margins\InlineCommentMarginProvider.cs" />
113112
<Compile Include="Services\PullRequestSessionService.cs" />
114-
<Compile Include="Tags\ShowInlineAnnotationWarningGlyph.xaml.cs">
115-
<DependentUpon>ShowInlineAnnotationWarningGlyph.xaml</DependentUpon>
116-
</Compile>
117-
<Compile Include="Tags\ShowInlineAnnotationNoticeGlyph.xaml.cs">
118-
<DependentUpon>ShowInlineAnnotationNoticeGlyph.xaml</DependentUpon>
119-
</Compile>
120-
<Compile Include="Tags\ShowInlineAnnotationTag.cs" />
121-
<Compile Include="Tags\ShowInlineAnnotationFailureGlyph.xaml.cs">
122-
<DependentUpon>ShowInlineAnnotationFailureGlyph.xaml</DependentUpon>
123-
</Compile>
124113
<Compile Include="ViewModels\PullRequestFileMarginViewModel.cs" />
125114
<Compile Include="ViewModels\CommentViewModel.cs" />
126115
<Compile Include="ViewModels\ICommentThreadViewModel.cs" />
@@ -149,11 +138,11 @@
149138
<Compile Include="Tags\ShowInlineCommentGlyph.xaml.cs">
150139
<DependentUpon>ShowInlineCommentGlyph.xaml</DependentUpon>
151140
</Compile>
152-
<Compile Include="Tags\InlineGlyphFactory.cs" />
141+
<Compile Include="Tags\InlineCommentGlyphFactory.cs" />
153142
<Compile Include="Tags\InlineCommentTag.cs" />
154143
<Compile Include="Tags\ShowInlineCommentTag.cs" />
155-
<Compile Include="Tags\InlineTagger.cs" />
156-
<Compile Include="Tags\InlineTaggerProvider.cs" />
144+
<Compile Include="Tags\InlineCommentTagger.cs" />
145+
<Compile Include="Tags\InlineCommentTaggerProvider.cs" />
157146
<Compile Include="ViewModels\InlineCommentThreadViewModel.cs" />
158147
<Compile Include="ViewModels\ICommentViewModel.cs" />
159148
<Compile Include="Views\CommentThreadView.xaml.cs">
@@ -446,18 +435,6 @@
446435
<SubType>Designer</SubType>
447436
<ContainsDesignTimeResources>true</ContainsDesignTimeResources>
448437
</Page>
449-
<Page Include="Tags\ShowInlineAnnotationFailureGlyph.xaml">
450-
<Generator>MSBuild:Compile</Generator>
451-
<SubType>Designer</SubType>
452-
</Page>
453-
<Page Include="Tags\ShowInlineAnnotationNoticeGlyph.xaml">
454-
<Generator>MSBuild:Compile</Generator>
455-
<SubType>Designer</SubType>
456-
</Page>
457-
<Page Include="Tags\ShowInlineAnnotationWarningGlyph.xaml">
458-
<Generator>MSBuild:Compile</Generator>
459-
<SubType>Designer</SubType>
460-
</Page>
461438
<Page Include="Views\PullRequestFileMarginView.xaml">
462439
<SubType>Designer</SubType>
463440
<Generator>MSBuild:Compile</Generator>

src/GitHub.InlineReviews/Margins/InlineCommentMargin.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public sealed class InlineCommentMargin : IWpfTextViewMargin
2525
readonly IPullRequestSessionManager sessionManager;
2626
readonly Grid marginGrid;
2727

28-
GlyphMargin<InlineTagBase> glyphMargin;
28+
GlyphMargin<InlineCommentTag> glyphMargin;
2929
IDisposable currentSessionSubscription;
3030
IDisposable visibleSubscription;
3131
bool hasChanges;
@@ -45,10 +45,10 @@ public InlineCommentMargin(
4545
textView.Options.SetOptionValue(InlineCommentTextViewOptions.MarginEnabledId, false);
4646

4747
marginGrid = new GlyphMarginGrid { Width = 17.0 };
48-
var glyphFactory = new InlineGlyphFactory(peekService, textView);
48+
var glyphFactory = new InlineCommentGlyphFactory(peekService, textView);
4949
var editorFormatMap = editorFormatMapService.GetEditorFormatMap(textView);
5050

51-
glyphMargin = new GlyphMargin<InlineTagBase>(textView, glyphFactory, marginGrid, tagAggregatorFactory,
51+
glyphMargin = new GlyphMargin<InlineCommentTag>(textView, glyphFactory, marginGrid, tagAggregatorFactory,
5252
editorFormatMap, MarginPropertiesName);
5353

5454
if (IsDiffView())

src/GitHub.InlineReviews/Models/PullRequestSessionFile.cs

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ public class PullRequestSessionFile : ReactiveObject, IPullRequestSessionFile
2525
IReadOnlyList<DiffChunk> diff;
2626
string commitSha;
2727
IReadOnlyList<IInlineCommentThreadModel> inlineCommentThreads;
28-
IReadOnlyList<IInlineAnnotationModel> inlineAnnotations;
2928

3029
/// <summary>
3130
/// Initializes a new instance of the <see cref="PullRequestSessionFile"/> class.
@@ -100,29 +99,6 @@ public IReadOnlyList<IInlineCommentThreadModel> InlineCommentThreads
10099
/// <inheritdoc/>
101100
public IObservable<IReadOnlyList<Tuple<int, DiffSide>>> LinesChanged => linesChanged;
102101

103-
/// <inheritdoc/>
104-
public IReadOnlyList<IInlineAnnotationModel> InlineAnnotations
105-
{
106-
get
107-
{
108-
return inlineAnnotations;
109-
}
110-
set
111-
{
112-
var lines = (inlineAnnotations ?? Enumerable.Empty<IInlineAnnotationModel>())?
113-
.Concat(value ?? Enumerable.Empty<IInlineAnnotationModel>())
114-
.Select(x => Tuple.Create(x.StartLine, DiffSide.Right))
115-
.Where(x => x.Item1 >= 0)
116-
.Distinct()
117-
.ToList();
118-
119-
this.RaisePropertyChanging();
120-
inlineAnnotations = value;
121-
this.RaisePropertyChanged();
122-
NotifyLinesChanged(lines);
123-
}
124-
}
125-
126102
/// <summary>
127103
/// Raises the <see cref="LinesChanged"/> signal.
128104
/// </summary>

src/GitHub.InlineReviews/Services/IPullRequestSessionService.cs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,6 @@ Task<IReadOnlyList<DiffChunk>> Diff(
4444
string relativePath,
4545
byte[] contents);
4646

47-
48-
49-
/// <summary>
50-
/// Builds a set of annotation models for a file based on a pull request model
51-
/// </summary>
52-
/// <param name="pullRequest">The pull request session.</param>
53-
/// <param name="relativePath">The relative path to the file.</param>
54-
/// <returns>
55-
/// A collection of <see cref="IInlineAnnotationModel"/> objects.
56-
/// </returns>
57-
IReadOnlyList<IInlineAnnotationModel> BuildAnnotations(
58-
PullRequestDetailModel pullRequest,
59-
string relativePath);
60-
6147
/// <summary>
6248
/// Builds a set of comment thread models for a file based on a pull request model and a diff.
6349
/// </summary>

src/GitHub.InlineReviews/Services/PullRequestSession.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,6 @@ async Task UpdateFile(PullRequestSessionFile file)
310310
file.CommitSha = file.IsTrackingHead ? PullRequest.HeadRefSha : file.CommitSha;
311311
file.Diff = await service.Diff(LocalRepository, mergeBaseSha, file.CommitSha, file.RelativePath);
312312
file.InlineCommentThreads = service.BuildCommentThreads(PullRequest, file.RelativePath, file.Diff, file.CommitSha);
313-
file.InlineAnnotations = service.BuildAnnotations(PullRequest, file.RelativePath);
314313
}
315314

316315
void UpdatePendingReview()

src/GitHub.InlineReviews/Services/PullRequestSessionService.cs

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -97,23 +97,6 @@ public virtual async Task<IReadOnlyList<DiffChunk>> Diff(ILocalRepositoryModel r
9797
}
9898
}
9999

100-
/// <inheritdoc/>
101-
public IReadOnlyList<IInlineAnnotationModel> BuildAnnotations(
102-
PullRequestDetailModel pullRequest,
103-
string relativePath)
104-
{
105-
relativePath = relativePath.Replace("\\", "/");
106-
107-
return pullRequest.CheckSuites
108-
?.SelectMany(checkSuite => checkSuite.CheckRuns)
109-
.SelectMany(checkRun =>
110-
checkRun.Annotations
111-
.Where(annotation => annotation.Filename == relativePath && annotation.AnnotationLevel.HasValue)
112-
.Select(annotation => new InlineAnnotationModel(checkRun, annotation)))
113-
.OrderBy(tuple => tuple.StartLine)
114-
.ToArray();
115-
}
116-
117100
/// <inheritdoc/>
118101
public IReadOnlyList<IInlineCommentThreadModel> BuildCommentThreads(
119102
PullRequestDetailModel pullRequest,
@@ -787,22 +770,11 @@ async Task<LastCommitAdapter> GetPullRequestLastCommitAdapter(HostAddress addres
787770
CheckRuns = suite.CheckRuns(null, null, null, null, null).AllPages(10)
788771
.Select(run => new CheckRunModel
789772
{
790-
DatabaseId = run.DatabaseId.Value,
791773
Conclusion = run.Conclusion.FromGraphQl(),
792774
Status = run.Status.FromGraphQl(),
793775
Name = run.Name,
794776
DetailsUrl = run.Permalink,
795777
Summary = run.Summary,
796-
Annotations = run.Annotations(null, null, null, null).AllPages()
797-
.Select(annotation => new CheckRunAnnotationModel
798-
{
799-
Title = annotation.Title,
800-
Message = annotation.Message,
801-
Filename = annotation.Path,
802-
AnnotationLevel = annotation.AnnotationLevel.FromGraphQl(),
803-
StartLine = annotation.Location.Start.Line,
804-
EndLine = annotation.Location.End.Line,
805-
}).ToList()
806778
}).ToList()
807779
}).ToList(),
808780
Statuses = commit.Commit.Status
@@ -950,5 +922,5 @@ class LastCommitAdapter
950922

951923
public List<StatusModel> Statuses { get; set; }
952924
}
953-
}
925+
}
954926
}

src/GitHub.InlineReviews/Tags/InlineGlyphFactory.cs renamed to src/GitHub.InlineReviews/Tags/InlineCommentGlyphFactory.cs

Lines changed: 12 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,37 +7,29 @@
77
using Microsoft.VisualStudio.Text.Editor;
88
using Microsoft.VisualStudio.Text.Formatting;
99
using GitHub.InlineReviews.Services;
10-
using GitHub.Models;
1110

1211
namespace GitHub.InlineReviews.Tags
1312
{
14-
class InlineGlyphFactory : IGlyphFactory<InlineTagBase>
13+
class InlineCommentGlyphFactory : IGlyphFactory<InlineCommentTag>
1514
{
1615
readonly IInlineCommentPeekService peekService;
1716
readonly ITextView textView;
1817

19-
public InlineGlyphFactory(
18+
public InlineCommentGlyphFactory(
2019
IInlineCommentPeekService peekService,
2120
ITextView textView)
2221
{
2322
this.peekService = peekService;
2423
this.textView = textView;
2524
}
2625

27-
public UIElement GenerateGlyph(IWpfTextViewLine line, InlineTagBase tag)
26+
public UIElement GenerateGlyph(IWpfTextViewLine line, InlineCommentTag tag)
2827
{
2928
var glyph = CreateGlyph(tag);
3029
glyph.DataContext = tag;
3130
glyph.MouseLeftButtonUp += (s, e) =>
3231
{
33-
if (tag is InlineCommentTag inlineCommentTag)
34-
{
35-
if (OpenThreadView(inlineCommentTag)) e.Handled = true;
36-
}
37-
38-
if (tag is ShowInlineAnnotationTag showInlineAnnotationTag)
39-
{
40-
}
32+
if (OpenThreadView(tag)) e.Handled = true;
4133
};
4234

4335
return glyph;
@@ -48,42 +40,28 @@ public IEnumerable<Type> GetTagTypes()
4840
return new[]
4941
{
5042
typeof(AddInlineCommentTag),
51-
typeof(ShowInlineCommentTag),
52-
typeof(ShowInlineAnnotationTag)
43+
typeof(ShowInlineCommentTag)
5344
};
5445
}
5546

5647
[SuppressMessage("Microsoft.Globalization", "CA1305:SpecifyIFormatProvider", MessageId = "System.String.Format(System.String,System.Object)")]
57-
static UserControl CreateGlyph(InlineTagBase tag)
48+
static UserControl CreateGlyph(InlineCommentTag tag)
5849
{
59-
if (tag is AddInlineCommentTag addCommentTag)
50+
var addTag = tag as AddInlineCommentTag;
51+
var showTag = tag as ShowInlineCommentTag;
52+
53+
if (addTag != null)
6054
{
6155
return new AddInlineCommentGlyph();
6256
}
63-
64-
if (tag is ShowInlineCommentTag showCommentTag)
57+
else if (showTag != null)
6558
{
6659
return new ShowInlineCommentGlyph()
6760
{
68-
Opacity = showCommentTag.Thread.IsStale ? 0.5 : 1,
61+
Opacity = showTag.Thread.IsStale ? 0.5 : 1,
6962
};
7063
}
7164

72-
if (tag is ShowInlineAnnotationTag showAnnotation)
73-
{
74-
switch (showAnnotation.Annotation.AnnotationLevel)
75-
{
76-
case CheckAnnotationLevel.Failure:
77-
return new ShowInlineAnnotationFailureGlyph();
78-
case CheckAnnotationLevel.Notice:
79-
return new ShowInlineAnnotationNoticeGlyph();
80-
case CheckAnnotationLevel.Warning:
81-
return new ShowInlineAnnotationWarningGlyph();
82-
default:
83-
throw new ArgumentOutOfRangeException();
84-
}
85-
}
86-
8765
throw new ArgumentException($"Unknown 'InlineCommentTag' type '{tag}'");
8866
}
8967

src/GitHub.InlineReviews/Tags/InlineCommentTag.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,22 @@ namespace GitHub.InlineReviews.Tags
1010
/// </summary>
1111
/// <seealso cref="AddInlineCommentTag"/>
1212
/// <seealso cref="ShowInlineCommentTag"/>
13-
public abstract class InlineCommentTag : InlineTagBase
13+
public abstract class InlineCommentTag : ITag
1414
{
1515
protected InlineCommentTag(
1616
IPullRequestSession session,
1717
int lineNumber,
18-
DiffChangeType diffChangeType): base(session, lineNumber)
18+
DiffChangeType diffChangeType)
1919
{
20+
Guard.ArgumentNotNull(session, nameof(session));
21+
22+
LineNumber = lineNumber;
23+
Session = session;
2024
DiffChangeType = diffChangeType;
2125
}
2226

27+
public int LineNumber { get; }
28+
public IPullRequestSession Session { get; }
2329
public DiffChangeType DiffChangeType { get; }
2430
}
2531
}

0 commit comments

Comments
 (0)