Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
e22799b5
R
roslyn
项目概览
lwm1986
/
roslyn
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
roslyn
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
e22799b5
编写于
9月 22, 2020
作者:
C
CyrusNajmabadi
提交者:
GitHub
9月 22, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #47924 from CyrusNajmabadi/diagnosticServiceCleanup
Diagnostic service cleanup
上级
ecf09687
4cbaec3c
变更
17
隐藏空白更改
内联
并排
Showing
17 changed file
with
234 addition
and
215 deletion
+234
-215
src/EditorFeatures/Core/Implementation/Diagnostics/AbstractDiagnosticsTaggerProvider.cs
...entation/Diagnostics/AbstractDiagnosticsTaggerProvider.cs
+6
-6
src/EditorFeatures/Core/Implementation/TodoComment/ITodoListProvider.cs
...ures/Core/Implementation/TodoComment/ITodoListProvider.cs
+0
-7
src/EditorFeatures/Test/Diagnostics/MockDiagnosticService.cs
src/EditorFeatures/Test/Diagnostics/MockDiagnosticService.cs
+6
-18
src/Features/Core/Portable/Diagnostics/DiagnosticBucket.cs
src/Features/Core/Portable/Diagnostics/DiagnosticBucket.cs
+39
-0
src/Features/Core/Portable/Diagnostics/DiagnosticService.cs
src/Features/Core/Portable/Diagnostics/DiagnosticService.cs
+37
-51
src/Features/Core/Portable/Diagnostics/IDiagnosticService.cs
src/Features/Core/Portable/Diagnostics/IDiagnosticService.cs
+7
-5
src/Features/Core/Portable/Diagnostics/IDiagnosticServiceExtensions.cs
...Core/Portable/Diagnostics/IDiagnosticServiceExtensions.cs
+36
-0
src/VisualStudio/Core/Def/Implementation/TableDataSource/AbstractRoslynTableDataSource.cs
...entation/TableDataSource/AbstractRoslynTableDataSource.cs
+1
-1
src/VisualStudio/Core/Def/Implementation/TableDataSource/AbstractTableDataSource.cs
...Implementation/TableDataSource/AbstractTableDataSource.cs
+21
-21
src/VisualStudio/Core/Def/Implementation/TableDataSource/TableEntriesFactory.cs
...Def/Implementation/TableDataSource/TableEntriesFactory.cs
+11
-11
src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioBaseDiagnosticListTable.LiveTableDataSource.cs
...isualStudioBaseDiagnosticListTable.LiveTableDataSource.cs
+15
-15
src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioBaseTodoListTable.cs
...entation/TableDataSource/VisualStudioBaseTodoListTable.cs
+9
-23
src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioDiagnosticListTable.BuildTableDataSource.cs
...e/VisualStudioDiagnosticListTable.BuildTableDataSource.cs
+1
-1
src/VisualStudio/Core/Def/Implementation/TodoComments/VisualStudioTodoCommentsService.cs
...mentation/TodoComments/VisualStudioTodoCommentsService.cs
+0
-7
src/VisualStudio/Core/Test.Next/Services/LspDiagnosticsTests.cs
...sualStudio/Core/Test.Next/Services/LspDiagnosticsTests.cs
+4
-4
src/VisualStudio/Core/Test/Diagnostics/DiagnosticTableDataSourceTests.vb
...o/Core/Test/Diagnostics/DiagnosticTableDataSourceTests.vb
+27
-27
src/VisualStudio/Core/Test/Diagnostics/TodoListTableDataSourceTests.vb
...dio/Core/Test/Diagnostics/TodoListTableDataSourceTests.vb
+14
-18
未找到文件。
src/EditorFeatures/Core/Implementation/Diagnostics/AbstractDiagnosticsTaggerProvider.cs
浏览文件 @
e22799b5
...
...
@@ -152,14 +152,14 @@ private void ProduceTags(TaggerContext<TTag> context, DocumentSnapshotSpan spanT
var
suppressedDiagnosticsSpans
=
(
NormalizedSnapshotSpanCollection
?)
null
;
buffer
?.
Properties
.
TryGetProperty
(
PredefinedPreviewTaggerKeys
.
SuppressDiagnosticsSpansKey
,
out
suppressedDiagnosticsSpans
);
var
eventArgs
=
_diagnosticService
.
GetDiagnosticsUpdatedEventArg
s
(
var
buckets
=
_diagnosticService
.
GetDiagnosticBucket
s
(
workspace
,
document
.
Project
.
Id
,
document
.
Id
,
context
.
CancellationToken
);
foreach
(
var
updateArg
in
eventArg
s
)
foreach
(
var
bucket
in
bucket
s
)
{
ProduceTags
(
context
,
spanToTag
,
workspace
,
document
,
suppressedDiagnosticsSpans
,
updateArg
,
cancellationToken
);
suppressedDiagnosticsSpans
,
bucket
,
cancellationToken
);
}
}
...
...
@@ -167,13 +167,13 @@ private void ProduceTags(TaggerContext<TTag> context, DocumentSnapshotSpan spanT
TaggerContext
<
TTag
>
context
,
DocumentSnapshotSpan
spanToTag
,
Workspace
workspace
,
Document
document
,
NormalizedSnapshotSpanCollection
?
suppressedDiagnosticsSpans
,
UpdatedEventArgs
updateArgs
,
CancellationToken
cancellationToken
)
DiagnosticBucket
bucket
,
CancellationToken
cancellationToken
)
{
try
{
var
id
=
updateArgs
.
Id
;
var
id
=
bucket
.
Id
;
var
diagnostics
=
_diagnosticService
.
GetDiagnostics
(
workspace
,
document
.
Project
.
Id
,
document
.
Id
,
id
,
false
,
cancellationToken
);
workspace
,
document
.
Project
.
Id
,
document
.
Id
,
id
,
includeSuppressedDiagnostics
:
false
,
cancellationToken
);
var
isLiveUpdate
=
id
is
ISupportLiveUpdate
;
...
...
src/EditorFeatures/Core/Implementation/TodoComment/ITodoListProvider.cs
浏览文件 @
e22799b5
...
...
@@ -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
...
...
@@ -25,10 +23,5 @@ internal interface ITodoListProvider
event
EventHandler
<
TodoItemsUpdatedArgs
>
TodoListUpdated
;
ImmutableArray
<
TodoCommentData
>
GetTodoItems
(
Workspace
workspace
,
DocumentId
documentId
,
CancellationToken
cancellationToken
);
/// <summary>
/// Get current UpdatedEventArgs stored in ITodoListProvider
/// </summary>
IEnumerable
<
UpdatedEventArgs
>
GetTodoItemsUpdatedEventArgs
(
Workspace
workspace
,
CancellationToken
cancellationToken
);
}
}
src/EditorFeatures/Test/Diagnostics/MockDiagnosticService.cs
浏览文件 @
e22799b5
...
...
@@ -34,34 +34,22 @@ public MockDiagnosticService()
{
}
public
I
Enumerable
<
DiagnosticData
>
GetDiagnostics
(
Workspace
workspace
,
ProjectId
projectId
,
DocumentId
documentId
,
object
id
,
bool
includeSuppressedDiagnostics
,
CancellationToken
cancellationToken
)
public
I
mmutableArray
<
DiagnosticData
>
GetDiagnostics
(
Workspace
workspace
,
ProjectId
?
projectId
,
DocumentId
?
documentId
,
object
?
id
,
bool
includeSuppressedDiagnostics
,
CancellationToken
cancellationToken
)
{
Assert
.
Equal
(
projectId
,
GetProjectId
(
workspace
));
Assert
.
Equal
(
documentId
,
GetDocumentId
(
workspace
));
if
(
_diagnostic
==
null
)
{
yield
break
;
}
else
{
yield
return
_diagnostic
;
}
return
_diagnostic
==
null
?
ImmutableArray
<
DiagnosticData
>.
Empty
:
ImmutableArray
.
Create
(
_diagnostic
);
}
public
I
Enumerable
<
UpdatedEventArgs
>
GetDiagnosticsUpdatedEventArgs
(
Workspace
workspace
,
ProjectId
projectId
,
DocumentId
documentId
,
CancellationToken
cancellationToken
)
public
I
mmutableArray
<
DiagnosticBucket
>
GetDiagnosticBuckets
(
Workspace
workspace
,
ProjectId
?
projectId
,
DocumentId
?
documentId
,
CancellationToken
cancellationToken
)
{
Assert
.
Equal
(
projectId
,
GetProjectId
(
workspace
));
Assert
.
Equal
(
documentId
,
GetDocumentId
(
workspace
));
if
(
_diagnostic
==
null
)
{
yield
break
;
}
else
{
yield
return
new
UpdatedEventArgs
(
this
,
workspace
,
GetProjectId
(
workspace
),
GetDocumentId
(
workspace
));
}
return
_diagnostic
==
null
?
ImmutableArray
<
DiagnosticBucket
>.
Empty
:
ImmutableArray
.
Create
(
new
DiagnosticBucket
(
this
,
workspace
,
GetProjectId
(
workspace
),
GetDocumentId
(
workspace
)));
}
internal
void
CreateDiagnosticAndFireEvents
(
Workspace
workspace
,
Location
location
)
...
...
src/Features/Core/Portable/Diagnostics/DiagnosticBucket.cs
0 → 100644
浏览文件 @
e22799b5
// 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.Diagnostics
{
internal
readonly
struct
DiagnosticBucket
{
/// <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
DiagnosticBucket
(
object
id
,
Workspace
workspace
,
ProjectId
?
projectId
,
DocumentId
?
documentId
)
{
Id
=
id
;
Workspace
=
workspace
;
ProjectId
=
projectId
;
DocumentId
=
documentId
;
}
}
}
src/Features/Core/Portable/Diagnostics/DiagnosticService.cs
浏览文件 @
e22799b5
...
...
@@ -12,6 +12,7 @@
using
Microsoft.CodeAnalysis.Common
;
using
Microsoft.CodeAnalysis.Host
;
using
Microsoft.CodeAnalysis.Host.Mef
;
using
Microsoft.CodeAnalysis.PooledObjects
;
using
Microsoft.CodeAnalysis.Shared.TestHooks
;
using
Roslyn.Utilities
;
...
...
@@ -201,7 +202,7 @@ private void OnCleared(object sender, EventArgs e)
RaiseDiagnosticsCleared
((
IDiagnosticUpdateSource
)
sender
);
}
public
I
Enumerable
<
DiagnosticData
>
GetDiagnostics
(
public
I
mmutableArray
<
DiagnosticData
>
GetDiagnostics
(
Workspace
workspace
,
ProjectId
projectId
,
DocumentId
documentId
,
object
id
,
bool
includeSuppressedDiagnostics
,
CancellationToken
cancellationToken
)
{
if
(
id
!=
null
)
...
...
@@ -214,108 +215,93 @@ private void OnCleared(object sender, EventArgs e)
return
GetDiagnostics
(
workspace
,
projectId
,
documentId
,
includeSuppressedDiagnostics
,
cancellationToken
);
}
private
I
Enumerable
<
DiagnosticData
>
GetSpecificDiagnostics
(
Workspace
workspace
,
ProjectId
projectId
,
DocumentId
documentId
,
object
id
,
bool
includeSuppressedDiagnostics
,
CancellationToken
cancellationToken
)
private
I
mmutableArray
<
DiagnosticData
>
GetSpecificDiagnostics
(
Workspace
workspace
,
ProjectId
projectId
,
DocumentId
documentId
,
object
id
,
bool
includeSuppressedDiagnostics
,
CancellationToken
cancellationToken
)
{
using
var
_
=
ArrayBuilder
<
Data
>.
GetInstance
(
out
var
buffer
);
foreach
(
var
source
in
_updateSources
)
{
cancellationToken
.
ThrowIfCancellationRequested
();
buffer
.
Clear
();
if
(
source
.
SupportGetDiagnostics
)
{
var
diagnostics
=
source
.
GetDiagnostics
(
workspace
,
projectId
,
documentId
,
id
,
includeSuppressedDiagnostics
,
cancellationToken
);
if
(
diagnostics
!=
null
&&
diagnostics
.
Length
>
0
)
{
if
(
diagnostics
.
Length
>
0
)
return
diagnostics
;
}
}
else
{
using
var
pool
=
SharedPools
.
Default
<
List
<
Data
>>().
GetPooledObject
();
AppendMatchingData
(
source
,
workspace
,
projectId
,
documentId
,
id
,
buffer
);
Debug
.
Assert
(
buffer
.
Count
==
0
||
buffer
.
Count
==
1
);
AppendMatchingData
(
source
,
workspace
,
projectId
,
documentId
,
id
,
pool
.
Object
);
Debug
.
Assert
(
pool
.
Object
.
Count
==
0
||
pool
.
Object
.
Count
==
1
);
if
(
pool
.
Object
.
Count
==
1
)
if
(
buffer
.
Count
==
1
)
{
var
diagnostics
=
pool
.
Object
[
0
].
Diagnostics
;
return
!
includeSuppressedDiagnostics
?
FilterSuppressedDiagnostics
(
diagnostics
)
:
diagnostics
;
var
diagnostics
=
buffer
[
0
].
Diagnostics
;
return
includeSuppressedDiagnostics
?
diagnostics
:
diagnostics
.
NullToEmpty
().
WhereAsArray
(
d
=>
!
d
.
IsSuppressed
);
}
}
}
return
SpecializedCollections
.
EmptyEnumerable
<
DiagnosticData
>()
;
return
ImmutableArray
<
DiagnosticData
>.
Empty
;
}
private
static
IEnumerable
<
DiagnosticData
>
FilterSuppressedDiagnostics
(
ImmutableArray
<
DiagnosticData
>
diagnostics
)
{
if
(!
diagnostics
.
IsDefault
)
{
foreach
(
var
diagnostic
in
diagnostics
)
{
if
(!
diagnostic
.
IsSuppressed
)
{
yield
return
diagnostic
;
}
}
}
}
private
IEnumerable
<
DiagnosticData
>
GetDiagnostics
(
private
ImmutableArray
<
DiagnosticData
>
GetDiagnostics
(
Workspace
workspace
,
ProjectId
projectId
,
DocumentId
documentId
,
bool
includeSuppressedDiagnostics
,
CancellationToken
cancellationToken
)
{
using
var
_1
=
ArrayBuilder
<
DiagnosticData
>.
GetInstance
(
out
var
result
);
using
var
_2
=
ArrayBuilder
<
Data
>.
GetInstance
(
out
var
buffer
);
foreach
(
var
source
in
_updateSources
)
{
cancellationToken
.
ThrowIfCancellationRequested
();
buffer
.
Clear
();
if
(
source
.
SupportGetDiagnostics
)
{
foreach
(
var
diagnostic
in
source
.
GetDiagnostics
(
workspace
,
projectId
,
documentId
,
null
,
includeSuppressedDiagnostics
,
cancellationToken
))
{
AssertIfNull
(
diagnostic
);
yield
return
diagnostic
;
}
result
.
AddRange
(
source
.
GetDiagnostics
(
workspace
,
projectId
,
documentId
,
id
:
null
,
includeSuppressedDiagnostics
,
cancellationToken
));
}
else
{
using
var
list
=
SharedPools
.
Default
<
List
<
Data
>>().
GetPooledObject
(
);
AppendMatchingData
(
source
,
workspace
,
projectId
,
documentId
,
id
:
null
,
buffer
);
AppendMatchingData
(
source
,
workspace
,
projectId
,
documentId
,
null
,
list
.
Object
);
foreach
(
var
data
in
list
.
Object
)
foreach
(
var
data
in
buffer
)
{
foreach
(
var
diagnostic
in
data
.
Diagnostics
)
{
AssertIfNull
(
diagnostic
);
if
(
includeSuppressedDiagnostics
||
!
diagnostic
.
IsSuppressed
)
{
yield
return
diagnostic
;
}
result
.
Add
(
diagnostic
);
}
}
}
}
return
result
.
ToImmutable
();
}
public
I
Enumerable
<
UpdatedEventArgs
>
GetDiagnosticsUpdatedEventArg
s
(
public
I
mmutableArray
<
DiagnosticBucket
>
GetDiagnosticBucket
s
(
Workspace
workspace
,
ProjectId
projectId
,
DocumentId
documentId
,
CancellationToken
cancellationToken
)
{
using
var
_1
=
ArrayBuilder
<
DiagnosticBucket
>.
GetInstance
(
out
var
result
);
using
var
_2
=
ArrayBuilder
<
Data
>.
GetInstance
(
out
var
buffer
);
foreach
(
var
source
in
_updateSources
)
{
buffer
.
Clear
();
cancellationToken
.
ThrowIfCancellationRequested
();
using
var
list
=
SharedPools
.
Default
<
List
<
Data
>>().
GetPooledObject
();
AppendMatchingData
(
source
,
workspace
,
projectId
,
documentId
,
null
,
list
.
Object
);
foreach
(
var
data
in
list
.
Object
)
{
yield
return
new
UpdatedEventArgs
(
data
.
Id
,
data
.
Workspace
,
data
.
ProjectId
,
data
.
DocumentId
);
}
AppendMatchingData
(
source
,
workspace
,
projectId
,
documentId
,
id
:
null
,
buffer
);
foreach
(
var
data
in
buffer
)
result
.
Add
(
new
DiagnosticBucket
(
data
.
Id
,
data
.
Workspace
,
data
.
ProjectId
,
data
.
DocumentId
));
}
return
result
.
ToImmutable
();
}
private
void
AppendMatchingData
(
IDiagnosticUpdateSource
source
,
Workspace
workspace
,
ProjectId
projectId
,
DocumentId
documentId
,
object
id
,
List
<
Data
>
list
)
IDiagnosticUpdateSource
source
,
Workspace
workspace
,
ProjectId
projectId
,
DocumentId
documentId
,
object
id
,
ArrayBuilder
<
Data
>
list
)
{
Contract
.
ThrowIfNull
(
workspace
);
...
...
@@ -349,7 +335,7 @@ private static IEnumerable<DiagnosticData> FilterSuppressedDiagnostics(Immutable
}
}
private
static
bool
TryAddData
<
T
>(
Workspace
workspace
,
T
key
,
Data
data
,
Func
<
Data
,
T
>
keyGetter
,
List
<
Data
>
result
)
where
T
:
class
private
static
bool
TryAddData
<
T
>(
Workspace
workspace
,
T
key
,
Data
data
,
Func
<
Data
,
T
>
keyGetter
,
ArrayBuilder
<
Data
>
result
)
where
T
:
class
{
if
(
key
==
null
)
{
...
...
src/Features/Core/Portable/Diagnostics/IDiagnosticService.cs
浏览文件 @
e22799b5
...
...
@@ -2,10 +2,11 @@
// 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
using
System
;
using
System.Collections.
Generic
;
using
System.Collections.
Immutable
;
using
System.Threading
;
using
Microsoft.CodeAnalysis.Common
;
namespace
Microsoft.CodeAnalysis.Diagnostics
{
...
...
@@ -25,11 +26,12 @@ internal interface IDiagnosticService
/// <summary>
/// Get current diagnostics stored in IDiagnosticUpdateSource
/// </summary>
I
Enumerable
<
DiagnosticData
>
GetDiagnostics
(
Workspace
workspace
,
ProjectId
projectId
,
DocumentId
documentId
,
object
id
,
bool
includeSuppressedDiagnostics
,
CancellationToken
cancellationToken
);
I
mmutableArray
<
DiagnosticData
>
GetDiagnostics
(
Workspace
workspace
,
ProjectId
?
projectId
,
DocumentId
?
documentId
,
object
?
id
,
bool
includeSuppressedDiagnostics
,
CancellationToken
cancellationToken
);
/// <summary>
/// Get current UpdatedEventArgs stored in IDiagnosticUpdateSource
/// Get current buckets stored our diagnostics are grouped into. Specific buckets can be retrieved by calling
/// <see cref="IDiagnosticServiceExtensions.GetDiagnostics(IDiagnosticService, DiagnosticBucket, bool, CancellationToken)"/>.
/// </summary>
I
Enumerable
<
UpdatedEventArgs
>
GetDiagnosticsUpdatedEventArgs
(
Workspace
workspace
,
ProjectId
projectId
,
DocumentId
documentId
,
CancellationToken
cancellationToken
);
I
mmutableArray
<
DiagnosticBucket
>
GetDiagnosticBuckets
(
Workspace
workspace
,
ProjectId
?
projectId
,
DocumentId
?
documentId
,
CancellationToken
cancellationToken
);
}
}
src/Features/Core/Portable/Diagnostics/IDiagnosticServiceExtensions.cs
0 → 100644
浏览文件 @
e22799b5
// 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.
using
System.Collections.Immutable
;
using
System.Threading
;
using
Microsoft.CodeAnalysis.PooledObjects
;
using
Roslyn.Utilities
;
namespace
Microsoft.CodeAnalysis.Diagnostics
{
internal
static
class
IDiagnosticServiceExtensions
{
public
static
ImmutableArray
<
DiagnosticData
>
GetDiagnostics
(
this
IDiagnosticService
service
,
DiagnosticBucket
bucket
,
bool
includeSuppressedDiagnostics
,
CancellationToken
cancellationToken
)
=>
service
.
GetDiagnostics
(
bucket
.
Workspace
,
bucket
.
ProjectId
,
bucket
.
DocumentId
,
bucket
.
Id
,
includeSuppressedDiagnostics
,
cancellationToken
);
public
static
ImmutableArray
<
DiagnosticData
>
GetDiagnostics
(
this
IDiagnosticService
service
,
Document
document
,
bool
includeSuppressedDiagnostics
,
CancellationToken
cancellationToken
)
{
var
project
=
document
.
Project
;
var
workspace
=
project
.
Solution
.
Workspace
;
using
var
_
=
ArrayBuilder
<
DiagnosticData
>.
GetInstance
(
out
var
result
);
foreach
(
var
bucket
in
service
.
GetDiagnosticBuckets
(
workspace
,
project
.
Id
,
document
.
Id
,
cancellationToken
))
{
Contract
.
ThrowIfFalse
(
workspace
.
Equals
(
bucket
.
Workspace
));
Contract
.
ThrowIfFalse
(
document
.
Id
.
Equals
(
bucket
.
DocumentId
));
var
diagnostics
=
service
.
GetDiagnostics
(
bucket
,
includeSuppressedDiagnostics
,
cancellationToken
);
result
.
AddRange
(
diagnostics
);
}
return
result
.
ToImmutable
();
}
}
}
src/VisualStudio/Core/Def/Implementation/TableDataSource/AbstractRoslynTableDataSource.cs
浏览文件 @
e22799b5
...
...
@@ -11,7 +11,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Implementation.TableDataSource
/// <summary>
/// A version of ITableDataSource who knows how to connect them to Roslyn solution crawler for live information.
/// </summary>
internal
abstract
class
AbstractRoslynTableDataSource
<
TItem
>
:
AbstractTableDataSource
<
TItem
>
internal
abstract
class
AbstractRoslynTableDataSource
<
TItem
,
TData
>
:
AbstractTableDataSource
<
TItem
,
TData
>
where
TItem
:
TableItem
{
public
AbstractRoslynTableDataSource
(
Workspace
workspace
)
:
base
(
workspace
)
...
...
src/VisualStudio/Core/Def/Implementation/TableDataSource/AbstractTableDataSource.cs
浏览文件 @
e22799b5
...
...
@@ -17,14 +17,14 @@ namespace Microsoft.VisualStudio.LanguageServices.Implementation.TableDataSource
/// <summary>
/// Base implementation of ITableDataSource
/// </summary>
internal
abstract
class
AbstractTableDataSource
<
TItem
>
:
ITableDataSource
internal
abstract
class
AbstractTableDataSource
<
TItem
,
TData
>
:
ITableDataSource
where
TItem
:
TableItem
{
private
readonly
object
_gate
;
// This map holds aggregation key to factory
// Any data that shares same aggregation key will de-duplicated to same factory
private
readonly
Dictionary
<
object
,
TableEntriesFactory
<
TItem
>>
_map
;
private
readonly
Dictionary
<
object
,
TableEntriesFactory
<
TItem
,
TData
>>
_map
;
// This map holds each data source key to its aggregation key
private
readonly
Dictionary
<
object
,
object
>
_aggregateKeyMap
;
...
...
@@ -35,7 +35,7 @@ internal abstract class AbstractTableDataSource<TItem> : ITableDataSource
public
AbstractTableDataSource
(
Workspace
workspace
)
{
_gate
=
new
object
();
_map
=
new
Dictionary
<
object
,
TableEntriesFactory
<
TItem
>>();
_map
=
new
Dictionary
<
object
,
TableEntriesFactory
<
TItem
,
TData
>>();
_aggregateKeyMap
=
new
Dictionary
<
object
,
object
>();
_subscriptions
=
ImmutableArray
<
SubscriptionWithoutLock
>.
Empty
;
...
...
@@ -55,7 +55,7 @@ public AbstractTableDataSource(Workspace workspace)
public
void
RefreshAllFactories
()
{
ImmutableArray
<
SubscriptionWithoutLock
>
snapshot
;
List
<
TableEntriesFactory
<
TItem
>>
factories
;
List
<
TableEntriesFactory
<
TItem
,
TData
>>
factories
;
lock
(
_gate
)
{
snapshot
=
_subscriptions
;
...
...
@@ -74,7 +74,7 @@ public void RefreshAllFactories()
}
}
public
void
Refresh
(
TableEntriesFactory
<
TItem
>
factory
)
public
void
Refresh
(
TableEntriesFactory
<
TItem
,
TData
>
factory
)
{
var
snapshot
=
_subscriptions
;
...
...
@@ -106,7 +106,7 @@ public void Shutdown()
}
}
public
ImmutableArray
<
TItem
>
AggregateItems
<
T
Data
>(
IEnumerable
<
IGrouping
<
TData
,
TItem
>>
groupedItems
)
public
ImmutableArray
<
TItem
>
AggregateItems
<
T
Key
>(
IEnumerable
<
IGrouping
<
TKey
,
TItem
>>
groupedItems
)
{
using
var
_0
=
ArrayBuilder
<
TItem
>.
GetInstance
(
out
var
aggregateItems
);
using
var
_1
=
ArrayBuilder
<
string
>.
GetInstance
(
out
var
projectNames
);
...
...
@@ -175,7 +175,7 @@ static T[] GetOrCreateArray<T>(ref T[] cache, ArrayBuilder<T> value)
/// Data contains multiple items belong to one logical chunk. and the Id represents this particular
/// chunk of the data
/// </summary>
public
abstract
object
GetItemKey
(
object
data
);
public
abstract
object
GetItemKey
(
TData
data
);
/// <summary>
/// Create TableEntriesSource for the given data.
...
...
@@ -188,9 +188,9 @@ static T[] GetOrCreateArray<T>(ref T[] cache, ArrayBuilder<T> value)
/// for example, for linked files, data that belong to same physical file will be gathered and items that belong to
/// those data will be de-duplicated.
/// </summary>
protected
abstract
object
GetOrUpdateAggregationKey
(
object
data
);
protected
abstract
object
GetOrUpdateAggregationKey
(
TData
data
);
protected
void
OnDataAddedOrChanged
(
object
data
)
protected
void
OnDataAddedOrChanged
(
TData
data
)
{
// reuse factory. it is okay to re-use factory since we make sure we remove the factory before
// adding it back
...
...
@@ -206,7 +206,7 @@ protected void OnDataAddedOrChanged(object data)
}
}
protected
void
OnDataRemoved
(
object
data
)
protected
void
OnDataRemoved
(
TData
data
)
{
lock
(
_gate
)
{
...
...
@@ -214,14 +214,14 @@ protected void OnDataRemoved(object data)
}
}
protected
void
RemoveStaledData
(
object
data
)
protected
void
RemoveStaledData
(
TData
data
)
{
OnDataRemoved_NoLock
(
data
);
RemoveAggregateKey_NoLock
(
data
);
}
private
void
OnDataRemoved_NoLock
(
object
data
)
private
void
OnDataRemoved_NoLock
(
TData
data
)
{
ImmutableArray
<
SubscriptionWithoutLock
>
snapshot
;
var
key
=
TryGetAggregateKey
(
data
);
...
...
@@ -253,7 +253,7 @@ private void OnDataRemoved_NoLock(object data)
NotifySubscriptionOnDataRemoved_NoLock
(
snapshot
,
factory
);
}
private
static
void
NotifySubscriptionOnDataAddedOrChanged_NoLock
(
ImmutableArray
<
SubscriptionWithoutLock
>
snapshot
,
TableEntriesFactory
<
TItem
>
factory
,
bool
newFactory
)
private
static
void
NotifySubscriptionOnDataAddedOrChanged_NoLock
(
ImmutableArray
<
SubscriptionWithoutLock
>
snapshot
,
TableEntriesFactory
<
TItem
,
TData
>
factory
,
bool
newFactory
)
{
for
(
var
i
=
0
;
i
<
snapshot
.
Length
;
i
++)
{
...
...
@@ -261,7 +261,7 @@ private static void NotifySubscriptionOnDataAddedOrChanged_NoLock(ImmutableArray
}
}
private
static
void
NotifySubscriptionOnDataRemoved_NoLock
(
ImmutableArray
<
SubscriptionWithoutLock
>
snapshot
,
TableEntriesFactory
<
TItem
>
factory
)
private
static
void
NotifySubscriptionOnDataRemoved_NoLock
(
ImmutableArray
<
SubscriptionWithoutLock
>
snapshot
,
TableEntriesFactory
<
TItem
,
TData
>
factory
)
{
for
(
var
i
=
0
;
i
<
snapshot
.
Length
;
i
++)
{
...
...
@@ -269,7 +269,7 @@ private static void NotifySubscriptionOnDataRemoved_NoLock(ImmutableArray<Subscr
}
}
private
void
GetOrCreateFactory_NoLock
(
object
data
,
out
TableEntriesFactory
<
TItem
>
factory
,
out
bool
newFactory
)
private
void
GetOrCreateFactory_NoLock
(
TData
data
,
out
TableEntriesFactory
<
TItem
,
TData
>
factory
,
out
bool
newFactory
)
{
newFactory
=
false
;
...
...
@@ -280,7 +280,7 @@ private void GetOrCreateFactory_NoLock(object data, out TableEntriesFactory<TIte
}
var
source
=
CreateTableEntriesSource
(
data
);
factory
=
new
TableEntriesFactory
<
TItem
>(
this
,
source
);
factory
=
new
TableEntriesFactory
<
TItem
,
TData
>(
this
,
source
);
_map
.
Add
(
key
,
factory
);
newFactory
=
true
;
...
...
@@ -301,10 +301,10 @@ protected void ChangeStableState(bool stable)
}
}
protected
void
AddAggregateKey
(
object
data
,
object
aggregateKey
)
protected
void
AddAggregateKey
(
TData
data
,
object
aggregateKey
)
=>
_aggregateKeyMap
.
Add
(
GetItemKey
(
data
),
aggregateKey
);
protected
object
TryGetAggregateKey
(
object
data
)
protected
object
TryGetAggregateKey
(
TData
data
)
{
var
key
=
GetItemKey
(
data
);
if
(
_aggregateKeyMap
.
TryGetValue
(
key
,
out
var
aggregateKey
))
...
...
@@ -315,7 +315,7 @@ protected object TryGetAggregateKey(object data)
return
null
;
}
private
void
RemoveAggregateKey_NoLock
(
object
data
)
private
void
RemoveAggregateKey_NoLock
(
TData
data
)
=>
_aggregateKeyMap
.
Remove
(
GetItemKey
(
data
));
IDisposable
ITableDataSource
.
Subscribe
(
ITableDataSink
sink
)
...
...
@@ -333,10 +333,10 @@ internal int NumberOfSubscription_TestOnly
protected
class
SubscriptionWithoutLock
:
IDisposable
{
private
readonly
AbstractTableDataSource
<
TItem
>
_source
;
private
readonly
AbstractTableDataSource
<
TItem
,
TData
>
_source
;
private
readonly
ITableDataSink
_sink
;
public
SubscriptionWithoutLock
(
AbstractTableDataSource
<
TItem
>
source
,
ITableDataSink
sink
)
public
SubscriptionWithoutLock
(
AbstractTableDataSource
<
TItem
,
TData
>
source
,
ITableDataSink
sink
)
{
_source
=
source
;
_sink
=
sink
;
...
...
src/VisualStudio/Core/Def/Implementation/TableDataSource/TableEntriesFactory.cs
浏览文件 @
e22799b5
...
...
@@ -12,18 +12,18 @@
namespace
Microsoft.VisualStudio.LanguageServices.Implementation.TableDataSource
{
internal
class
TableEntriesFactory
<
TItem
>
:
ITableEntriesSnapshotFactory
internal
class
TableEntriesFactory
<
TItem
,
TData
>
:
ITableEntriesSnapshotFactory
where
TItem
:
TableItem
{
private
readonly
object
_gate
=
new
object
();
private
readonly
AbstractTableDataSource
<
TItem
>
_tableSource
;
private
readonly
AbstractTableDataSource
<
TItem
,
TData
>
_tableSource
;
private
readonly
AggregatedEntriesSource
_entriesSources
;
private
readonly
WeakReference
<
ITableEntriesSnapshot
>
_lastSnapshotWeakReference
=
new
WeakReference
<
ITableEntriesSnapshot
>(
null
);
private
int
_lastVersion
=
0
;
public
TableEntriesFactory
(
AbstractTableDataSource
<
TItem
>
tableSource
,
AbstractTableEntriesSource
<
TItem
>
entriesSource
)
public
TableEntriesFactory
(
AbstractTableDataSource
<
TItem
,
TData
>
tableSource
,
AbstractTableEntriesSource
<
TItem
>
entriesSource
)
{
_tableSource
=
tableSource
;
_entriesSources
=
new
AggregatedEntriesSource
(
_tableSource
,
entriesSource
);
...
...
@@ -76,7 +76,7 @@ public ITableEntriesSnapshot GetSnapshot(int versionNumber)
}
}
public
void
OnDataAddedOrChanged
(
object
data
)
public
void
OnDataAddedOrChanged
(
TData
data
)
{
lock
(
_gate
)
{
...
...
@@ -86,7 +86,7 @@ public void OnDataAddedOrChanged(object data)
}
}
public
bool
OnDataRemoved
(
object
data
)
public
bool
OnDataRemoved
(
TData
data
)
{
lock
(
_gate
)
{
...
...
@@ -127,18 +127,18 @@ private ITableEntriesSnapshot CreateSnapshot(int version, ImmutableArray<TItem>
private
class
AggregatedEntriesSource
{
private
readonly
EntriesSourceCollections
_sources
;
private
readonly
AbstractTableDataSource
<
TItem
>
_tableSource
;
private
readonly
AbstractTableDataSource
<
TItem
,
TData
>
_tableSource
;
public
AggregatedEntriesSource
(
AbstractTableDataSource
<
TItem
>
tableSource
,
AbstractTableEntriesSource
<
TItem
>
primary
)
public
AggregatedEntriesSource
(
AbstractTableDataSource
<
TItem
,
TData
>
tableSource
,
AbstractTableEntriesSource
<
TItem
>
primary
)
{
_tableSource
=
tableSource
;
_sources
=
new
EntriesSourceCollections
(
primary
);
}
public
void
OnDataAddedOrChanged
(
object
data
)
public
void
OnDataAddedOrChanged
(
TData
data
)
=>
_sources
.
OnDataAddedOrChanged
(
data
,
_tableSource
);
public
bool
OnDataRemoved
(
object
data
)
public
bool
OnDataRemoved
(
TData
data
)
=>
_sources
.
OnDataRemoved
(
data
,
_tableSource
);
public
ImmutableArray
<
TItem
>
GetItems
()
...
...
@@ -252,7 +252,7 @@ private void EnsureSources()
}
}
public
void
OnDataAddedOrChanged
(
object
data
,
AbstractTableDataSource
<
TItem
>
tableSource
)
public
void
OnDataAddedOrChanged
(
TData
data
,
AbstractTableDataSource
<
TItem
,
TData
>
tableSource
)
{
var
key
=
tableSource
.
GetItemKey
(
data
);
if
(
_primary
!=
null
&&
_primary
.
Key
.
Equals
(
key
))
...
...
@@ -274,7 +274,7 @@ public void OnDataAddedOrChanged(object data, AbstractTableDataSource<TItem> tab
_sources
.
Add
(
source
.
Key
,
source
);
}
public
bool
OnDataRemoved
(
object
data
,
AbstractTableDataSource
<
TItem
>
tableSource
)
public
bool
OnDataRemoved
(
TData
data
,
AbstractTableDataSource
<
TItem
,
TData
>
tableSource
)
{
var
key
=
tableSource
.
GetItemKey
(
data
);
if
(
_primary
!=
null
&&
_primary
.
Key
.
Equals
(
key
))
...
...
src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioBaseDiagnosticListTable.LiveTableDataSource.cs
浏览文件 @
e22799b5
...
...
@@ -35,7 +35,7 @@ internal abstract partial class VisualStudioBaseDiagnosticListTable
/// See <see cref="VisualStudioDiagnosticListTableWorkspaceEventListener.VisualStudioDiagnosticListTable.BuildTableDataSource"/>
/// for error list diagnostic source for "Build only" setting.
/// </summary>
protected
class
LiveTableDataSource
:
AbstractRoslynTableDataSource
<
DiagnosticTableItem
>
protected
class
LiveTableDataSource
:
AbstractRoslynTableDataSource
<
DiagnosticTableItem
,
DiagnosticsUpdatedArgs
>
{
private
readonly
string
_identifier
;
private
readonly
IDiagnosticService
_diagnosticService
;
...
...
@@ -66,7 +66,7 @@ public LiveTableDataSource(Workspace workspace, IDiagnosticService diagnosticSer
public
override
string
DisplayName
=>
ServicesVSResources
.
CSharp_VB_Diagnostics_Table_Data_Source
;
public
override
string
SourceTypeIdentifier
=>
StandardTableDataSources
.
ErrorTableDataSource
;
public
override
string
Identifier
=>
_identifier
;
public
override
object
GetItemKey
(
object
data
)
=>
((
UpdatedEventArgs
)
data
)
.
Id
;
public
override
object
GetItemKey
(
DiagnosticsUpdatedArgs
data
)
=>
data
.
Id
;
private
void
ConnectToBuildUpdateSource
(
ExternalErrorDiagnosticUpdateSource
?
buildUpdateSource
)
{
...
...
@@ -110,7 +110,7 @@ private void OnBuildProgressChanged(bool running)
return
snapshot
;
}
protected
override
object
GetOrUpdateAggregationKey
(
object
data
)
protected
override
object
GetOrUpdateAggregationKey
(
DiagnosticsUpdatedArgs
data
)
{
var
key
=
TryGetAggregateKey
(
data
);
if
(
key
==
null
)
...
...
@@ -147,28 +147,28 @@ private bool CheckAggregateKey(AggregatedKey? key, DiagnosticsUpdatedArgs? args)
return
key
.
DocumentIds
==
documents
;
}
private
object
CreateAggregationKey
(
object
data
)
private
object
CreateAggregationKey
(
DiagnosticsUpdatedArgs
data
)
{
var
args
=
data
as
DiagnosticsUpdatedArgs
;
if
(
args
?.
DocumentId
==
null
||
args
?.
Solution
==
null
)
{
if
(
data
.
DocumentId
==
null
||
data
.
Solution
==
null
)
return
GetItemKey
(
data
);
}
if
(!(
args
.
Id
is
LiveDiagnosticUpdateArgsId
liveArgsId
))
{
if
(
data
.
Id
is
not
LiveDiagnosticUpdateArgsId
liveArgsId
)
return
GetItemKey
(
data
);
}
var
documents
=
GetDocumentsWithSameFilePath
(
args
.
Solution
,
args
.
DocumentId
);
var
documents
=
GetDocumentsWithSameFilePath
(
data
.
Solution
,
data
.
DocumentId
);
return
new
AggregatedKey
(
documents
,
liveArgsId
.
Analyzer
,
liveArgsId
.
Kind
);
}
private
void
PopulateInitialData
(
Workspace
workspace
,
IDiagnosticService
diagnosticService
)
{
foreach
(
var
args
in
diagnosticService
.
GetDiagnosticsUpdatedEventArgs
(
workspace
,
projectId
:
null
,
documentId
:
null
,
cancellationToken
:
CancellationToken
.
None
))
{
OnDataAddedOrChanged
(
args
);
foreach
(
var
bucket
in
diagnosticService
.
GetDiagnosticBuckets
(
workspace
,
projectId
:
null
,
documentId
:
null
,
cancellationToken
:
CancellationToken
.
None
))
{
// We only need to issue an event to VS that these docs have diagnostics associated with them. So
// we create a dummy notification for this. It doesn't matter that it is 'DiagnosticsRemoved' as
// this doesn't actually change any data. All that will happen now is that VS will call back into
// us for these IDs and we'll fetch the diagnostics at that point.
OnDataAddedOrChanged
(
DiagnosticsUpdatedArgs
.
DiagnosticsRemoved
(
bucket
.
Id
,
bucket
.
Workspace
,
solution
:
null
,
bucket
.
ProjectId
,
bucket
.
DocumentId
));
}
}
...
...
src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioBaseTodoListTable.cs
浏览文件 @
e22799b5
...
...
@@ -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
>
private
class
TableDataSource
:
AbstractRoslynTableDataSource
<
TodoTableItem
,
TodoItemsUpdatedArgs
>
{
private
readonly
Workspace
_workspace
;
private
readonly
string
_identifier
;
...
...
@@ -81,16 +82,14 @@ public TableDataSource(Workspace workspace, ITodoListProvider todoListProvider,
_todoListProvider
=
todoListProvider
;
_todoListProvider
.
TodoListUpdated
+=
OnTodoListUpdated
;
PopulateInitialData
(
workspace
,
_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
(
object
data
)
=>
((
UpdatedEventArgs
)
data
)
.
DocumentId
;
public
override
object
GetItemKey
(
TodoItemsUpdatedArgs
data
)
=>
data
.
DocumentId
;
protected
override
object
GetOrUpdateAggregationKey
(
object
data
)
protected
override
object
GetOrUpdateAggregationKey
(
TodoItemsUpdatedArgs
data
)
{
var
key
=
TryGetAggregateKey
(
data
);
if
(
key
==
null
)
...
...
@@ -105,7 +104,7 @@ protected override object GetOrUpdateAggregationKey(object data)
return
key
;
}
if
(!
CheckAggregateKey
((
ImmutableArray
<
DocumentId
>)
key
,
data
as
TodoItemsUpdatedArgs
))
if
(!
CheckAggregateKey
((
ImmutableArray
<
DocumentId
>)
key
,
data
))
{
RemoveStaledData
(
data
);
...
...
@@ -118,24 +117,19 @@ protected override object GetOrUpdateAggregationKey(object 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
(
object
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
)
...
...
@@ -150,14 +144,6 @@ public override IEnumerable<TodoTableItem> Order(IEnumerable<TodoTableItem> grou
.
ThenBy
(
d
=>
d
.
Data
.
OriginalColumn
);
}
private
void
PopulateInitialData
(
Workspace
workspace
,
ITodoListProvider
todoListService
)
{
foreach
(
var
args
in
todoListService
.
GetTodoItemsUpdatedEventArgs
(
workspace
,
cancellationToken
:
CancellationToken
.
None
))
{
OnDataAddedOrChanged
(
args
);
}
}
private
void
OnTodoListUpdated
(
object
sender
,
TodoItemsUpdatedArgs
e
)
{
if
(
_workspace
!=
e
.
Workspace
)
...
...
src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioDiagnosticListTable.BuildTableDataSource.cs
浏览文件 @
e22799b5
...
...
@@ -25,7 +25,7 @@ internal partial class VisualStudioDiagnosticListTable : VisualStudioBaseDiagnos
/// See <see cref="VisualStudioBaseDiagnosticListTable.LiveTableDataSource"/>
/// for error list diagnostic source for "Build + Intellisense" setting.
/// </summary>
private
class
BuildTableDataSource
:
AbstractTableDataSource
<
DiagnosticTableItem
>
private
class
BuildTableDataSource
:
AbstractTableDataSource
<
DiagnosticTableItem
,
object
>
{
private
readonly
object
_key
=
new
object
();
...
...
src/VisualStudio/Core/Def/Implementation/TodoComments/VisualStudioTodoCommentsService.cs
浏览文件 @
e22799b5
...
...
@@ -211,13 +211,6 @@ public ImmutableArray<TodoCommentData> GetTodoItems(Workspace workspace, Documen
:
ImmutableArray
<
TodoCommentData
>.
Empty
;
}
public
IEnumerable
<
UpdatedEventArgs
>
GetTodoItemsUpdatedEventArgs
(
Workspace
workspace
,
CancellationToken
cancellationToken
)
{
// Don't need to implement this. OOP pushes all items over to VS. So there's no need
return
SpecializedCollections
.
EmptyEnumerable
<
UpdatedEventArgs
>();
}
/// <summary>
/// Callback from the OOP service back into us.
/// </summary>
...
...
src/VisualStudio/Core/Test.Next/Services/LspDiagnosticsTests.cs
浏览文件 @
e22799b5
...
...
@@ -386,7 +386,7 @@ static InProcLanguageServer CreateLanguageServer(Stream inputStream, Stream outp
}
}
private
void
SetupMockWithDiagnostics
(
Mock
<
IDiagnosticService
>
diagnosticServiceMock
,
DocumentId
documentId
,
I
Enumerable
<
DiagnosticData
>
diagnostics
)
private
void
SetupMockWithDiagnostics
(
Mock
<
IDiagnosticService
>
diagnosticServiceMock
,
DocumentId
documentId
,
I
mmutableArray
<
DiagnosticData
>
diagnostics
)
{
diagnosticServiceMock
.
Setup
(
d
=>
d
.
GetDiagnostics
(
It
.
IsAny
<
Workspace
>(),
It
.
IsAny
<
ProjectId
>(),
documentId
,
It
.
IsAny
<
object
>(),
It
.
IsAny
<
bool
>(),
It
.
IsAny
<
CancellationToken
>()))
...
...
@@ -394,7 +394,7 @@ private void SetupMockWithDiagnostics(Mock<IDiagnosticService> diagnosticService
}
private
void
SetupMockDiagnosticSequence
(
Mock
<
IDiagnosticService
>
diagnosticServiceMock
,
DocumentId
documentId
,
I
Enumerable
<
DiagnosticData
>
firstDiagnostics
,
IEnumerable
<
DiagnosticData
>
secondDiagnostics
)
I
mmutableArray
<
DiagnosticData
>
firstDiagnostics
,
ImmutableArray
<
DiagnosticData
>
secondDiagnostics
)
{
diagnosticServiceMock
.
SetupSequence
(
d
=>
d
.
GetDiagnostics
(
It
.
IsAny
<
Workspace
>(),
It
.
IsAny
<
ProjectId
>(),
documentId
,
It
.
IsAny
<
object
>(),
It
.
IsAny
<
bool
>(),
It
.
IsAny
<
CancellationToken
>()))
...
...
@@ -402,11 +402,11 @@ private void SetupMockWithDiagnostics(Mock<IDiagnosticService> diagnosticService
.
Returns
(
secondDiagnostics
);
}
private
async
Task
<
I
Enumerable
<
DiagnosticData
>>
CreateMockDiagnosticDataAsync
(
Document
document
,
string
id
)
private
async
Task
<
I
mmutableArray
<
DiagnosticData
>>
CreateMockDiagnosticDataAsync
(
Document
document
,
string
id
)
{
var
descriptor
=
new
DiagnosticDescriptor
(
id
,
""
,
""
,
""
,
DiagnosticSeverity
.
Error
,
true
);
var
location
=
Location
.
Create
(
await
document
.
GetRequiredSyntaxTreeAsync
(
CancellationToken
.
None
).
ConfigureAwait
(
false
),
new
TextSpan
());
return
new
DiagnosticData
[]
{
DiagnosticData
.
Create
(
Diagnostic
.
Create
(
descriptor
,
location
),
document
)
}
;
return
ImmutableArray
.
Create
(
DiagnosticData
.
Create
(
Diagnostic
.
Create
(
descriptor
,
location
),
document
))
;
}
private
async
Task
<
ImmutableArray
<
DiagnosticData
>>
CreateMockDiagnosticDatasWithMappedLocationAsync
(
Document
document
,
params
(
string
diagnosticId
,
string
mappedFilePath
)[]
diagnostics
)
...
...
src/VisualStudio/Core/Test/Diagnostics/DiagnosticTableDataSourceTests.vb
浏览文件 @
e22799b5
...
...
@@ -38,7 +38,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Diagnostics
Assert
.
Equal
(
manager
.
Identifier
,
StandardTables
.
ErrorsTable
)
Assert
.
Equal
(
1
,
manager
.
Sources
.
Count
())
Dim
source
=
DirectCast
(
manager
.
Sources
.
First
(),
AbstractRoslynTableDataSource
(
Of
DiagnosticTableItem
))
Dim
source
=
DirectCast
(
manager
.
Sources
.
First
(),
AbstractRoslynTableDataSource
(
Of
DiagnosticTableItem
,
DiagnosticsUpdatedArgs
))
AssertEx
.
SetEqual
(
table
.
Columns
,
manager
.
GetColumnsForSources
(
SpecializedCollections
.
SingletonEnumerable
(
source
)))
Assert
.
Equal
(
ServicesVSResources
.
CSharp_VB_Diagnostics_Table_Data_Source
,
source
.
DisplayName
)
...
...
@@ -69,7 +69,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Diagnostics
provider
.
RaiseDiagnosticsUpdated
(
workspace
)
Dim
manager
=
DirectCast
(
table
.
TableManager
,
TestTableManagerProvider
.
TestTableManager
)
Dim
source
=
DirectCast
(
manager
.
Sources
.
First
(),
AbstractRoslynTableDataSource
(
Of
DiagnosticTableItem
))
Dim
source
=
DirectCast
(
manager
.
Sources
.
First
(),
AbstractRoslynTableDataSource
(
Of
DiagnosticTableItem
,
DiagnosticsUpdatedArgs
))
Dim
sinkAndSubscription
=
manager
.
Sinks_TestOnly
.
First
()
Dim
sink
=
DirectCast
(
sinkAndSubscription
.
Key
,
TestTableManagerProvider
.
TestTableManager
.
TestSink
)
...
...
@@ -87,7 +87,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Diagnostics
Dim
table
=
New
VisualStudioDiagnosticListTableWorkspaceEventListener
.
VisualStudioDiagnosticListTable
(
workspace
,
provider
,
tableManagerProvider
)
Dim
manager
=
DirectCast
(
table
.
TableManager
,
TestTableManagerProvider
.
TestTableManager
)
Dim
source
=
DirectCast
(
manager
.
Sources
.
First
(),
AbstractRoslynTableDataSource
(
Of
DiagnosticTableItem
))
Dim
source
=
DirectCast
(
manager
.
Sources
.
First
(),
AbstractRoslynTableDataSource
(
Of
DiagnosticTableItem
,
DiagnosticsUpdatedArgs
))
Dim
sinkAndSubscription
=
manager
.
Sinks_TestOnly
.
First
()
Dim
sink
=
DirectCast
(
sinkAndSubscription
.
Key
,
TestTableManagerProvider
.
TestTableManager
.
TestSink
)
...
...
@@ -115,7 +115,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Diagnostics
provider
.
RaiseDiagnosticsUpdated
(
workspace
)
Dim
manager
=
DirectCast
(
table
.
TableManager
,
TestTableManagerProvider
.
TestTableManager
)
Dim
source
=
DirectCast
(
manager
.
Sources
.
First
(),
AbstractRoslynTableDataSource
(
Of
DiagnosticTableItem
))
Dim
source
=
DirectCast
(
manager
.
Sources
.
First
(),
AbstractRoslynTableDataSource
(
Of
DiagnosticTableItem
,
DiagnosticsUpdatedArgs
))
Dim
sinkAndSubscription
=
manager
.
Sinks_TestOnly
.
First
()
Dim
sink
=
DirectCast
(
sinkAndSubscription
.
Key
,
TestTableManagerProvider
.
TestTableManager
.
TestSink
)
...
...
@@ -156,13 +156,13 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Diagnostics
provider
.
RaiseDiagnosticsUpdated
(
workspace
)
Dim
manager
=
DirectCast
(
table
.
TableManager
,
TestTableManagerProvider
.
TestTableManager
)
Dim
source
=
DirectCast
(
manager
.
Sources
.
First
(),
AbstractRoslynTableDataSource
(
Of
DiagnosticTableItem
))
Dim
source
=
DirectCast
(
manager
.
Sources
.
First
(),
AbstractRoslynTableDataSource
(
Of
DiagnosticTableItem
,
DiagnosticsUpdatedArgs
))
Dim
sinkAndSubscription
=
manager
.
Sinks_TestOnly
.
First
()
Dim
sink
=
DirectCast
(
sinkAndSubscription
.
Key
,
TestTableManagerProvider
.
TestTableManager
.
TestSink
)
Dim
subscription
=
sinkAndSubscription
.
Value
Dim
factory
=
TryCast
(
sink
.
Entries
.
First
(),
TableEntriesFactory
(
Of
DiagnosticTableItem
))
Dim
factory
=
TryCast
(
sink
.
Entries
.
First
(),
TableEntriesFactory
(
Of
DiagnosticTableItem
,
DiagnosticsUpdatedArgs
))
Dim
snapshot1
=
factory
.
GetCurrentSnapshot
()
factory
.
OnRefreshed
()
...
...
@@ -204,7 +204,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Diagnostics
provider
.
RaiseDiagnosticsUpdated
(
workspace
)
Dim
manager
=
DirectCast
(
table
.
TableManager
,
TestTableManagerProvider
.
TestTableManager
)
Dim
source
=
DirectCast
(
manager
.
Sources
.
First
(),
AbstractRoslynTableDataSource
(
Of
DiagnosticTableItem
))
Dim
source
=
DirectCast
(
manager
.
Sources
.
First
(),
AbstractRoslynTableDataSource
(
Of
DiagnosticTableItem
,
DiagnosticsUpdatedArgs
))
Dim
sinkAndSubscription
=
manager
.
Sinks_TestOnly
.
First
()
Dim
sink
=
DirectCast
(
sinkAndSubscription
.
Key
,
TestTableManagerProvider
.
TestTableManager
.
TestSink
)
...
...
@@ -236,7 +236,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Diagnostics
provider
.
RaiseDiagnosticsUpdated
(
workspace
)
Dim
manager
=
DirectCast
(
table
.
TableManager
,
TestTableManagerProvider
.
TestTableManager
)
Dim
source
=
DirectCast
(
manager
.
Sources
.
First
(),
AbstractRoslynTableDataSource
(
Of
DiagnosticTableItem
))
Dim
source
=
DirectCast
(
manager
.
Sources
.
First
(),
AbstractRoslynTableDataSource
(
Of
DiagnosticTableItem
,
DiagnosticsUpdatedArgs
))
Dim
sinkAndSubscription
=
manager
.
Sinks_TestOnly
.
First
()
Dim
sink
=
DirectCast
(
sinkAndSubscription
.
Key
,
TestTableManagerProvider
.
TestTableManager
.
TestSink
)
...
...
@@ -262,7 +262,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Diagnostics
provider
.
RaiseDiagnosticsUpdated
(
workspace
)
Dim
manager
=
DirectCast
(
table
.
TableManager
,
TestTableManagerProvider
.
TestTableManager
)
Dim
source
=
DirectCast
(
manager
.
Sources
.
First
(),
AbstractRoslynTableDataSource
(
Of
DiagnosticTableItem
))
Dim
source
=
DirectCast
(
manager
.
Sources
.
First
(),
AbstractRoslynTableDataSource
(
Of
DiagnosticTableItem
,
DiagnosticsUpdatedArgs
))
Dim
sinkAndSubscription
=
manager
.
Sinks_TestOnly
.
First
()
Dim
sink
=
DirectCast
(
sinkAndSubscription
.
Key
,
TestTableManagerProvider
.
TestTableManager
.
TestSink
)
...
...
@@ -290,7 +290,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Diagnostics
provider
.
RaiseDiagnosticsUpdated
(
workspace1
)
Dim
manager
=
DirectCast
(
table
.
TableManager
,
TestTableManagerProvider
.
TestTableManager
)
Dim
source
=
DirectCast
(
manager
.
Sources
.
First
(),
AbstractRoslynTableDataSource
(
Of
DiagnosticTableItem
))
Dim
source
=
DirectCast
(
manager
.
Sources
.
First
(),
AbstractRoslynTableDataSource
(
Of
DiagnosticTableItem
,
DiagnosticsUpdatedArgs
))
Dim
sinkAndSubscription
=
manager
.
Sinks_TestOnly
.
First
()
Dim
sink
=
DirectCast
(
sinkAndSubscription
.
Key
,
TestTableManagerProvider
.
TestTableManager
.
TestSink
)
...
...
@@ -324,7 +324,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Diagnostics
provider
.
RaiseDiagnosticsUpdated
(
workspace
)
Dim
manager
=
DirectCast
(
table
.
TableManager
,
TestTableManagerProvider
.
TestTableManager
)
Dim
source
=
DirectCast
(
manager
.
Sources
.
First
(),
AbstractRoslynTableDataSource
(
Of
DiagnosticTableItem
))
Dim
source
=
DirectCast
(
manager
.
Sources
.
First
(),
AbstractRoslynTableDataSource
(
Of
DiagnosticTableItem
,
DiagnosticsUpdatedArgs
))
Dim
sinkAndSubscription
=
manager
.
Sinks_TestOnly
.
First
()
Dim
sink
=
DirectCast
(
sinkAndSubscription
.
Key
,
TestTableManagerProvider
.
TestTableManager
.
TestSink
)
...
...
@@ -361,7 +361,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Diagnostics
provider
.
RaiseDiagnosticsUpdated
(
workspace
)
Dim
manager
=
DirectCast
(
table
.
TableManager
,
TestTableManagerProvider
.
TestTableManager
)
Dim
source
=
DirectCast
(
manager
.
Sources
.
First
(),
AbstractRoslynTableDataSource
(
Of
DiagnosticTableItem
))
Dim
source
=
DirectCast
(
manager
.
Sources
.
First
(),
AbstractRoslynTableDataSource
(
Of
DiagnosticTableItem
,
DiagnosticsUpdatedArgs
))
Dim
sinkAndSubscription
=
manager
.
Sinks_TestOnly
.
First
()
Dim
sink
=
DirectCast
(
sinkAndSubscription
.
Key
,
TestTableManagerProvider
.
TestTableManager
.
TestSink
)
...
...
@@ -393,7 +393,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Diagnostics
provider
.
RaiseDiagnosticsUpdated
(
workspace
)
Dim
manager
=
DirectCast
(
table
.
TableManager
,
TestTableManagerProvider
.
TestTableManager
)
Dim
source
=
DirectCast
(
manager
.
Sources
.
First
(),
AbstractRoslynTableDataSource
(
Of
DiagnosticTableItem
))
Dim
source
=
DirectCast
(
manager
.
Sources
.
First
(),
AbstractRoslynTableDataSource
(
Of
DiagnosticTableItem
,
DiagnosticsUpdatedArgs
))
Dim
sinkAndSubscription
=
manager
.
Sinks_TestOnly
.
First
()
Dim
sink
=
DirectCast
(
sinkAndSubscription
.
Key
,
TestTableManagerProvider
.
TestTableManager
.
TestSink
)
...
...
@@ -425,7 +425,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Diagnostics
provider
.
RaiseDiagnosticsUpdated
(
workspace
)
Dim
manager
=
DirectCast
(
table
.
TableManager
,
TestTableManagerProvider
.
TestTableManager
)
Dim
source
=
DirectCast
(
manager
.
Sources
.
First
(),
AbstractRoslynTableDataSource
(
Of
DiagnosticTableItem
))
Dim
source
=
DirectCast
(
manager
.
Sources
.
First
(),
AbstractRoslynTableDataSource
(
Of
DiagnosticTableItem
,
DiagnosticsUpdatedArgs
))
Dim
sinkAndSubscription
=
manager
.
Sinks_TestOnly
.
First
()
Dim
sink
=
DirectCast
(
sinkAndSubscription
.
Key
,
TestTableManagerProvider
.
TestTableManager
.
TestSink
)
...
...
@@ -454,7 +454,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Diagnostics
provider
.
RaiseDiagnosticsUpdated
(
workspace
)
Dim
manager
=
DirectCast
(
table
.
TableManager
,
TestTableManagerProvider
.
TestTableManager
)
Dim
source
=
DirectCast
(
manager
.
Sources
.
First
(),
AbstractRoslynTableDataSource
(
Of
DiagnosticTableItem
))
Dim
source
=
DirectCast
(
manager
.
Sources
.
First
(),
AbstractRoslynTableDataSource
(
Of
DiagnosticTableItem
,
DiagnosticsUpdatedArgs
))
Dim
sinkAndSubscription
=
manager
.
Sinks_TestOnly
.
First
()
Dim
sink
=
DirectCast
(
sinkAndSubscription
.
Key
,
TestTableManagerProvider
.
TestTableManager
.
TestSink
)
...
...
@@ -483,7 +483,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Diagnostics
provider
.
RaiseDiagnosticsUpdated
(
workspace
)
Dim
manager
=
DirectCast
(
table
.
TableManager
,
TestTableManagerProvider
.
TestTableManager
)
Dim
source
=
DirectCast
(
manager
.
Sources
.
First
(),
AbstractRoslynTableDataSource
(
Of
DiagnosticTableItem
))
Dim
source
=
DirectCast
(
manager
.
Sources
.
First
(),
AbstractRoslynTableDataSource
(
Of
DiagnosticTableItem
,
DiagnosticsUpdatedArgs
))
Dim
sinkAndSubscription
=
manager
.
Sinks_TestOnly
.
First
()
Dim
sink
=
DirectCast
(
sinkAndSubscription
.
Key
,
TestTableManagerProvider
.
TestTableManager
.
TestSink
)
...
...
@@ -529,7 +529,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Diagnostics
provider
.
RaiseDiagnosticsUpdated
(
workspace
)
Dim
manager
=
DirectCast
(
table
.
TableManager
,
TestTableManagerProvider
.
TestTableManager
)
Dim
source
=
DirectCast
(
manager
.
Sources
.
First
(),
AbstractRoslynTableDataSource
(
Of
DiagnosticTableItem
))
Dim
source
=
DirectCast
(
manager
.
Sources
.
First
(),
AbstractRoslynTableDataSource
(
Of
DiagnosticTableItem
,
DiagnosticsUpdatedArgs
))
Dim
sinkAndSubscription
=
manager
.
Sinks_TestOnly
.
First
()
Dim
sink
=
DirectCast
(
sinkAndSubscription
.
Key
,
TestTableManagerProvider
.
TestTableManager
.
TestSink
)
...
...
@@ -558,7 +558,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Diagnostics
provider
.
RaiseDiagnosticsUpdated
(
workspace
)
Dim
manager
=
DirectCast
(
table
.
TableManager
,
TestTableManagerProvider
.
TestTableManager
)
Dim
source
=
DirectCast
(
manager
.
Sources
.
First
(),
AbstractRoslynTableDataSource
(
Of
DiagnosticTableItem
))
Dim
source
=
DirectCast
(
manager
.
Sources
.
First
(),
AbstractRoslynTableDataSource
(
Of
DiagnosticTableItem
,
DiagnosticsUpdatedArgs
))
Dim
sinkAndSubscription
=
manager
.
Sinks_TestOnly
.
First
()
Dim
sink
=
DirectCast
(
sinkAndSubscription
.
Key
,
TestTableManagerProvider
.
TestTableManager
.
TestSink
)
...
...
@@ -588,7 +588,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Diagnostics
provider
.
RaiseDiagnosticsUpdated
(
workspace
)
Dim
manager
=
DirectCast
(
table
.
TableManager
,
TestTableManagerProvider
.
TestTableManager
)
Dim
source
=
DirectCast
(
manager
.
Sources
.
First
(),
AbstractRoslynTableDataSource
(
Of
DiagnosticTableItem
))
Dim
source
=
DirectCast
(
manager
.
Sources
.
First
(),
AbstractRoslynTableDataSource
(
Of
DiagnosticTableItem
,
DiagnosticsUpdatedArgs
))
Dim
sinkAndSubscription
=
manager
.
Sinks_TestOnly
.
First
()
Dim
sink
=
DirectCast
(
sinkAndSubscription
.
Key
,
TestTableManagerProvider
.
TestTableManager
.
TestSink
)
...
...
@@ -821,10 +821,10 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Diagnostics
Public
Event
DiagnosticsUpdated
As
EventHandler
(
Of
DiagnosticsUpdatedArgs
)
Implements
IDiagnosticService
.
DiagnosticsUpdated
Public
Function
GetDiagnostics
(
workspace
As
Workspace
,
projectId
As
ProjectId
,
documentId
As
DocumentId
,
id
As
Object
,
reportSuppressedDiagnostics
As
Boolean
,
cancellationToken
As
CancellationToken
)
As
I
Enumerable
(
Of
DiagnosticData
)
Implements
IDiagnosticService
.
GetDiagnostics
Public
Function
GetDiagnostics
(
workspace
As
Workspace
,
projectId
As
ProjectId
,
documentId
As
DocumentId
,
id
As
Object
,
reportSuppressedDiagnostics
As
Boolean
,
cancellationToken
As
CancellationToken
)
As
I
mmutableArray
(
Of
DiagnosticData
)
Implements
IDiagnosticService
.
GetDiagnostics
Assert
.
NotNull
(
workspace
)
Dim
diagnostics
As
I
Enumerable
(
Of
DiagnosticData
)
Dim
diagnostics
As
I
mmutableArray
(
Of
DiagnosticData
)
If
documentId
IsNot
Nothing
Then
diagnostics
=
Items
.
Where
(
Function
(
t
)
t
.
DocumentId
Is
documentId
).
ToImmutableArrayOrEmpty
()
...
...
@@ -835,22 +835,22 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Diagnostics
End
If
If
Not
reportSuppressedDiagnostics
Then
diagnostics
=
diagnostics
.
Where
(
Function
(
d
)
Not
d
.
IsSuppressed
)
diagnostics
=
diagnostics
.
Where
AsArray
(
Function
(
d
)
Not
d
.
IsSuppressed
)
End
If
Return
diagnostics
End
Function
Public
Function
GetDiagnosticsArgs
(
workspace
As
Workspace
,
projectId
As
ProjectId
,
documentId
As
DocumentId
,
cancellationToken
As
CancellationToken
)
As
I
Enumerable
(
Of
UpdatedEventArgs
)
Implements
IDiagnosticService
.
GetDiagnosticsUpdatedEventArg
s
Public
Function
GetDiagnosticsArgs
(
workspace
As
Workspace
,
projectId
As
ProjectId
,
documentId
As
DocumentId
,
cancellationToken
As
CancellationToken
)
As
I
mmutableArray
(
Of
DiagnosticBucket
)
Implements
IDiagnosticService
.
GetDiagnosticBucket
s
Assert
.
NotNull
(
workspace
)
Dim
diagnosticsArgs
As
I
Enumerable
(
Of
UpdatedEventArgs
)
Dim
diagnosticsArgs
As
I
mmutableArray
(
Of
DiagnosticBucket
)
If
documentId
IsNot
Nothing
Then
diagnosticsArgs
=
Items
.
Where
(
Function
(
t
)
t
.
DocumentId
Is
documentId
)
_
.
Select
(
Function
(
t
)
Return
New
UpdatedEventArgs
(
Return
New
DiagnosticBucket
(
New
ErrorId
(
Me
,
If
(
CObj
(
t
.
DocumentId
),
t
.
ProjectId
)),
workspace
,
t
.
ProjectId
,
t
.
DocumentId
)
End
Function
).
ToImmutableArrayOrEmpty
()
...
...
@@ -858,14 +858,14 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Diagnostics
diagnosticsArgs
=
Items
.
Where
(
Function
(
t
)
t
.
ProjectId
Is
projectId
)
_
.
Select
(
Function
(
t
)
Return
New
UpdatedEventArgs
(
Return
New
DiagnosticBucket
(
New
ErrorId
(
Me
,
If
(
CObj
(
t
.
DocumentId
),
t
.
ProjectId
)),
workspace
,
t
.
ProjectId
,
t
.
DocumentId
)
End
Function
).
ToImmutableArrayOrEmpty
()
Else
diagnosticsArgs
=
Items
.
Select
(
Function
(
t
)
Return
New
UpdatedEventArgs
(
Return
New
DiagnosticBucket
(
New
ErrorId
(
Me
,
If
(
CObj
(
t
.
DocumentId
),
t
.
ProjectId
)),
workspace
,
t
.
ProjectId
,
t
.
DocumentId
)
End
Function
).
ToImmutableArrayOrEmpty
()
...
...
src/VisualStudio/Core/Test/Diagnostics/TodoListTableDataSourceTests.vb
浏览文件 @
e22799b5
...
...
@@ -30,7 +30,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Diagnostics
Assert
.
Equal
(
manager
.
Identifier
,
StandardTables
.
TasksTable
)
Assert
.
Equal
(
1
,
manager
.
Sources
.
Count
())
Dim
source
=
DirectCast
(
manager
.
Sources
.
First
(),
AbstractRoslynTableDataSource
(
Of
TodoTableItem
))
Dim
source
=
DirectCast
(
manager
.
Sources
.
First
(),
AbstractRoslynTableDataSource
(
Of
TodoTableItem
,
TodoItemsUpdatedArgs
))
AssertEx
.
SetEqual
(
table
.
Columns
,
manager
.
GetColumnsForSources
(
SpecializedCollections
.
SingletonEnumerable
(
source
)))
Assert
.
Equal
(
ServicesVSResources
.
CSharp_VB_Todo_List_Table_Data_Source
,
source
.
DisplayName
)
...
...
@@ -61,7 +61,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Diagnostics
provider
.
RaiseTodoListUpdated
(
workspace
)
Dim
manager
=
DirectCast
(
table
.
TableManager
,
TestTableManagerProvider
.
TestTableManager
)
Dim
source
=
DirectCast
(
manager
.
Sources
.
First
(),
AbstractRoslynTableDataSource
(
Of
TodoTableItem
))
Dim
source
=
DirectCast
(
manager
.
Sources
.
First
(),
AbstractRoslynTableDataSource
(
Of
TodoTableItem
,
TodoItemsUpdatedArgs
))
Dim
sinkAndSubscription
=
manager
.
Sinks_TestOnly
.
First
()
Dim
sink
=
DirectCast
(
sinkAndSubscription
.
Key
,
TestTableManagerProvider
.
TestTableManager
.
TestSink
)
...
...
@@ -79,7 +79,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Diagnostics
Dim
table
=
New
VisualStudioTodoListTableWorkspaceEventListener
.
VisualStudioTodoListTable
(
workspace
,
provider
,
tableManagerProvider
)
Dim
manager
=
DirectCast
(
table
.
TableManager
,
TestTableManagerProvider
.
TestTableManager
)
Dim
source
=
DirectCast
(
manager
.
Sources
.
First
(),
AbstractRoslynTableDataSource
(
Of
TodoTableItem
))
Dim
source
=
DirectCast
(
manager
.
Sources
.
First
(),
AbstractRoslynTableDataSource
(
Of
TodoTableItem
,
TodoItemsUpdatedArgs
))
Dim
sinkAndSubscription
=
manager
.
Sinks_TestOnly
.
First
()
Dim
sink
=
DirectCast
(
sinkAndSubscription
.
Key
,
TestTableManagerProvider
.
TestTableManager
.
TestSink
)
...
...
@@ -107,7 +107,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Diagnostics
provider
.
RaiseTodoListUpdated
(
workspace
)
Dim
manager
=
DirectCast
(
table
.
TableManager
,
TestTableManagerProvider
.
TestTableManager
)
Dim
source
=
DirectCast
(
manager
.
Sources
.
First
(),
AbstractRoslynTableDataSource
(
Of
TodoTableItem
))
Dim
source
=
DirectCast
(
manager
.
Sources
.
First
(),
AbstractRoslynTableDataSource
(
Of
TodoTableItem
,
TodoItemsUpdatedArgs
))
Dim
sinkAndSubscription
=
manager
.
Sinks_TestOnly
.
First
()
Dim
sink
=
DirectCast
(
sinkAndSubscription
.
Key
,
TestTableManagerProvider
.
TestTableManager
.
TestSink
)
...
...
@@ -148,13 +148,13 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Diagnostics
provider
.
RaiseTodoListUpdated
(
workspace
)
Dim
manager
=
DirectCast
(
table
.
TableManager
,
TestTableManagerProvider
.
TestTableManager
)
Dim
source
=
DirectCast
(
manager
.
Sources
.
First
(),
AbstractRoslynTableDataSource
(
Of
TodoTableItem
))
Dim
source
=
DirectCast
(
manager
.
Sources
.
First
(),
AbstractRoslynTableDataSource
(
Of
TodoTableItem
,
TodoItemsUpdatedArgs
))
Dim
sinkAndSubscription
=
manager
.
Sinks_TestOnly
.
First
()
Dim
sink
=
DirectCast
(
sinkAndSubscription
.
Key
,
TestTableManagerProvider
.
TestTableManager
.
TestSink
)
Dim
subscription
=
sinkAndSubscription
.
Value
Dim
factory
=
TryCast
(
sink
.
Entries
.
First
(),
TableEntriesFactory
(
Of
TodoTableItem
))
Dim
factory
=
TryCast
(
sink
.
Entries
.
First
(),
TableEntriesFactory
(
Of
TodoTableItem
,
TodoItemsUpdatedArgs
))
Dim
snapshot1
=
factory
.
GetCurrentSnapshot
()
factory
.
OnRefreshed
()
...
...
@@ -196,13 +196,13 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Diagnostics
provider
.
RaiseTodoListUpdated
(
workspace
)
Dim
manager
=
DirectCast
(
table
.
TableManager
,
TestTableManagerProvider
.
TestTableManager
)
Dim
source
=
DirectCast
(
manager
.
Sources
.
First
(),
AbstractRoslynTableDataSource
(
Of
TodoTableItem
))
Dim
source
=
DirectCast
(
manager
.
Sources
.
First
(),
AbstractRoslynTableDataSource
(
Of
TodoTableItem
,
TodoItemsUpdatedArgs
))
Dim
sinkAndSubscription
=
manager
.
Sinks_TestOnly
.
First
()
Dim
sink
=
DirectCast
(
sinkAndSubscription
.
Key
,
TestTableManagerProvider
.
TestTableManager
.
TestSink
)
Dim
subscription
=
sinkAndSubscription
.
Value
Dim
factory
=
TryCast
(
sink
.
Entries
.
First
(),
TableEntriesFactory
(
Of
TodoTableItem
))
Dim
factory
=
TryCast
(
sink
.
Entries
.
First
(),
TableEntriesFactory
(
Of
TodoTableItem
,
TodoItemsUpdatedArgs
))
Dim
snapshot1
=
factory
.
GetCurrentSnapshot
()
factory
.
OnRefreshed
()
...
...
@@ -226,13 +226,13 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Diagnostics
provider
.
RaiseTodoListUpdated
(
workspace
)
Dim
manager
=
DirectCast
(
table
.
TableManager
,
TestTableManagerProvider
.
TestTableManager
)
Dim
source
=
DirectCast
(
manager
.
Sources
.
First
(),
AbstractRoslynTableDataSource
(
Of
TodoTableItem
))
Dim
source
=
DirectCast
(
manager
.
Sources
.
First
(),
AbstractRoslynTableDataSource
(
Of
TodoTableItem
,
TodoItemsUpdatedArgs
))
Dim
sinkAndSubscription
=
manager
.
Sinks_TestOnly
.
First
()
Dim
sink
=
DirectCast
(
sinkAndSubscription
.
Key
,
TestTableManagerProvider
.
TestTableManager
.
TestSink
)
Dim
subscription
=
sinkAndSubscription
.
Value
Dim
factory
=
TryCast
(
sink
.
Entries
.
First
(),
TableEntriesFactory
(
Of
TodoTableItem
))
Dim
factory
=
TryCast
(
sink
.
Entries
.
First
(),
TableEntriesFactory
(
Of
TodoTableItem
,
TodoItemsUpdatedArgs
))
Dim
snapshot1
=
factory
.
GetCurrentSnapshot
()
provider
.
Items
=
New
TodoCommentData
()
{
...
...
@@ -260,13 +260,13 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Diagnostics
provider
.
RaiseTodoListUpdated
(
workspace
)
Dim
manager
=
DirectCast
(
table
.
TableManager
,
TestTableManagerProvider
.
TestTableManager
)
Dim
source
=
DirectCast
(
manager
.
Sources
.
First
(),
AbstractRoslynTableDataSource
(
Of
TodoTableItem
))
Dim
source
=
DirectCast
(
manager
.
Sources
.
First
(),
AbstractRoslynTableDataSource
(
Of
TodoTableItem
,
TodoItemsUpdatedArgs
))
Dim
sinkAndSubscription
=
manager
.
Sinks_TestOnly
.
First
()
Dim
sink
=
DirectCast
(
sinkAndSubscription
.
Key
,
TestTableManagerProvider
.
TestTableManager
.
TestSink
)
Dim
subscription
=
sinkAndSubscription
.
Value
Dim
factory
=
TryCast
(
sink
.
Entries
.
First
(),
TableEntriesFactory
(
Of
TodoTableItem
))
Dim
factory
=
TryCast
(
sink
.
Entries
.
First
(),
TableEntriesFactory
(
Of
TodoTableItem
,
TodoItemsUpdatedArgs
))
Dim
snapshot1
=
factory
.
GetCurrentSnapshot
()
provider
.
Items
=
New
TodoCommentData
()
{
...
...
@@ -294,7 +294,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Diagnostics
provider
.
RaiseTodoListUpdated
(
workspace
)
Dim
manager
=
DirectCast
(
table
.
TableManager
,
TestTableManagerProvider
.
TestTableManager
)
Dim
source
=
DirectCast
(
manager
.
Sources
.
First
(),
AbstractRoslynTableDataSource
(
Of
TodoTableItem
))
Dim
source
=
DirectCast
(
manager
.
Sources
.
First
(),
AbstractRoslynTableDataSource
(
Of
TodoTableItem
,
TodoItemsUpdatedArgs
))
Dim
sinkAndSubscription
=
manager
.
Sinks_TestOnly
.
First
()
Dim
sink
=
DirectCast
(
sinkAndSubscription
.
Key
,
TestTableManagerProvider
.
TestTableManager
.
TestSink
)
...
...
@@ -335,7 +335,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Diagnostics
provider
.
RaiseTodoListUpdated
(
workspace
)
Dim
manager
=
DirectCast
(
table
.
TableManager
,
TestTableManagerProvider
.
TestTableManager
)
Dim
source
=
DirectCast
(
manager
.
Sources
.
First
(),
AbstractRoslynTableDataSource
(
Of
TodoTableItem
))
Dim
source
=
DirectCast
(
manager
.
Sources
.
First
(),
AbstractRoslynTableDataSource
(
Of
TodoTableItem
,
TodoItemsUpdatedArgs
))
Dim
sinkAndSubscription
=
manager
.
Sinks_TestOnly
.
First
()
Dim
sink
=
DirectCast
(
sinkAndSubscription
.
Key
,
TestTableManagerProvider
.
TestTableManager
.
TestSink
)
...
...
@@ -390,10 +390,6 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Diagnostics
Return
Items
.
Where
(
Function
(
t
)
t
.
DocumentId
Is
documentId
).
ToImmutableArrayOrEmpty
()
End
Function
Public
Function
GetTodoItemsUpdatedEventArgs
(
workspace
As
Workspace
,
cancellationToken
As
CancellationToken
)
As
IEnumerable
(
Of
UpdatedEventArgs
)
Implements
ITodoListProvider
.
GetTodoItemsUpdatedEventArgs
Return
Items
.
Select
(
Function
(
t
)
New
UpdatedEventArgs
(
Tuple
.
Create
(
Me
,
t
.
DocumentId
),
workspace
,
t
.
DocumentId
.
ProjectId
,
t
.
DocumentId
)).
ToImmutableArray
()
End
Function
Public
Sub
RaiseTodoListUpdated
(
workspace
As
Workspace
)
Dim
map
=
Items
.
ToLookup
(
Function
(
t
)
t
.
DocumentId
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录