Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
ac3e73cf
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,发现更多精彩内容 >>
提交
ac3e73cf
编写于
2月 18, 2015
作者:
H
Heejae Chang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
connect ProgressReport to TableControl
first working version. need some more tweaks.
上级
5a1b81db
变更
11
显示空白变更内容
内联
并排
Showing
11 changed file
with
138 addition
and
13 deletion
+138
-13
src/Features/Core/SolutionCrawler/ISolutionCrawlerProgressReporter.cs
.../Core/SolutionCrawler/ISolutionCrawlerProgressReporter.cs
+7
-2
src/Features/Core/SolutionCrawler/SolutionCrawlerProgressReporter.cs
...s/Core/SolutionCrawler/SolutionCrawlerProgressReporter.cs
+16
-0
src/Features/Core/SolutionCrawler/WorkCoordinator.AsyncDocumentWorkItemQueue.cs
...tionCrawler/WorkCoordinator.AsyncDocumentWorkItemQueue.cs
+5
-0
src/Features/Core/SolutionCrawler/WorkCoordinator.AsyncProjectWorkItemQueue.cs
...utionCrawler/WorkCoordinator.AsyncProjectWorkItemQueue.cs
+5
-0
src/Features/Core/SolutionCrawler/WorkCoordinator.AsyncWorkItemQueue.cs
...ore/SolutionCrawler/WorkCoordinator.AsyncWorkItemQueue.cs
+42
-4
src/Features/Core/SolutionCrawler/WorkCoordinator.HighPriorityProcessor.cs
.../SolutionCrawler/WorkCoordinator.HighPriorityProcessor.cs
+1
-1
src/Features/Core/SolutionCrawler/WorkCoordinator.LowPriorityProcessor.cs
...e/SolutionCrawler/WorkCoordinator.LowPriorityProcessor.cs
+4
-4
src/Features/Core/SolutionCrawler/WorkCoordinator.NormalPriorityProcessor.cs
...olutionCrawler/WorkCoordinator.NormalPriorityProcessor.cs
+1
-1
src/VisualStudio/Core/Def/Implementation/TableDataSource/AbstractTableDataSource.cs
...Implementation/TableDataSource/AbstractTableDataSource.cs
+51
-0
src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioBaseDiagnosticListTable.cs
...on/TableDataSource/VisualStudioBaseDiagnosticListTable.cs
+4
-1
src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioBaseTodoListTable.cs
...entation/TableDataSource/VisualStudioBaseTodoListTable.cs
+2
-0
未找到文件。
src/Features/Core/SolutionCrawler/ISolutionCrawlerProgressReporter.cs
浏览文件 @
ac3e73cf
...
...
@@ -10,12 +10,17 @@ namespace Microsoft.CodeAnalysis.SolutionCrawler
internal
interface
ISolutionCrawlerProgressReporter
{
/// <summary>
/// Raised when there is pending work in solution crawler
/// Return true if solution crawler is in progress.
/// </summary>
bool
InProgress
{
get
;
}
/// <summary>
/// Raised when there is pending work in solution crawler.
/// </summary>
event
EventHandler
Started
;
/// <summary>
/// Raised when there is no more pending work in solutino crawler
/// Raised when there is no more pending work in solutino crawler
.
/// </summary>
event
EventHandler
Stopped
;
}
...
...
src/Features/Core/SolutionCrawler/SolutionCrawlerProgressReporter.cs
浏览文件 @
ac3e73cf
...
...
@@ -25,6 +25,14 @@ private class SolutionCrawlerProgressReporter : ISolutionCrawlerProgressReporter
private
int
_count
=
0
;
public
bool
InProgress
{
get
{
return
_count
>
0
;
}
}
public
event
EventHandler
Started
{
add
...
...
@@ -103,6 +111,14 @@ private class NullReporter : ISolutionCrawlerProgressReporter
{
public
static
readonly
NullReporter
Instance
=
new
NullReporter
();
public
bool
InProgress
{
get
{
return
false
;
}
}
public
event
EventHandler
Started
{
add
{
}
...
...
src/Features/Core/SolutionCrawler/WorkCoordinator.AsyncDocumentWorkItemQueue.cs
浏览文件 @
ac3e73cf
...
...
@@ -14,6 +14,11 @@ private class AsyncDocumentWorkItemQueue : AsyncWorkItemQueue<DocumentId>
{
private
readonly
Dictionary
<
ProjectId
,
Dictionary
<
DocumentId
,
WorkItem
>>
_documentWorkQueue
=
new
Dictionary
<
ProjectId
,
Dictionary
<
DocumentId
,
WorkItem
>>();
public
AsyncDocumentWorkItemQueue
(
SolutionCrawlerProgressReporter
progressReporter
)
:
base
(
progressReporter
)
{
}
protected
override
int
WorkItemCount_NoLock
{
get
...
...
src/Features/Core/SolutionCrawler/WorkCoordinator.AsyncProjectWorkItemQueue.cs
浏览文件 @
ac3e73cf
...
...
@@ -15,6 +15,11 @@ private sealed class AsyncProjectWorkItemQueue : AsyncWorkItemQueue<ProjectId>
{
private
readonly
Dictionary
<
ProjectId
,
WorkItem
>
_projectWorkQueue
=
new
Dictionary
<
ProjectId
,
WorkItem
>();
public
AsyncProjectWorkItemQueue
(
SolutionCrawlerProgressReporter
progressReporter
)
:
base
(
progressReporter
)
{
}
protected
override
int
WorkItemCount_NoLock
{
get
...
...
src/Features/Core/SolutionCrawler/WorkCoordinator.AsyncWorkItemQueue.cs
浏览文件 @
ac3e73cf
...
...
@@ -15,12 +15,20 @@ private partial class WorkCoordinator
private
abstract
class
AsyncWorkItemQueue
<
TKey
>
:
IDisposable
where
TKey
:
class
{
private
readonly
AsyncSemaphore
_semaphore
=
new
AsyncSemaphore
(
initialCount
:
0
);
private
readonly
object
_gate
;
private
readonly
AsyncSemaphore
_semaphore
;
private
readonly
SolutionCrawlerProgressReporter
_progressReporter
;
// map containing cancellation source for the item given out.
private
readonly
Dictionary
<
object
,
CancellationTokenSource
>
_cancellationMap
=
new
Dictionary
<
object
,
CancellationTokenSource
>()
;
private
readonly
Dictionary
<
object
,
CancellationTokenSource
>
_cancellationMap
;
private
readonly
object
_gate
=
new
object
();
public
AsyncWorkItemQueue
(
SolutionCrawlerProgressReporter
progressReporter
)
{
_gate
=
new
object
();
_semaphore
=
new
AsyncSemaphore
(
initialCount
:
0
);
_cancellationMap
=
new
Dictionary
<
object
,
CancellationTokenSource
>();
_progressReporter
=
progressReporter
;
}
protected
abstract
int
WorkItemCount_NoLock
{
get
;
}
...
...
@@ -38,7 +46,7 @@ public bool HasAnyWork
{
lock
(
_gate
)
{
return
WorkItemCount_NoLock
>
0
;
return
HasAnyWork_NoLock
;
}
}
}
...
...
@@ -72,6 +80,12 @@ public virtual Task WaitAsync(CancellationToken cancellationToken)
public
bool
AddOrReplace
(
WorkItem
item
)
{
if
(!
HasAnyWork
)
{
// first work is added.
_progressReporter
.
Start
();
}
lock
(
_gate
)
{
if
(
AddOrReplace_NoLock
(
item
))
...
...
@@ -89,6 +103,10 @@ public void Dispose()
{
lock
(
_gate
)
{
// here we don't need to care about progress reporter since
// it will be only called when host is shutting down.
// we do the below since we want to kill any pending tasks
Dispose_NoLock
();
_cancellationMap
.
Do
(
p
=>
p
.
Value
.
Cancel
());
...
...
@@ -96,6 +114,14 @@ public void Dispose()
}
}
private
bool
HasAnyWork_NoLock
{
get
{
return
WorkItemCount_NoLock
>
0
;
}
}
protected
void
Cancel_NoLock
(
object
key
)
{
CancellationTokenSource
source
;
...
...
@@ -112,6 +138,12 @@ public bool TryTake(TKey key, out WorkItem workInfo, out CancellationTokenSource
{
if
(
TryTake_NoLock
(
key
,
out
workInfo
))
{
if
(!
HasAnyWork_NoLock
)
{
// last work is done.
_progressReporter
.
Stop
();
}
source
=
GetNewCancellationSource_NoLock
(
key
);
workInfo
.
AsyncToken
.
Dispose
();
return
true
;
...
...
@@ -131,6 +163,12 @@ public bool TryTakeAnyWork(ProjectId preferableProjectId, out WorkItem workItem,
// there must be at least one item in the map when this is called unless host is shutting down.
if
(
TryTakeAnyWork_NoLock
(
preferableProjectId
,
out
workItem
))
{
if
(!
HasAnyWork_NoLock
)
{
// last work is done.
_progressReporter
.
Stop
();
}
source
=
GetNewCancellationSource_NoLock
(
workItem
.
Key
);
workItem
.
AsyncToken
.
Dispose
();
return
true
;
...
...
src/Features/Core/SolutionCrawler/WorkCoordinator.HighPriorityProcessor.cs
浏览文件 @
ac3e73cf
...
...
@@ -38,7 +38,7 @@ private sealed class HighPriorityProcessor : IdleProcessor
_lazyAnalyzers
=
lazyAnalyzers
;
_running
=
SpecializedTasks
.
EmptyTask
;
_workItemQueue
=
new
AsyncDocumentWorkItemQueue
();
_workItemQueue
=
new
AsyncDocumentWorkItemQueue
(
processor
.
_registration
.
ProgressReporter
);
Start
();
}
...
...
src/Features/Core/SolutionCrawler/WorkCoordinator.LowPriorityProcessor.cs
浏览文件 @
ac3e73cf
...
...
@@ -34,7 +34,7 @@ private sealed class LowPriorityProcessor : GlobalOperationAwareIdleProcessor
base
(
listener
,
processor
,
globalOperationNotificationService
,
backOffTimeSpanInMs
,
shutdownToken
)
{
_lazyAnalyzers
=
lazyAnalyzers
;
_workItemQueue
=
new
AsyncProjectWorkItemQueue
();
_workItemQueue
=
new
AsyncProjectWorkItemQueue
(
processor
.
_registration
.
ProgressReporter
);
Start
();
}
...
...
@@ -69,7 +69,7 @@ protected override async Task ExecuteAsync()
await
ProcessProjectAsync
(
this
.
Analyzers
,
workItem
,
projectCancellation
).
ConfigureAwait
(
false
);
}
}
catch
(
Exception
e
)
when
(
FatalError
.
ReportUnlessCanceled
(
e
))
catch
(
Exception
e
)
when
(
FatalError
.
ReportUnlessCanceled
(
e
))
{
throw
ExceptionUtilities
.
Unreachable
;
}
...
...
@@ -135,7 +135,7 @@ private async Task ProcessProjectAsync(ImmutableArray<IIncrementalAnalyzer> anal
processedEverything
=
true
;
}
catch
(
Exception
e
)
when
(
FatalError
.
ReportUnlessCanceled
(
e
))
catch
(
Exception
e
)
when
(
FatalError
.
ReportUnlessCanceled
(
e
))
{
throw
ExceptionUtilities
.
Unreachable
;
}
...
...
src/Features/Core/SolutionCrawler/WorkCoordinator.NormalPriorityProcessor.cs
浏览文件 @
ac3e73cf
...
...
@@ -51,7 +51,7 @@ private sealed class NormalPriorityProcessor : GlobalOperationAwareIdleProcessor
_lazyAnalyzers
=
lazyAnalyzers
;
_running
=
SpecializedTasks
.
EmptyTask
;
_workItemQueue
=
new
AsyncDocumentWorkItemQueue
();
_workItemQueue
=
new
AsyncDocumentWorkItemQueue
(
processor
.
_registration
.
ProgressReporter
);
_higherPriorityDocumentsNotProcessed
=
new
ConcurrentDictionary
<
DocumentId
,
bool
>(
concurrencyLevel
:
2
,
capacity
:
20
);
_currentProjectProcessing
=
default
(
ProjectId
);
...
...
src/VisualStudio/Core/Def/Implementation/TableDataSource/AbstractTableDataSource.cs
浏览文件 @
ac3e73cf
...
...
@@ -5,6 +5,7 @@
using
System.Collections.Immutable
;
using
System.Linq
;
using
Microsoft.CodeAnalysis
;
using
Microsoft.CodeAnalysis.SolutionCrawler
;
using
Microsoft.VisualStudio.TableManager
;
namespace
Microsoft.VisualStudio.LanguageServices.Implementation.TableDataSource
...
...
@@ -36,6 +37,28 @@ public virtual void OnProjectDependencyChanged(Solution solution)
protected
abstract
AbstractTableEntriesFactory
<
TData
>
CreateTableEntryFactory
(
object
key
,
TArgs
data
);
protected
void
ConnectToSolutionCrawlerService
(
Workspace
workspace
)
{
var
crawlerService
=
workspace
.
Services
.
GetService
<
ISolutionCrawlerService
>();
var
reporter
=
crawlerService
.
GetProgressReporter
(
workspace
);
// set initial value
ChangeStableState
(
stable
:
!
reporter
.
InProgress
);
reporter
.
Started
+=
OnSolutionCrawlerStarted
;
reporter
.
Stopped
+=
OnSolutionCrawlerStopped
;
}
private
void
OnSolutionCrawlerStarted
(
object
sender
,
EventArgs
e
)
{
ChangeStableState
(
stable
:
false
);
}
private
void
OnSolutionCrawlerStopped
(
object
sender
,
EventArgs
e
)
{
ChangeStableState
(
stable
:
true
);
}
protected
void
OnDataAddedOrChanged
(
object
key
,
TArgs
data
)
{
// reuse factory. it is okay to re-use factory since we make sure we remove the factory before
...
...
@@ -88,6 +111,21 @@ protected void OnDataRemoved(object key)
}
}
private
void
ChangeStableState
(
bool
stable
)
{
ImmutableArray
<
SubscriptionWithoutLock
>
snapshot
;
lock
(
_gate
)
{
snapshot
=
_subscriptions
;
}
for
(
var
i
=
0
;
i
<
snapshot
.
Length
;
i
++)
{
snapshot
[
i
].
IsStable
=
stable
;
}
}
protected
void
RefreshAllFactories
()
{
ImmutableArray
<
SubscriptionWithoutLock
>
snapshot
;
...
...
@@ -136,6 +174,19 @@ public SubscriptionWithoutLock(AbstractTableDataSource<TArgs, TData> source, ITa
ReportInitialData
();
}
public
bool
IsStable
{
get
{
return
_sink
.
IsStable
;
}
set
{
_sink
.
IsStable
=
value
;
}
}
public
void
AddOrUpdate
(
ITableEntriesSnapshotFactory
provider
,
bool
newFactory
)
{
if
(
newFactory
)
...
...
src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioBaseDiagnosticListTable.cs
浏览文件 @
ac3e73cf
...
...
@@ -10,6 +10,7 @@
using
System.Windows.Documents
;
using
Microsoft.CodeAnalysis
;
using
Microsoft.CodeAnalysis.Diagnostics
;
using
Microsoft.CodeAnalysis.SolutionCrawler
;
using
Microsoft.CodeAnalysis.Text
;
using
Microsoft.VisualStudio.Imaging.Interop
;
using
Microsoft.VisualStudio.LanguageServices.Implementation.Utilities
;
...
...
@@ -113,6 +114,8 @@ public TableDataSource(IServiceProvider serviceProvider, Workspace workspace, ID
_diagnosticService
=
diagnosticService
;
_diagnosticService
.
DiagnosticsUpdated
+=
OnDiagnosticsUpdated
;
ConnectToSolutionCrawlerService
(
_workspace
);
}
public
override
void
OnProjectDependencyChanged
(
Solution
solution
)
...
...
@@ -329,7 +332,7 @@ private int GetErrorRank(DiagnosticData item)
return
ErrorRank
.
Other
;
}
switch
(
value
)
switch
(
value
)
{
case
nameof
(
ErrorRank
.
Lexical
):
return
ErrorRank
.
Lexical
;
...
...
src/VisualStudio/Core/Def/Implementation/TableDataSource/VisualStudioBaseTodoListTable.cs
浏览文件 @
ac3e73cf
...
...
@@ -50,6 +50,8 @@ public TableDataSource(Workspace workspace, ITodoListProvider todoListProvider,
_identifier
=
identifier
;
_todoListProvider
=
todoListProvider
;
_todoListProvider
.
TodoListUpdated
+=
OnTodoListUpdated
;
ConnectToSolutionCrawlerService
(
_workspace
);
}
public
override
string
DisplayName
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录