提交 2500ab70 编写于 作者: C Cyrus Najmabadi

before del

上级 57df9bf2
......@@ -3,10 +3,8 @@
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Threading;
using Microsoft.CodeAnalysis.Common;
using Microsoft.CodeAnalysis.TodoComments;
namespace Microsoft.CodeAnalysis.Editor
......@@ -27,8 +25,9 @@ internal interface ITodoListProvider
ImmutableArray<TodoCommentData> GetTodoItems(Workspace workspace, DocumentId documentId, CancellationToken cancellationToken);
/// <summary>
/// Get current UpdatedEventArgs stored in ITodoListProvider
/// Get current buckets stored our todo items are grouped into. Specific buckets can be retrieved by calling
/// <see cref="GetTodoItems"/>.
/// </summary>
IEnumerable<UpdatedEventArgs> GetTodoItemsUpdatedEventArgs(Workspace workspace, CancellationToken cancellationToken);
ImmutableArray<TodoItemBucket> GetTodoItemBuckets(Workspace workspace, CancellationToken cancellationToken);
}
}
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#nullable enable
namespace Microsoft.CodeAnalysis.Editor
{
internal readonly struct TodoItemBucket
{
/// <summary>
/// The identity of bucket group.
/// </summary>
public readonly object Id;
/// <summary>
/// <see cref="Workspace"/> this bucket is associated with.
/// </summary>
public readonly Workspace Workspace;
/// <summary>
/// <see cref="ProjectId"/> this bucket is associated with, or <see langword="null"/>.
/// </summary>
public readonly ProjectId? ProjectId;
/// <summary>
/// <see cref="DocumentId"/> this bucket is associated with, or <see langword="null"/>.
/// </summary>
public readonly DocumentId? DocumentId;
public TodoItemBucket(object id, Workspace workspace, ProjectId? projectId, DocumentId? documentId)
{
Id = id;
Workspace = workspace;
ProjectId = projectId;
DocumentId = documentId;
}
}
}
......@@ -9,22 +9,22 @@ namespace Microsoft.CodeAnalysis.Diagnostics
internal readonly struct DiagnosticBucket
{
/// <summary>
/// The identity of update group.
/// The identity of bucket group.
/// </summary>
public readonly object Id;
/// <summary>
/// <see cref="Workspace"/> this update is associated with.
/// <see cref="Workspace"/> this bucket is associated with.
/// </summary>
public readonly Workspace Workspace;
/// <summary>
/// <see cref="ProjectId"/> this update is associated with, or <see langword="null"/>.
/// <see cref="ProjectId"/> this bucket is associated with, or <see langword="null"/>.
/// </summary>
public readonly ProjectId? ProjectId;
/// <summary>
/// <see cref="DocumentId"/> this update is associated with, or <see langword="null"/>.
/// <see cref="DocumentId"/> this bucket is associated with, or <see langword="null"/>.
/// </summary>
public readonly DocumentId? DocumentId;
......
......@@ -12,6 +12,7 @@
using Microsoft.CodeAnalysis.Common;
using Microsoft.CodeAnalysis.Editor;
using Microsoft.CodeAnalysis.Text;
using Microsoft.CodeAnalysis.TodoComments;
using Microsoft.VisualStudio.LanguageServices.Implementation.Diagnostics;
using Microsoft.VisualStudio.Shell.Interop;
using Microsoft.VisualStudio.Shell.TableControl;
......@@ -67,7 +68,7 @@ protected override void RemoveTableSourceIfNecessary(Solution solution)
protected override void ShutdownSource()
=> _source.Shutdown();
private class TableDataSource : AbstractRoslynTableDataSource<TodoTableItem, UpdatedEventArgs>
private class TableDataSource : AbstractRoslynTableDataSource<TodoTableItem, TodoItemsUpdatedArgs>
{
private readonly Workspace _workspace;
private readonly string _identifier;
......@@ -88,9 +89,9 @@ public TableDataSource(Workspace workspace, ITodoListProvider todoListProvider,
public override string DisplayName => ServicesVSResources.CSharp_VB_Todo_List_Table_Data_Source;
public override string SourceTypeIdentifier => StandardTableDataSources.CommentTableDataSource;
public override string Identifier => _identifier;
public override object GetItemKey(UpdatedEventArgs data) => data.DocumentId;
public override object GetItemKey(TodoItemsUpdatedArgs data) => data.DocumentId;
protected override object GetOrUpdateAggregationKey(UpdatedEventArgs data)
protected override object GetOrUpdateAggregationKey(TodoItemsUpdatedArgs data)
{
var key = TryGetAggregateKey(data);
if (key == null)
......@@ -105,7 +106,7 @@ protected override object GetOrUpdateAggregationKey(UpdatedEventArgs data)
return key;
}
if (!CheckAggregateKey((ImmutableArray<DocumentId>)key, data as TodoItemsUpdatedArgs))
if (!CheckAggregateKey((ImmutableArray<DocumentId>)key, data))
{
RemoveStaledData(data);
......@@ -118,24 +119,19 @@ protected override object GetOrUpdateAggregationKey(UpdatedEventArgs data)
private bool CheckAggregateKey(ImmutableArray<DocumentId> key, TodoItemsUpdatedArgs args)
{
if (args?.DocumentId == null || args?.Solution == null)
{
if (args.DocumentId == null || args.Solution == null)
return true;
}
var documents = GetDocumentsWithSameFilePath(args.Solution, args.DocumentId);
return key == documents;
}
private object CreateAggregationKey(UpdatedEventArgs data)
private object CreateAggregationKey(TodoItemsUpdatedArgs data)
{
var args = data as TodoItemsUpdatedArgs;
if (args?.Solution == null)
{
if (data.Solution == null)
return GetItemKey(data);
}
return GetDocumentsWithSameFilePath(args.Solution, args.DocumentId);
return GetDocumentsWithSameFilePath(data.Solution, data.DocumentId);
}
public override AbstractTableEntriesSnapshot<TodoTableItem> CreateSnapshot(AbstractTableEntriesSource<TodoTableItem> source, int version, ImmutableArray<TodoTableItem> items, ImmutableArray<ITrackingPoint> trackingPoints)
......@@ -152,10 +148,8 @@ public override IEnumerable<TodoTableItem> Order(IEnumerable<TodoTableItem> grou
private void PopulateInitialData(Workspace workspace, ITodoListProvider todoListService)
{
foreach (var args in todoListService.GetTodoItemsUpdatedEventArgs(workspace, cancellationToken: CancellationToken.None))
{
OnDataAddedOrChanged(args);
}
foreach (var bucket in todoListService.GetTodoItemBuckets(workspace, cancellationToken: CancellationToken.None))
OnDataAddedOrChanged(new TodoItemsUpdatedArgs(bucket.Id, bucket.Workspace, solution: null, bucket.ProjectId, bucket.DocumentId, ImmutableArray<TodoCommentData>.Empty));
}
private void OnTodoListUpdated(object sender, TodoItemsUpdatedArgs e)
......
......@@ -211,7 +211,7 @@ public ImmutableArray<TodoCommentData> GetTodoItems(Workspace workspace, Documen
: ImmutableArray<TodoCommentData>.Empty;
}
public IEnumerable<UpdatedEventArgs> GetTodoItemsUpdatedEventArgs(
public ImmutableArray<TodoItemBucket> GetTodoItemBuckets(
Workspace workspace, CancellationToken cancellationToken)
{
// Don't need to implement this. OOP pushes all items over to VS. So there's no need
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册