提交 612c38ed 编写于 作者: H Heejae Chang

Merge pull request #2742 from heejaechang/errorAPiFix

moved tableControl APIs to the new ones
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.CodeAnalysis;
using Microsoft.VisualStudio.TableControl;
using Microsoft.VisualStudio.TableManager;
using Microsoft.VisualStudio.Shell.TableManager;
using Roslyn.Utilities;
namespace Microsoft.VisualStudio.LanguageServices.Implementation.TableDataSource
......@@ -17,7 +15,7 @@ internal abstract class AbstractTable<TArgs, TData>
protected readonly AbstractRoslynTableDataSource<TArgs, TData> Source;
protected AbstractTable(Workspace workspace, ITableManagerProvider provider, Guid tableIdentifier, AbstractRoslynTableDataSource<TArgs, TData> source)
protected AbstractTable(Workspace workspace, ITableManagerProvider provider, string tableIdentifier, AbstractRoslynTableDataSource<TArgs, TData> source)
{
_workspace = workspace;
_provider = provider;
......@@ -40,20 +38,16 @@ private void OnWorkspaceChanged(object sender, WorkspaceChangeEventArgs e)
case WorkspaceChangeKind.SolutionAdded:
case WorkspaceChangeKind.ProjectAdded:
AddTableSourceIfNecessary();
SolutionOrProjectChanged(e);
break;
case WorkspaceChangeKind.SolutionRemoved:
case WorkspaceChangeKind.ProjectRemoved:
RemoveTableSourceIfNecessary();
SolutionOrProjectChanged(e);
break;
case WorkspaceChangeKind.SolutionChanged:
case WorkspaceChangeKind.SolutionCleared:
case WorkspaceChangeKind.SolutionReloaded:
case WorkspaceChangeKind.ProjectChanged:
case WorkspaceChangeKind.ProjectReloaded:
SolutionOrProjectChanged(e);
break;
case WorkspaceChangeKind.DocumentAdded:
case WorkspaceChangeKind.DocumentRemoved:
case WorkspaceChangeKind.DocumentReloaded:
......@@ -69,11 +63,6 @@ private void OnWorkspaceChanged(object sender, WorkspaceChangeEventArgs e)
}
}
protected virtual void SolutionOrProjectChanged(WorkspaceChangeEventArgs e)
{
// do nothing in base implementation
}
private void AddTableSourceIfNecessary()
{
if (_workspace.CurrentSolution.ProjectIds.Count == 0 || this.TableManager.Sources.Any(s => s == this.Source))
......@@ -91,6 +80,7 @@ private void RemoveTableSourceIfNecessary()
return;
}
this.Source.Shutdown();
this.TableManager.RemoveSource(this.Source);
}
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.VisualStudio.TableControl;
using Microsoft.VisualStudio.TableManager;
using Microsoft.VisualStudio.Shell.TableControl;
using Microsoft.VisualStudio.Shell.TableManager;
namespace Microsoft.VisualStudio.LanguageServices.Implementation.TableDataSource
{
......
......@@ -6,7 +6,7 @@
using System.Linq;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.SolutionCrawler;
using Microsoft.VisualStudio.TableManager;
using Microsoft.VisualStudio.Shell.TableManager;
namespace Microsoft.VisualStudio.LanguageServices.Implementation.TableDataSource
{
......@@ -24,16 +24,11 @@ public AbstractTableDataSource()
Subscriptions = ImmutableArray<SubscriptionWithoutLock>.Empty;
}
public virtual void OnProjectDependencyChanged(Solution solution)
{
// base implementation does nothing.
}
public abstract string DisplayName { get; }
public abstract Guid SourceTypeIdentifier { get; }
public abstract string SourceTypeIdentifier { get; }
public abstract Guid Identifier { get; }
public abstract string Identifier { get; }
public void Refresh(AbstractTableEntriesFactory<TData> factory)
{
......@@ -45,6 +40,23 @@ public void Refresh(AbstractTableEntriesFactory<TData> factory)
}
}
public void Shutdown()
{
ImmutableArray<SubscriptionWithoutLock> snapshot;
lock (Gate)
{
snapshot = Subscriptions;
Map.Clear();
}
// let table manager know that we want to clear all factories
for (var i = 0; i < snapshot.Length; i++)
{
snapshot[i].RemoveAll();
}
}
protected void ConnectToSolutionCrawlerService(Workspace workspace)
{
var crawlerService = workspace.Services.GetService<ISolutionCrawlerService>();
......@@ -180,7 +192,7 @@ public void AddOrUpdate(ITableEntriesSnapshotFactory provider, bool newFactory)
return;
}
_sink.FactoryUpdated(provider);
_sink.FactorySnapshotChanged(provider);
}
public void Remove(ITableEntriesSnapshotFactory factory)
......@@ -188,6 +200,11 @@ public void Remove(ITableEntriesSnapshotFactory factory)
_sink.RemoveFactory(factory);
}
public void RemoveAll()
{
_sink.RemoveAllFactories();
}
public void Dispose()
{
// REVIEW: will closing task hub dispose this subscription?
......
......@@ -6,8 +6,7 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Text;
using Microsoft.VisualStudio.TableControl;
using Microsoft.VisualStudio.TableManager;
using Microsoft.VisualStudio.Shell.TableManager;
using Microsoft.VisualStudio.Text;
namespace Microsoft.VisualStudio.LanguageServices.Implementation.TableDataSource
......
......@@ -7,8 +7,7 @@
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Text;
using Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem;
using Microsoft.VisualStudio.Shell.Interop;
using Microsoft.VisualStudio.TableManager;
using Microsoft.VisualStudio.Shell.TableManager;
using Microsoft.VisualStudio.Text;
using Roslyn.Utilities;
......@@ -16,9 +15,6 @@ namespace Microsoft.VisualStudio.LanguageServices.Implementation.TableDataSource
{
internal abstract class AbstractTableEntriesSnapshot<TData> : ITableEntriesSnapshot
{
// TODO: remove this once we have new drop
protected const string ProjectGuidKey = "projectguid";
private readonly int _version;
private readonly ImmutableArray<TData> _items;
private ImmutableArray<ITrackingPoint> _trackingPoints;
......@@ -34,7 +30,6 @@ protected AbstractTableEntriesSnapshot(int version, Guid projectGuid, ImmutableA
ProjectGuid = projectGuid;
}
public abstract object SnapshotIdentity { get; }
public abstract bool TryNavigateTo(int index, bool previewTab);
public abstract bool TryGetValue(int index, string columnName, out object content);
protected abstract bool IsEquivalent(TData item1, TData item2);
......@@ -55,7 +50,7 @@ public int Count
}
}
public int TranslateTo(int index, ITableEntriesSnapshot newerSnapshot)
public int IndexOf(int index, ITableEntriesSnapshot newerSnapshot)
{
var item = GetItem(index);
if (item == null)
......@@ -217,23 +212,6 @@ protected string GetProjectName(Workspace workspace, ProjectId projectId)
return project.Name;
}
// TODO: remove this once we moved to new drop
protected IVsHierarchy GetHierarchy(Workspace workspace, ProjectId projectId)
{
if (projectId == null)
{
return null;
}
var vsWorkspace = workspace as VisualStudioWorkspaceImpl;
if (vsWorkspace == null)
{
return null;
}
return vsWorkspace.GetHierarchy(projectId);
}
protected static Guid GetProjectGuid(Workspace workspace, ProjectId projectId)
{
if (projectId == null)
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.ComponentModel.Composition;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.VisualStudio.TableControl;
using Microsoft.VisualStudio.TableManager;
using Microsoft.VisualStudio.Shell.TableControl;
using Microsoft.VisualStudio.Shell.TableManager;
using Microsoft.VisualStudio.Utilities;
namespace Microsoft.VisualStudio.LanguageServices.Implementation.TableDataSource
{
[Export(typeof(ITableControlEventProcessorProvider))]
[DataSourceType(StandardTableDataSources.ErrorTableDataSourceString)]
[DataSourceType(StandardTableDataSources.ErrorTableDataSource)]
[DataSource(VisualStudioDiagnosticListTable.IdentifierString)]
[Name(Name)]
[Order(Before = "default")]
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.ComponentModel.Composition;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.VisualStudio.TableControl;
using Microsoft.VisualStudio.TableManager;
using Microsoft.VisualStudio.Shell.TableControl;
using Microsoft.VisualStudio.Shell.TableManager;
using Microsoft.VisualStudio.Utilities;
namespace Microsoft.VisualStudio.LanguageServices.Implementation.TableDataSource
{
[Export(typeof(ITableControlEventProcessorProvider))]
[DataSourceType(StandardTableDataSources.ErrorTableDataSourceString)]
[DataSourceType(StandardTableDataSources.ErrorTableDataSource)]
[DataSource(MiscellaneousDiagnosticListTable.IdentifierString)]
[Name(Name)]
[Order(Before = "default")]
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.ComponentModel.Composition;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Editor;
using Microsoft.VisualStudio.TableControl;
using Microsoft.VisualStudio.TableManager;
using Microsoft.VisualStudio.Shell.TableControl;
using Microsoft.VisualStudio.Shell.TableManager;
using Microsoft.VisualStudio.Utilities;
namespace Microsoft.VisualStudio.LanguageServices.Implementation.TableDataSource
{
[Export(typeof(ITableControlEventProcessorProvider))]
[DataSourceType(StandardTableDataSources.CommentTableDataSourceString)]
[DataSourceType(StandardTableDataSources.CommentTableDataSource)]
[DataSource(MiscellaneousTodoListTable.IdentifierString)]
[Name(Name)]
[Order(Before = "default")]
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.ComponentModel.Composition;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.TableControl;
using Microsoft.VisualStudio.TableManager;
using Microsoft.VisualStudio.Shell.TableManager;
namespace Microsoft.VisualStudio.LanguageServices.Implementation.TableDataSource
{
[Export(typeof(MiscellaneousDiagnosticListTable))]
internal class MiscellaneousDiagnosticListTable : VisualStudioBaseDiagnosticListTable
{
internal const string IdentifierString = "{55C819C3-98F6-4398-9BE2-5DAC5B690BB8}";
internal static readonly Guid Identifier = new Guid(IdentifierString);
internal const string IdentifierString = nameof(MiscellaneousDiagnosticListTable);
[ImportingConstructor]
public MiscellaneousDiagnosticListTable(
SVsServiceProvider serviceProvider, MiscellaneousFilesWorkspace workspace, IDiagnosticService diagnosticService, ITableManagerProvider provider) :
base(serviceProvider, workspace, diagnosticService, Identifier, provider)
base(serviceProvider, workspace, diagnosticService, IdentifierString, provider)
{
ConnectWorkspaceEvents();
}
/// this is for test only
internal MiscellaneousDiagnosticListTable(Workspace workspace, IDiagnosticService diagnosticService, ITableManagerProvider provider) :
base(null, workspace, diagnosticService, Identifier, provider)
base(null, workspace, diagnosticService, IdentifierString, provider)
{
}
}
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.ComponentModel.Composition;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Editor;
using Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem;
using Microsoft.VisualStudio.TableControl;
using Microsoft.VisualStudio.TableManager;
using Microsoft.VisualStudio.Shell.TableManager;
namespace Microsoft.VisualStudio.LanguageServices.Implementation.TableDataSource
{
[Export(typeof(MiscellaneousTodoListTable))]
internal class MiscellaneousTodoListTable : VisualStudioBaseTodoListTable
{
internal const string IdentifierString = "{A9F23FB3-51C9-46AD-85DC-1FA7669DA32C}";
internal static readonly Guid Identifier = new Guid(IdentifierString);
internal const string IdentifierString = nameof(MiscellaneousTodoListTable);
[ImportingConstructor]
public MiscellaneousTodoListTable(MiscellaneousFilesWorkspace workspace, ITodoListProvider todoListProvider, ITableManagerProvider provider) :
base(workspace, todoListProvider, Identifier, provider)
base(workspace, todoListProvider, IdentifierString, provider)
{
ConnectWorkspaceEvents();
}
// only for test
public MiscellaneousTodoListTable(Workspace workspace, ITodoListProvider todoListProvider, ITableManagerProvider provider) :
base(workspace, todoListProvider, Identifier, provider)
base(workspace, todoListProvider, IdentifierString, provider)
{
}
}
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.ComponentModel.Composition;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Editor;
using Microsoft.VisualStudio.TableControl;
using Microsoft.VisualStudio.TableManager;
using Microsoft.VisualStudio.Shell.TableControl;
using Microsoft.VisualStudio.Shell.TableManager;
using Microsoft.VisualStudio.Utilities;
namespace Microsoft.VisualStudio.LanguageServices.Implementation.TableDataSource
{
[Export(typeof(ITableControlEventProcessorProvider))]
[DataSourceType(StandardTableDataSources.CommentTableDataSourceString)]
[DataSourceType(StandardTableDataSources.CommentTableDataSource)]
[DataSource(VisualStudioTodoListTable.IdentifierString)]
[Name(Name)]
[Order(Before = "default")]
......
......@@ -15,8 +15,8 @@
using Microsoft.VisualStudio.LanguageServices.Implementation.Utilities;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
using Microsoft.VisualStudio.TableControl;
using Microsoft.VisualStudio.TableManager;
using Microsoft.VisualStudio.Shell.TableControl;
using Microsoft.VisualStudio.Shell.TableManager;
using Microsoft.VisualStudio.Text;
using Roslyn.Utilities;
......@@ -39,57 +39,26 @@ internal class VisualStudioBaseDiagnosticListTable : AbstractTable<DiagnosticsUp
};
protected VisualStudioBaseDiagnosticListTable(
SVsServiceProvider serviceProvider, Workspace workspace, IDiagnosticService diagnosticService, Guid identifier, ITableManagerProvider provider) :
SVsServiceProvider serviceProvider, Workspace workspace, IDiagnosticService diagnosticService, string identifier, ITableManagerProvider provider) :
base(workspace, provider, StandardTables.ErrorsTable, new TableDataSource(serviceProvider, workspace, diagnosticService, identifier))
{
}
internal override IReadOnlyCollection<string> Columns { get { return s_columns; } }
protected override void SolutionOrProjectChanged(WorkspaceChangeEventArgs e)
{
if (e.ProjectId == null)
{
// solution level change
this.Source.OnProjectDependencyChanged(e.NewSolution);
return;
}
var oldProject = e.OldSolution.GetProject(e.ProjectId);
var newProject = e.NewSolution.GetProject(e.ProjectId);
if (oldProject == null || newProject == null)
{
// project added or removed
this.Source.OnProjectDependencyChanged(e.NewSolution);
return;
}
if (!object.ReferenceEquals(newProject.AllProjectReferences, oldProject.AllProjectReferences) &&
!newProject.ProjectReferences.SetEquals(oldProject.ProjectReferences))
{
// reference has changed
this.Source.OnProjectDependencyChanged(e.NewSolution);
return;
}
}
private class TableDataSource : AbstractRoslynTableDataSource<DiagnosticsUpdatedArgs, DiagnosticData>
{
private readonly Guid _identifier;
private readonly string _identifier;
private readonly IDiagnosticService _diagnosticService;
private readonly IServiceProvider _serviceProvider;
private readonly Workspace _workspace;
private readonly OpenDocumentTracker _tracker;
private ImmutableDictionary<ProjectId, int> _projectRanks;
public TableDataSource(IServiceProvider serviceProvider, Workspace workspace, IDiagnosticService diagnosticService, Guid identifier)
public TableDataSource(IServiceProvider serviceProvider, Workspace workspace, IDiagnosticService diagnosticService, string identifier)
{
_workspace = workspace;
_serviceProvider = serviceProvider;
_identifier = identifier;
_projectRanks = ImmutableDictionary<ProjectId, int>.Empty;
_tracker = new OpenDocumentTracker(_workspace);
......@@ -99,25 +68,6 @@ public TableDataSource(IServiceProvider serviceProvider, Workspace workspace, ID
ConnectToSolutionCrawlerService(_workspace);
}
public override void OnProjectDependencyChanged(Solution solution)
{
var rankList = solution.GetProjectDependencyGraph().GetTopologicallySortedProjects(CancellationToken.None);
Contract.ThrowIfNull(rankList);
// rank is acsending order
var rank = 0;
var builder = ImmutableDictionary.CreateBuilder<ProjectId, int>();
foreach (var projectId in rankList)
{
builder.Add(projectId, rank++);
}
_projectRanks = builder.ToImmutable();
// project rank has changed, refresh all factories.
this.RefreshAllFactories();
}
public override string DisplayName
{
get
......@@ -126,7 +76,7 @@ public override string DisplayName
}
}
public override Guid SourceTypeIdentifier
public override string SourceTypeIdentifier
{
get
{
......@@ -134,7 +84,7 @@ public override Guid SourceTypeIdentifier
}
}
public override Guid Identifier
public override string Identifier
{
get
{
......@@ -213,7 +163,7 @@ protected override ImmutableArray<ITrackingPoint> GetTrackingPoints(ImmutableArr
protected override AbstractTableEntriesSnapshot<DiagnosticData> CreateSnapshot(
int version, ImmutableArray<DiagnosticData> items, ImmutableArray<ITrackingPoint> trackingPoints)
{
var snapshot = new TableEntriesSnapshot(this, version, GetProjectRank(_projectId), items, trackingPoints);
var snapshot = new TableEntriesSnapshot(this, version, items, trackingPoints);
if (_documentId != null && !trackingPoints.IsDefaultOrEmpty)
{
......@@ -224,43 +174,18 @@ protected override ImmutableArray<ITrackingPoint> GetTrackingPoints(ImmutableArr
return snapshot;
}
private int GetProjectRank(ProjectId projectId)
{
var rank = 0;
if (projectId != null && _source._projectRanks.TryGetValue(projectId, out rank))
{
return rank;
}
return _source._projectRanks.Count;
}
private class TableEntriesSnapshot : AbstractTableEntriesSnapshot<DiagnosticData>, IWpfTableEntriesSnapshot
{
private readonly TableEntriesFactory _factory;
// TODO: remove this once we get new drop
private readonly int _projectRank;
private FrameworkElement[] _descriptions;
public TableEntriesSnapshot(
TableEntriesFactory factory, int version,
int projectRank, ImmutableArray<DiagnosticData> items, ImmutableArray<ITrackingPoint> trackingPoints) :
TableEntriesFactory factory, int version, ImmutableArray<DiagnosticData> items, ImmutableArray<ITrackingPoint> trackingPoints) :
base(version, GetProjectGuid(factory._workspace, factory._projectId), items, trackingPoints)
{
_projectRank = projectRank;
_factory = factory;
}
public override object SnapshotIdentity
{
get
{
return _factory;
}
}
public override bool TryGetValue(int index, string columnName, out object content)
{
// REVIEW: this method is too-chatty to make async, but otherwise, how one can implement it async?
......@@ -274,9 +199,6 @@ public override bool TryGetValue(int index, string columnName, out object conten
switch (columnName)
{
case StandardTableKeyNames.ProjectRank:
content = _projectRank;
return true;
case StandardTableKeyNames.ErrorRank:
content = GetErrorRank(item);
return true;
......@@ -313,13 +235,9 @@ public override bool TryGetValue(int index, string columnName, out object conten
case StandardTableKeyNames.ProjectName:
content = GetProjectName(_factory._workspace, _factory._projectId);
return content != null;
case ProjectGuidKey:
case StandardTableKeyNames.ProjectGuid:
content = ProjectGuid;
return ProjectGuid != Guid.Empty;
case StandardTableKeyNames.Project:
// TODO: remove this once we move to new drop
content = GetHierarchy(_factory._workspace, _factory._projectId);
return content != null;
default:
content = null;
return false;
......
......@@ -11,8 +11,8 @@
using Microsoft.CodeAnalysis.Text;
using Microsoft.VisualStudio.LanguageServices.Implementation.Diagnostics;
using Microsoft.VisualStudio.Shell.Interop;
using Microsoft.VisualStudio.TableControl;
using Microsoft.VisualStudio.TableManager;
using Microsoft.VisualStudio.Shell.TableControl;
using Microsoft.VisualStudio.Shell.TableManager;
using Microsoft.VisualStudio.Text;
using Roslyn.Utilities;
......@@ -27,11 +27,10 @@ internal class VisualStudioBaseTodoListTable : AbstractTable<TaskListEventArgs,
StandardTableColumnDefinitions.ProjectName,
StandardTableColumnDefinitions.DocumentName,
StandardTableColumnDefinitions.Line,
StandardTableColumnDefinitions.Column,
StandardTableColumnDefinitions.TaskCategory
StandardTableColumnDefinitions.Column
};
protected VisualStudioBaseTodoListTable(Workspace workspace, ITodoListProvider todoListProvider, Guid identifier, ITableManagerProvider provider) :
protected VisualStudioBaseTodoListTable(Workspace workspace, ITodoListProvider todoListProvider, string identifier, ITableManagerProvider provider) :
base(workspace, provider, StandardTables.TasksTable, new TableDataSource(workspace, todoListProvider, identifier))
{
}
......@@ -41,10 +40,10 @@ internal class VisualStudioBaseTodoListTable : AbstractTable<TaskListEventArgs,
private class TableDataSource : AbstractRoslynTableDataSource<TaskListEventArgs, TodoTaskItem>
{
private readonly Workspace _workspace;
private readonly Guid _identifier;
private readonly string _identifier;
private readonly ITodoListProvider _todoListProvider;
public TableDataSource(Workspace workspace, ITodoListProvider todoListProvider, Guid identifier)
public TableDataSource(Workspace workspace, ITodoListProvider todoListProvider, string identifier)
{
_workspace = workspace;
_identifier = identifier;
......@@ -62,7 +61,7 @@ public override string DisplayName
}
}
public override Guid SourceTypeIdentifier
public override string SourceTypeIdentifier
{
get
{
......@@ -70,7 +69,7 @@ public override Guid SourceTypeIdentifier
}
}
public override Guid Identifier
public override string Identifier
{
get
{
......@@ -148,14 +147,6 @@ private class TableEntriesSnapshot : AbstractTableEntriesSnapshot<TodoTaskItem>
_factory = factory;
}
public override object SnapshotIdentity
{
get
{
return _factory;
}
}
public override bool TryGetValue(int index, string columnName, out object content)
{
// REVIEW: this method is too-chatty to make async, but otherwise, how one can implement it async?
......@@ -187,13 +178,9 @@ public override bool TryGetValue(int index, string columnName, out object conten
case StandardTableKeyNames.ProjectName:
content = GetProjectName(_factory._workspace, _factory._documentId.ProjectId);
return content != null;
case ProjectGuidKey:
case StandardTableKeyNames.ProjectGuid:
content = ProjectGuid;
return ProjectGuid != Guid.Empty;
case StandardTableKeyNames.Project:
// TODO: remove this once moved to new drop
content = GetHierarchy(_factory._workspace, _factory._documentId.ProjectId);
return content != null;
case StandardTableKeyNames.TaskCategory:
content = VSTASKCATEGORY.CAT_COMMENTS;
return true;
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.ComponentModel.Composition;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.TableControl;
using Microsoft.VisualStudio.TableManager;
using Microsoft.VisualStudio.Shell.TableManager;
namespace Microsoft.VisualStudio.LanguageServices.Implementation.TableDataSource
{
[Export(typeof(VisualStudioDiagnosticListTable))]
internal class VisualStudioDiagnosticListTable : VisualStudioBaseDiagnosticListTable
{
internal const string IdentifierString = "{30EE579B-4C9E-432A-9EBD-BF55D0EA47FF}";
internal static readonly Guid Identifier = new Guid(IdentifierString);
internal const string IdentifierString = nameof(VisualStudioDiagnosticListTable);
[ImportingConstructor]
public VisualStudioDiagnosticListTable(
SVsServiceProvider serviceProvider, VisualStudioWorkspace workspace, IDiagnosticService diagnosticService, ITableManagerProvider provider) :
base(serviceProvider, workspace, diagnosticService, Identifier, provider)
base(serviceProvider, workspace, diagnosticService, IdentifierString, provider)
{
ConnectWorkspaceEvents();
// create initial project rank map
this.Source.OnProjectDependencyChanged(workspace.CurrentSolution);
}
/// this is for test only
internal VisualStudioDiagnosticListTable(Workspace workspace, IDiagnosticService diagnosticService, ITableManagerProvider provider) :
base(null, workspace, diagnosticService, Identifier, provider)
base(null, workspace, diagnosticService, IdentifierString, provider)
{
}
}
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.ComponentModel.Composition;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Editor;
using Microsoft.VisualStudio.TableControl;
using Microsoft.VisualStudio.TableManager;
using Microsoft.VisualStudio.Shell.TableManager;
namespace Microsoft.VisualStudio.LanguageServices.Implementation.TableDataSource
{
[Export(typeof(VisualStudioTodoListTable))]
internal class VisualStudioTodoListTable : VisualStudioBaseTodoListTable
{
internal const string IdentifierString = "{036B243C-81E5-4360-8F9D-D105A64BF04C}";
internal static readonly Guid Identifier = new Guid(IdentifierString);
internal const string IdentifierString = nameof(VisualStudioTodoListTable);
[ImportingConstructor]
public VisualStudioTodoListTable(VisualStudioWorkspace workspace, ITodoListProvider todoListProvider, ITableManagerProvider provider) :
base(workspace, todoListProvider, Identifier, provider)
base(workspace, todoListProvider, IdentifierString, provider)
{
ConnectWorkspaceEvents();
}
// only for test
public VisualStudioTodoListTable(Workspace workspace, ITodoListProvider todoListProvider, ITableManagerProvider provider) :
base(workspace, todoListProvider, Identifier, provider)
base(workspace, todoListProvider, IdentifierString, provider)
{
}
}
......
......@@ -239,6 +239,7 @@
<Reference Include="Microsoft.VisualStudio.Shell.Immutable.10.0, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.VisualStudio.Shell.Immutable.11.0, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.VisualStudio.Shell.Immutable.12.0, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.VisualStudio.Shell.Immutable.14.0, Version=$(VisualStudioReferenceAssemblyVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.VisualStudio.Shell.Interop, Version=7.1.40304.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.VisualStudio.Shell.Interop.10.0, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<EmbedInteropTypes>True</EmbedInteropTypes>
......@@ -255,7 +256,6 @@
<Reference Include="Microsoft.VisualStudio.Text.Logic, Version=$(VisualStudioReferenceAssemblyVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.VisualStudio.Text.UI, Version=$(VisualStudioReferenceAssemblyVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.VisualStudio.Text.UI.Wpf, Version=$(VisualStudioReferenceAssemblyVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.VisualStudio.Text.Internal, Version=$(VisualStudioReferenceAssemblyVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.VisualStudio.TextManager.Interop, Version=7.1.40304.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.VisualStudio.TextManager.Interop.8.0, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.VisualStudio.Threading, Version=$(VisualStudioReferenceAssemblyVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
......
......@@ -11,8 +11,8 @@ Imports Microsoft.CodeAnalysis.Diagnostics
Imports Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces
Imports Microsoft.CodeAnalysis.Text
Imports Microsoft.VisualStudio.LanguageServices.Implementation.TableDataSource
Imports Microsoft.VisualStudio.TableControl
Imports Microsoft.VisualStudio.TableManager
Imports Microsoft.VisualStudio.Shell.TableControl
Imports Microsoft.VisualStudio.Shell.TableManager
Imports Roslyn.Test.Utilities
Imports Roslyn.Utilities
......@@ -460,35 +460,6 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Diagnostics
End Using
End Sub
<Fact>
Public Sub TestProjectRank()
Using workspace = CSharpWorkspaceFactory.CreateWorkspaceFromLines(String.Empty)
Dim documentId = workspace.CurrentSolution.Projects.First().DocumentIds.First()
Dim projectId = documentId.ProjectId
Dim item1 = CreateItem(workspace, projectId, documentId, DiagnosticSeverity.Error)
Dim provider = New TestDiagnosticService(item1)
Dim tableManagerProvider = New TestTableManagerProvider()
Dim table = New VisualStudioDiagnosticListTable(workspace, provider, tableManagerProvider)
provider.RaiseDiagnosticsUpdated(workspace)
Dim manager = DirectCast(table.TableManager, TestTableManagerProvider.TestTableManager)
Dim source = DirectCast(manager.Sources.First(), AbstractRoslynTableDataSource(Of DiagnosticsUpdatedArgs, DiagnosticData))
Dim sinkAndSubscription = manager.Sinks_TestOnly.First()
Dim sink = DirectCast(sinkAndSubscription.Key, TestTableManagerProvider.TestTableManager.TestSink)
Dim snapshot = sink.Entries.First().GetCurrentSnapshot()
Assert.Equal(1, snapshot.Count)
Dim content As Object = Nothing
Assert.True(snapshot.TryGetValue(0, StandardTableKeyNames.ProjectRank, content))
Assert.NotNull(content)
Assert.Equal(CType(content, Integer), 0)
End Using
End Sub
<Fact>
Public Sub TestErrorSource()
Using workspace = CSharpWorkspaceFactory.CreateWorkspaceFromLines(String.Empty)
......
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System.Collections.Immutable
Imports Microsoft.VisualStudio.TableControl
Imports Microsoft.VisualStudio.TableManager
Imports Microsoft.VisualStudio.Shell.TableControl
Imports Microsoft.VisualStudio.Shell.TableManager
Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Diagnostics
Friend Class TestTableManagerProvider
Implements ITableManagerProvider
Public Function GetTableManager(identifier As Guid) As ITableManager Implements ITableManagerProvider.GetTableManager
Public Function GetTableManager(identifier As String) As ITableManager Implements ITableManagerProvider.GetTableManager
Return New TestTableManager(identifier)
End Function
Public Class TestTableManager
Implements ITableManager
Private ReadOnly _identifier As Guid
Private ReadOnly _identifier As String
Private ReadOnly _sources As Dictionary(Of ITableDataSource, String())
Private ReadOnly _sinks As Dictionary(Of ITableDataSink, IDisposable)
Public Sub New(identifier As Guid)
Public Sub New(identifier As String)
Me._identifier = identifier
Me._sources = New Dictionary(Of ITableDataSource, String())()
Me._sinks = New Dictionary(Of ITableDataSink, IDisposable)()
End Sub
Public ReadOnly Property Identifier As Guid Implements ITableManager.Identifier
Public ReadOnly Property Identifier As String Implements ITableManager.Identifier
Get
Return _identifier
End Get
......@@ -99,7 +99,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Diagnostics
Me.Entries.Add(newFactory)
End Sub
Public Sub FactoryUpdated(factory As ITableEntriesSnapshotFactory) Implements ITableDataSink.FactoryUpdated
Public Sub FactorySnapshotChanged(factory As ITableEntriesSnapshotFactory) Implements ITableDataSink.FactorySnapshotChanged
End Sub
Public Sub AddEntries(newEntries As IReadOnlyList(Of ITableEntry), Optional removeEverything As Boolean = False) Implements ITableDataSink.AddEntries
......@@ -110,10 +110,6 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Diagnostics
Throw New NotImplementedException()
End Sub
Public Sub PostChange(Optional oldEntries As IReadOnlyList(Of ITableEntry) = Nothing, Optional newEntries As IReadOnlyList(Of ITableEntry) = Nothing, Optional oldSnapshot As ITableEntriesSnapshot = Nothing, Optional newSnapshot As ITableEntriesSnapshot = Nothing, Optional oldFactory As ITableEntriesSnapshotFactory = Nothing, Optional newFactory As ITableEntriesSnapshotFactory = Nothing, Optional removeEverything As Boolean = False) Implements ITableDataSink.PostChange
Throw New NotImplementedException()
End Sub
Public Sub RemoveEntries(oldEntries As IReadOnlyList(Of ITableEntry)) Implements ITableDataSink.RemoveEntries
Throw New NotImplementedException()
End Sub
......@@ -130,6 +126,18 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Diagnostics
Throw New NotImplementedException()
End Sub
Public Sub RemoveAllEntries() Implements ITableDataSink.RemoveAllEntries
Throw New NotImplementedException()
End Sub
Public Sub RemoveAllSnapshots() Implements ITableDataSink.RemoveAllSnapshots
Throw New NotImplementedException()
End Sub
Public Sub RemoveAllFactories() Implements ITableDataSink.RemoveAllFactories
Throw New NotImplementedException()
End Sub
Public Property IsStable As Boolean Implements ITableDataSink.IsStable
Get
Throw New NotImplementedException()
......
......@@ -7,8 +7,8 @@ Imports Microsoft.CodeAnalysis.Editor
Imports Microsoft.CodeAnalysis.Editor.Implementation.TodoComments
Imports Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces
Imports Microsoft.VisualStudio.LanguageServices.Implementation.TableDataSource
Imports Microsoft.VisualStudio.TableControl
Imports Microsoft.VisualStudio.TableManager
Imports Microsoft.VisualStudio.Shell.TableControl
Imports Microsoft.VisualStudio.Shell.TableManager
Imports Roslyn.Test.Utilities
Imports Roslyn.Utilities
......@@ -205,7 +205,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Diagnostics
Dim snapshot2 = factory.GetCurrentSnapshot()
Assert.Equal(0, snapshot1.TranslateTo(0, snapshot2))
Assert.Equal(0, snapshot1.IndexOf(0, snapshot2))
End Using
End Sub
......@@ -238,7 +238,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Diagnostics
provider.RaiseTodoListUpdated(workspace)
Dim snapshot2 = factory.GetCurrentSnapshot()
Assert.Equal(1, snapshot1.TranslateTo(0, snapshot2))
Assert.Equal(1, snapshot1.IndexOf(0, snapshot2))
End Using
End Sub
......@@ -271,7 +271,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Diagnostics
provider.RaiseTodoListUpdated(workspace)
Dim snapshot2 = factory.GetCurrentSnapshot()
Assert.Equal(-1, snapshot1.TranslateTo(0, snapshot2))
Assert.Equal(-1, snapshot1.IndexOf(0, snapshot2))
End Using
End Sub
......
......@@ -150,6 +150,7 @@
<Reference Include="Microsoft.VisualStudio.Shell.Immutable.10.0, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.VisualStudio.Shell.Immutable.11.0, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.VisualStudio.Shell.Immutable.12.0, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.VisualStudio.Shell.Immutable.14.0, Version=$(VisualStudioReferenceAssemblyVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.VisualStudio.Shell.Interop, Version=7.1.40304.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.VisualStudio.Shell.Interop.10.0, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<EmbedInteropTypes>True</EmbedInteropTypes>
......@@ -158,7 +159,6 @@
<Reference Include="Microsoft.VisualStudio.Shell.Interop.11.0, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<EmbedInteropTypes>True</EmbedInteropTypes>
</Reference>
<Reference Include="Microsoft.VisualStudio.Text.Internal, Version=$(VisualStudioReferenceAssemblyVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.VisualStudio.Text.Data, Version=$(VisualStudioReferenceAssemblyVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.VisualStudio.Text.Logic, Version=$(VisualStudioReferenceAssemblyVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.VisualStudio.Text.UI, Version=$(VisualStudioReferenceAssemblyVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册