Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
52d00a2f
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,发现更多精彩内容 >>
提交
52d00a2f
编写于
5月 10, 2016
作者:
K
Kevin Halverson
提交者:
Artur Spychaj
5月 16, 2016
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Start plumbing InvocationReasons through SolutionCrawler events...
上级
d4fe93a9
变更
18
隐藏空白更改
内联
并排
Showing
18 changed file
with
71 addition
and
61 deletion
+71
-61
src/EditorFeatures/Core/Implementation/TodoComment/AbstractTodoCommentIncrementalAnalyzer.cs
...ion/TodoComment/AbstractTodoCommentIncrementalAnalyzer.cs
+3
-3
src/EditorFeatures/Core/Shared/Preview/PreviewSolutionCrawlerRegistrationService.cs
...ared/Preview/PreviewSolutionCrawlerRegistrationService.cs
+2
-2
src/Features/Core/Portable/Diagnostics/BaseDiagnosticIncrementalAnalyzer.cs
...Portable/Diagnostics/BaseDiagnosticIncrementalAnalyzer.cs
+6
-3
src/Features/Core/Portable/Diagnostics/DefaultDiagnosticAnalyzerService.cs
.../Portable/Diagnostics/DefaultDiagnosticAnalyzerService.cs
+3
-3
src/Features/Core/Portable/Diagnostics/DiagnosticAnalyzerService_IncrementalAnalyzer.cs
...gnostics/DiagnosticAnalyzerService_IncrementalAnalyzer.cs
+6
-6
src/Features/Core/Portable/Diagnostics/EngineV1/DiagnosticIncrementalAnalyzer.cs
...ble/Diagnostics/EngineV1/DiagnosticIncrementalAnalyzer.cs
+4
-3
src/Features/Core/Portable/Diagnostics/EngineV2/DiagnosticIncrementalAnalyzer_IncrementalAnalyzer.cs
...neV2/DiagnosticIncrementalAnalyzer_IncrementalAnalyzer.cs
+4
-3
src/Features/Core/Portable/IncrementalCaches/SymbolTreeInfoIncrementalAnalyzerProvider.cs
...mentalCaches/SymbolTreeInfoIncrementalAnalyzerProvider.cs
+2
-2
src/Features/Core/Portable/IncrementalCaches/SyntaxTreeInfoIncrementalAnalyzerProvider.cs
...mentalCaches/SyntaxTreeInfoIncrementalAnalyzerProvider.cs
+1
-1
src/Features/Core/Portable/Notification/SemanticChangeNotificationService.cs
...ortable/Notification/SemanticChangeNotificationService.cs
+3
-3
src/Features/Core/Portable/SolutionCrawler/AggregateIncrementalAnalyzer.cs
.../Portable/SolutionCrawler/AggregateIncrementalAnalyzer.cs
+6
-6
src/Features/Core/Portable/SolutionCrawler/IncrementalAnalyzerBase.cs
.../Core/Portable/SolutionCrawler/IncrementalAnalyzerBase.cs
+3
-3
src/Features/Core/Portable/SolutionCrawler/WorkCoordinator.IncrementalAnalyzerProcessor.cs
...onCrawler/WorkCoordinator.IncrementalAnalyzerProcessor.cs
+9
-7
src/Features/Core/Portable/SolutionCrawler/WorkCoordinator.LowPriorityProcessor.cs
...e/SolutionCrawler/WorkCoordinator.LowPriorityProcessor.cs
+4
-3
src/Features/Core/Portable/SolutionCrawler/WorkCoordinator.NormalPriorityProcessor.cs
...olutionCrawler/WorkCoordinator.NormalPriorityProcessor.cs
+5
-4
src/VisualStudio/Core/Def/Implementation/DesignerAttribute/AbstractDesignerAttributeIncrementalAnalyzer.cs
...Attribute/AbstractDesignerAttributeIncrementalAnalyzer.cs
+4
-3
src/VisualStudio/Core/Def/Implementation/SolutionSize/SolutionSizeTracker.cs
...re/Def/Implementation/SolutionSize/SolutionSizeTracker.cs
+3
-3
src/Workspaces/Core/Portable/SolutionCrawler/IIncrementalAnalyzer.cs
...ces/Core/Portable/SolutionCrawler/IIncrementalAnalyzer.cs
+3
-3
未找到文件。
src/EditorFeatures/Core/Implementation/TodoComment/AbstractTodoCommentIncrementalAnalyzer.cs
浏览文件 @
52d00a2f
...
...
@@ -42,7 +42,7 @@ public Task DocumentResetAsync(Document document, CancellationToken cancellation
return
_state
.
PersistAsync
(
document
,
new
Data
(
VersionStamp
.
Default
,
VersionStamp
.
Default
,
ImmutableArray
<
TodoItem
>.
Empty
),
cancellationToken
);
}
public
async
Task
AnalyzeSyntaxAsync
(
Document
document
,
CancellationToken
cancellationToken
)
public
async
Task
AnalyzeSyntaxAsync
(
Document
document
,
InvocationReasons
reasons
,
CancellationToken
cancellationToken
)
{
// it has an assumption that this will not be called concurrently for same document.
// in fact, in current design, it won't be even called concurrently for different documents.
...
...
@@ -220,12 +220,12 @@ public Task DocumentCloseAsync(Document document, CancellationToken cancellation
return
SpecializedTasks
.
EmptyTask
;
}
public
Task
AnalyzeDocumentAsync
(
Document
document
,
SyntaxNode
bodyOpt
,
CancellationToken
cancellationToken
)
public
Task
AnalyzeDocumentAsync
(
Document
document
,
SyntaxNode
bodyOpt
,
InvocationReasons
reasons
,
CancellationToken
cancellationToken
)
{
return
SpecializedTasks
.
EmptyTask
;
}
public
Task
AnalyzeProjectAsync
(
Project
project
,
bool
semanticsChanged
,
CancellationToken
cancellationToken
)
public
Task
AnalyzeProjectAsync
(
Project
project
,
bool
semanticsChanged
,
InvocationReasons
reasons
,
CancellationToken
cancellationToken
)
{
return
SpecializedTasks
.
EmptyTask
;
}
...
...
src/EditorFeatures/Core/Shared/Preview/PreviewSolutionCrawlerRegistrationService.cs
浏览文件 @
52d00a2f
...
...
@@ -49,8 +49,8 @@ public async void Register(Workspace workspace)
await
Task
.
Delay
(
workerBackOffTimeSpanInMS
).
ConfigureAwait
(
false
);
// do actual analysis
await
analyzer
.
AnalyzeSyntaxAsync
(
document
,
source
.
Token
).
ConfigureAwait
(
false
);
await
analyzer
.
AnalyzeDocumentAsync
(
document
,
bodyOpt
:
null
,
cancellationToken
:
source
.
Token
).
ConfigureAwait
(
false
);
await
analyzer
.
AnalyzeSyntaxAsync
(
document
,
InvocationReasons
.
Empty
,
source
.
Token
).
ConfigureAwait
(
false
);
await
analyzer
.
AnalyzeDocumentAsync
(
document
,
bodyOpt
:
null
,
reasons
:
InvocationReasons
.
Empty
,
cancellationToken
:
source
.
Token
).
ConfigureAwait
(
false
);
// don't call project one.
}
...
...
src/Features/Core/Portable/Diagnostics/BaseDiagnosticIncrementalAnalyzer.cs
浏览文件 @
52d00a2f
...
...
@@ -35,9 +35,10 @@ protected BaseDiagnosticIncrementalAnalyzer(DiagnosticAnalyzerService owner, Wor
/// </summary>
/// <param name="document">The document to analyze.</param>
/// <param name="bodyOpt">If present, indicates a portion (e.g. a method body) of the document to analyze.</param>
/// <param name="reasons">The reason(s) this analysis was triggered.</param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public
abstract
Task
AnalyzeDocumentAsync
(
Document
document
,
SyntaxNode
bodyOpt
,
CancellationToken
cancellationToken
);
public
abstract
Task
AnalyzeDocumentAsync
(
Document
document
,
SyntaxNode
bodyOpt
,
InvocationReasons
reasons
,
CancellationToken
cancellationToken
);
/// <summary>
/// Analyze a single project such that diagnostics for the entire project become available.
/// Calls <see cref="DiagnosticAnalyzerService.RaiseDiagnosticsUpdated(DiagnosticsUpdatedArgs)"/> for each
...
...
@@ -45,18 +46,20 @@ protected BaseDiagnosticIncrementalAnalyzer(DiagnosticAnalyzerService owner, Wor
/// </summary>
/// <param name="project">The project to analyze.</param>
/// <param name="semanticsChanged">Indicates a change to the declarative semantics of the project.</param>
/// <param name="reasons">The reason(s) this analysis was triggered.</param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public
abstract
Task
AnalyzeProjectAsync
(
Project
project
,
bool
semanticsChanged
,
CancellationToken
cancellationToken
);
public
abstract
Task
AnalyzeProjectAsync
(
Project
project
,
bool
semanticsChanged
,
InvocationReasons
reasons
,
CancellationToken
cancellationToken
);
/// <summary>
/// Apply syntax tree actions (that have not already been applied) to a document.
/// Calls <see cref="DiagnosticAnalyzerService.RaiseDiagnosticsUpdated(DiagnosticsUpdatedArgs)"/> for each
/// unique group of diagnostics, where a group is identified by analysis classification (syntax), document, and analyzer.
/// </summary>
/// <param name="document">The document to analyze.</param>
/// <param name="reasons">The reason(s) this analysis was triggered.</param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public
abstract
Task
AnalyzeSyntaxAsync
(
Document
document
,
CancellationToken
cancellationToken
);
public
abstract
Task
AnalyzeSyntaxAsync
(
Document
document
,
InvocationReasons
reasons
,
CancellationToken
cancellationToken
);
/// <summary>
/// Respond to a document being opened for editing in the host.
/// </summary>
...
...
src/Features/Core/Portable/Diagnostics/DefaultDiagnosticAnalyzerService.cs
浏览文件 @
52d00a2f
...
...
@@ -82,7 +82,7 @@ public bool NeedsReanalysisOnOptionChanged(object sender, OptionChangedEventArgs
return
false
;
}
public
async
Task
AnalyzeSyntaxAsync
(
Document
document
,
CancellationToken
cancellationToken
)
public
async
Task
AnalyzeSyntaxAsync
(
Document
document
,
InvocationReasons
reasons
,
CancellationToken
cancellationToken
)
{
// right now, there is no way to observe diagnostics for closed file.
if
(!
_workspace
.
IsDocumentOpen
(
document
.
Id
)
||
...
...
@@ -103,7 +103,7 @@ public async Task AnalyzeSyntaxAsync(Document document, CancellationToken cancel
_workspace
,
document
.
Project
.
Solution
,
document
.
Project
.
Id
,
document
.
Id
,
diagnosticData
));
}
public
async
Task
AnalyzeDocumentAsync
(
Document
document
,
SyntaxNode
bodyOpt
,
CancellationToken
cancellationToken
)
public
async
Task
AnalyzeDocumentAsync
(
Document
document
,
SyntaxNode
bodyOpt
,
InvocationReasons
reasons
,
CancellationToken
cancellationToken
)
{
// right now, there is no way to observe diagnostics for closed file.
if
(!
_workspace
.
IsDocumentOpen
(
document
.
Id
)
||
...
...
@@ -150,7 +150,7 @@ private void RaiseEmptyDiagnosticUpdated(int kind, DocumentId documentId)
new
DefaultUpdateArgsId
(
_workspace
.
Kind
,
kind
,
documentId
),
_workspace
,
null
,
documentId
.
ProjectId
,
documentId
));
}
public
Task
AnalyzeProjectAsync
(
Project
project
,
bool
semanticsChanged
,
CancellationToken
cancellationToken
)
public
Task
AnalyzeProjectAsync
(
Project
project
,
bool
semanticsChanged
,
InvocationReasons
reasons
,
CancellationToken
cancellationToken
)
{
return
SpecializedTasks
.
EmptyTask
;
}
...
...
src/Features/Core/Portable/Diagnostics/DiagnosticAnalyzerService_IncrementalAnalyzer.cs
浏览文件 @
52d00a2f
...
...
@@ -76,19 +76,19 @@ public IncrementalAnalyzerDelegatee(DiagnosticAnalyzerService owner, Workspace w
}
#
region
IIncrementalAnalyzer
public
override
Task
AnalyzeSyntaxAsync
(
Document
document
,
CancellationToken
cancellationToken
)
public
override
Task
AnalyzeSyntaxAsync
(
Document
document
,
InvocationReasons
reasons
,
CancellationToken
cancellationToken
)
{
return
Analyzer
.
AnalyzeSyntaxAsync
(
document
,
cancellationToken
);
return
Analyzer
.
AnalyzeSyntaxAsync
(
document
,
reasons
,
cancellationToken
);
}
public
override
Task
AnalyzeDocumentAsync
(
Document
document
,
SyntaxNode
bodyOpt
,
CancellationToken
cancellationToken
)
public
override
Task
AnalyzeDocumentAsync
(
Document
document
,
SyntaxNode
bodyOpt
,
InvocationReasons
reasons
,
CancellationToken
cancellationToken
)
{
return
Analyzer
.
AnalyzeDocumentAsync
(
document
,
bodyOpt
,
cancellationToken
);
return
Analyzer
.
AnalyzeDocumentAsync
(
document
,
bodyOpt
,
reasons
,
cancellationToken
);
}
public
override
Task
AnalyzeProjectAsync
(
Project
project
,
bool
semanticsChanged
,
CancellationToken
cancellationToken
)
public
override
Task
AnalyzeProjectAsync
(
Project
project
,
bool
semanticsChanged
,
InvocationReasons
reasons
,
CancellationToken
cancellationToken
)
{
return
Analyzer
.
AnalyzeProjectAsync
(
project
,
semanticsChanged
,
cancellationToken
);
return
Analyzer
.
AnalyzeProjectAsync
(
project
,
semanticsChanged
,
reasons
,
cancellationToken
);
}
public
override
Task
DocumentOpenAsync
(
Document
document
,
CancellationToken
cancellationToken
)
...
...
src/Features/Core/Portable/Diagnostics/EngineV1/DiagnosticIncrementalAnalyzer.cs
浏览文件 @
52d00a2f
...
...
@@ -13,6 +13,7 @@
using
Microsoft.CodeAnalysis.LanguageServices
;
using
Microsoft.CodeAnalysis.Shared.Extensions
;
using
Microsoft.CodeAnalysis.Shared.Options
;
using
Microsoft.CodeAnalysis.SolutionCrawler
;
using
Microsoft.CodeAnalysis.Text
;
using
Microsoft.CodeAnalysis.Versions
;
using
Roslyn.Utilities
;
...
...
@@ -198,7 +199,7 @@ private bool CheckOptions(Project project, bool forceAnalysis)
return
new
CompilationWithAnalyzers
(
compilation
,
filteredAnalyzers
,
analysisOptions
);
}
public
override
async
Task
AnalyzeSyntaxAsync
(
Document
document
,
CancellationToken
cancellationToken
)
public
override
async
Task
AnalyzeSyntaxAsync
(
Document
document
,
InvocationReasons
reasons
,
CancellationToken
cancellationToken
)
{
await
AnalyzeSyntaxAsync
(
document
,
diagnosticIds
:
null
,
cancellationToken
:
cancellationToken
).
ConfigureAwait
(
false
);
}
...
...
@@ -257,7 +258,7 @@ private async Task AnalyzeSyntaxAsync(Document document, ImmutableHashSet<string
}
}
public
override
async
Task
AnalyzeDocumentAsync
(
Document
document
,
SyntaxNode
bodyOpt
,
CancellationToken
cancellationToken
)
public
override
async
Task
AnalyzeDocumentAsync
(
Document
document
,
SyntaxNode
bodyOpt
,
InvocationReasons
reasons
,
CancellationToken
cancellationToken
)
{
await
AnalyzeDocumentAsync
(
document
,
bodyOpt
,
diagnosticIds
:
null
,
cancellationToken
:
cancellationToken
).
ConfigureAwait
(
false
);
}
...
...
@@ -398,7 +399,7 @@ private async Task AnalyzeDocumentAsync(Document document, VersionArgument versi
}
}
public
override
async
Task
AnalyzeProjectAsync
(
Project
project
,
bool
semanticsChanged
,
CancellationToken
cancellationToken
)
public
override
async
Task
AnalyzeProjectAsync
(
Project
project
,
bool
semanticsChanged
,
InvocationReasons
reasons
,
CancellationToken
cancellationToken
)
{
await
AnalyzeProjectAsync
(
project
,
cancellationToken
).
ConfigureAwait
(
false
);
}
...
...
src/Features/Core/Portable/Diagnostics/EngineV2/DiagnosticIncrementalAnalyzer_IncrementalAnalyzer.cs
浏览文件 @
52d00a2f
...
...
@@ -10,6 +10,7 @@
using
Microsoft.CodeAnalysis.Internal.Log
;
using
Microsoft.CodeAnalysis.Shared.Extensions
;
using
Microsoft.CodeAnalysis.Shared.Options
;
using
Microsoft.CodeAnalysis.SolutionCrawler
;
using
Roslyn.Utilities
;
namespace
Microsoft.CodeAnalysis.Diagnostics.EngineV2
...
...
@@ -17,12 +18,12 @@ namespace Microsoft.CodeAnalysis.Diagnostics.EngineV2
// TODO: make it to use cache
internal
partial
class
DiagnosticIncrementalAnalyzer
:
BaseDiagnosticIncrementalAnalyzer
{
public
override
Task
AnalyzeSyntaxAsync
(
Document
document
,
CancellationToken
cancellationToken
)
public
override
Task
AnalyzeSyntaxAsync
(
Document
document
,
InvocationReasons
reasons
,
CancellationToken
cancellationToken
)
{
return
AnalyzeDocumentForKindAsync
(
document
,
AnalysisKind
.
Syntax
,
cancellationToken
);
}
public
override
Task
AnalyzeDocumentAsync
(
Document
document
,
SyntaxNode
bodyOpt
,
CancellationToken
cancellationToken
)
public
override
Task
AnalyzeDocumentAsync
(
Document
document
,
SyntaxNode
bodyOpt
,
InvocationReasons
reasons
,
CancellationToken
cancellationToken
)
{
return
AnalyzeDocumentForKindAsync
(
document
,
AnalysisKind
.
Semantic
,
cancellationToken
);
}
...
...
@@ -65,7 +66,7 @@ private async Task AnalyzeDocumentForKindAsync(Document document, AnalysisKind k
}
}
public
override
async
Task
AnalyzeProjectAsync
(
Project
project
,
bool
semanticsChanged
,
CancellationToken
cancellationToken
)
public
override
async
Task
AnalyzeProjectAsync
(
Project
project
,
bool
semanticsChanged
,
InvocationReasons
reasons
,
CancellationToken
cancellationToken
)
{
try
{
...
...
src/Features/Core/Portable/IncrementalCaches/SymbolTreeInfoIncrementalAnalyzerProvider.cs
浏览文件 @
52d00a2f
...
...
@@ -190,7 +190,7 @@ private class IncrementalAnalyzer : IncrementalAnalyzerBase
_metadataPathToInfo
=
metadataPathToInfo
;
}
public
override
Task
AnalyzeDocumentAsync
(
Document
document
,
SyntaxNode
bodyOpt
,
CancellationToken
cancellationToken
)
public
override
Task
AnalyzeDocumentAsync
(
Document
document
,
SyntaxNode
bodyOpt
,
InvocationReasons
reasons
,
CancellationToken
cancellationToken
)
{
if
(!
document
.
SupportsSyntaxTree
)
{
...
...
@@ -208,7 +208,7 @@ public override Task AnalyzeDocumentAsync(Document document, SyntaxNode bodyOpt,
return
UpdateSymbolTreeInfoAsync
(
document
.
Project
,
cancellationToken
);
}
public
override
Task
AnalyzeProjectAsync
(
Project
project
,
bool
semanticsChanged
,
CancellationToken
cancellationToken
)
public
override
Task
AnalyzeProjectAsync
(
Project
project
,
bool
semanticsChanged
,
InvocationReasons
reasons
,
CancellationToken
cancellationToken
)
{
return
UpdateSymbolTreeInfoAsync
(
project
,
cancellationToken
);
}
...
...
src/Features/Core/Portable/IncrementalCaches/SyntaxTreeInfoIncrementalAnalyzerProvider.cs
浏览文件 @
52d00a2f
...
...
@@ -18,7 +18,7 @@ public IIncrementalAnalyzer CreateIncrementalAnalyzer(Workspace workspace)
private
class
IncrementalAnalyzer
:
IncrementalAnalyzerBase
{
public
override
Task
AnalyzeSyntaxAsync
(
Document
document
,
CancellationToken
cancellationToken
)
public
override
Task
AnalyzeSyntaxAsync
(
Document
document
,
InvocationReasons
reasons
,
CancellationToken
cancellationToken
)
{
return
SyntaxTreeInfo
.
PrecalculateAsync
(
document
,
cancellationToken
);
}
...
...
src/Features/Core/Portable/Notification/SemanticChangeNotificationService.cs
浏览文件 @
52d00a2f
...
...
@@ -72,7 +72,7 @@ public bool NeedsReanalysisOnOptionChanged(object sender, OptionChangedEventArgs
return
false
;
}
public
async
Task
AnalyzeDocumentAsync
(
Document
document
,
SyntaxNode
bodyOpt
,
CancellationToken
cancellationToken
)
public
async
Task
AnalyzeDocumentAsync
(
Document
document
,
SyntaxNode
bodyOpt
,
InvocationReasons
reasons
,
CancellationToken
cancellationToken
)
{
// method body change
if
(
bodyOpt
!=
null
||
!
document
.
IsOpen
())
...
...
@@ -106,12 +106,12 @@ public Task NewSolutionSnapshotAsync(Solution solution, CancellationToken cancel
return
SpecializedTasks
.
EmptyTask
;
}
public
Task
AnalyzeSyntaxAsync
(
Document
document
,
CancellationToken
cancellationToken
)
public
Task
AnalyzeSyntaxAsync
(
Document
document
,
InvocationReasons
reasons
,
CancellationToken
cancellationToken
)
{
return
SpecializedTasks
.
EmptyTask
;
}
public
Task
AnalyzeProjectAsync
(
Project
project
,
bool
semanticsChanged
,
CancellationToken
cancellationToken
)
public
Task
AnalyzeProjectAsync
(
Project
project
,
bool
semanticsChanged
,
InvocationReasons
reasons
,
CancellationToken
cancellationToken
)
{
return
SpecializedTasks
.
EmptyTask
;
}
...
...
src/Features/Core/Portable/SolutionCrawler/AggregateIncrementalAnalyzer.cs
浏览文件 @
52d00a2f
...
...
@@ -64,30 +64,30 @@ public bool NeedsReanalysisOnOptionChanged(object sender, OptionChangedEventArgs
return
false
;
}
public
async
Task
AnalyzeSyntaxAsync
(
Document
document
,
CancellationToken
cancellationToken
)
public
async
Task
AnalyzeSyntaxAsync
(
Document
document
,
InvocationReasons
reasons
,
CancellationToken
cancellationToken
)
{
IIncrementalAnalyzer
analyzer
;
if
(
TryGetAnalyzer
(
document
.
Project
,
out
analyzer
))
{
await
analyzer
.
AnalyzeSyntaxAsync
(
document
,
cancellationToken
).
ConfigureAwait
(
false
);
await
analyzer
.
AnalyzeSyntaxAsync
(
document
,
reasons
,
cancellationToken
).
ConfigureAwait
(
false
);
}
}
public
async
Task
AnalyzeDocumentAsync
(
Document
document
,
SyntaxNode
bodyOpt
,
CancellationToken
cancellationToken
)
public
async
Task
AnalyzeDocumentAsync
(
Document
document
,
SyntaxNode
bodyOpt
,
InvocationReasons
reasons
,
CancellationToken
cancellationToken
)
{
IIncrementalAnalyzer
analyzer
;
if
(
TryGetAnalyzer
(
document
.
Project
,
out
analyzer
))
{
await
analyzer
.
AnalyzeDocumentAsync
(
document
,
bodyOpt
,
cancellationToken
).
ConfigureAwait
(
false
);
await
analyzer
.
AnalyzeDocumentAsync
(
document
,
bodyOpt
,
reasons
,
cancellationToken
).
ConfigureAwait
(
false
);
}
}
public
async
Task
AnalyzeProjectAsync
(
Project
project
,
bool
semanticsChanged
,
CancellationToken
cancellationToken
)
public
async
Task
AnalyzeProjectAsync
(
Project
project
,
bool
semanticsChanged
,
InvocationReasons
reasons
,
CancellationToken
cancellationToken
)
{
IIncrementalAnalyzer
analyzer
;
if
(
TryGetAnalyzer
(
project
,
out
analyzer
))
{
await
analyzer
.
AnalyzeProjectAsync
(
project
,
semanticsChanged
,
cancellationToken
).
ConfigureAwait
(
false
);
await
analyzer
.
AnalyzeProjectAsync
(
project
,
semanticsChanged
,
reasons
,
cancellationToken
).
ConfigureAwait
(
false
);
}
}
...
...
src/Features/Core/Portable/SolutionCrawler/IncrementalAnalyzerBase.cs
浏览文件 @
52d00a2f
...
...
@@ -39,17 +39,17 @@ public bool NeedsReanalysisOnOptionChanged(object sender, OptionChangedEventArgs
return
false
;
}
public
virtual
Task
AnalyzeSyntaxAsync
(
Document
document
,
CancellationToken
cancellationToken
)
public
virtual
Task
AnalyzeSyntaxAsync
(
Document
document
,
InvocationReasons
reasons
,
CancellationToken
cancellationToken
)
{
return
SpecializedTasks
.
EmptyTask
;
}
public
virtual
Task
AnalyzeDocumentAsync
(
Document
document
,
SyntaxNode
bodyOpt
,
CancellationToken
cancellationToken
)
public
virtual
Task
AnalyzeDocumentAsync
(
Document
document
,
SyntaxNode
bodyOpt
,
InvocationReasons
reasons
,
CancellationToken
cancellationToken
)
{
return
SpecializedTasks
.
EmptyTask
;
}
public
virtual
Task
AnalyzeProjectAsync
(
Project
project
,
bool
semanticsChanged
,
CancellationToken
cancellationToken
)
public
virtual
Task
AnalyzeProjectAsync
(
Project
project
,
bool
semanticsChanged
,
InvocationReasons
reasons
,
CancellationToken
cancellationToken
)
{
return
SpecializedTasks
.
EmptyTask
;
}
...
...
src/Features/Core/Portable/SolutionCrawler/WorkCoordinator.IncrementalAnalyzerProcessor.cs
浏览文件 @
52d00a2f
...
...
@@ -166,14 +166,15 @@ private void ResetLogAggregator()
Document
document
,
ImmutableArray
<
IIncrementalAnalyzer
>
analyzers
,
WorkItem
workItem
,
CancellationToken
cancellationToken
)
{
// process all analyzers for each categories in this order - syntax, body, document
if
(
workItem
.
MustRefresh
||
workItem
.
InvocationReasons
.
Contains
(
PredefinedInvocationReasons
.
SyntaxChanged
))
var
reasons
=
workItem
.
InvocationReasons
;
if
(
workItem
.
MustRefresh
||
reasons
.
Contains
(
PredefinedInvocationReasons
.
SyntaxChanged
))
{
await
RunAnalyzersAsync
(
analyzers
,
document
,
(
a
,
d
,
c
)
=>
a
.
AnalyzeSyntaxAsync
(
d
,
c
),
cancellationToken
).
ConfigureAwait
(
false
);
await
RunAnalyzersAsync
(
analyzers
,
document
,
(
a
,
d
,
c
)
=>
a
.
AnalyzeSyntaxAsync
(
d
,
reasons
,
c
),
cancellationToken
).
ConfigureAwait
(
false
);
}
if
(
workItem
.
MustRefresh
||
workItem
.
InvocationR
easons
.
Contains
(
PredefinedInvocationReasons
.
SemanticChanged
))
if
(
workItem
.
MustRefresh
||
r
easons
.
Contains
(
PredefinedInvocationReasons
.
SemanticChanged
))
{
await
RunAnalyzersAsync
(
analyzers
,
document
,
(
a
,
d
,
c
)
=>
a
.
AnalyzeDocumentAsync
(
d
,
null
,
c
),
cancellationToken
).
ConfigureAwait
(
false
);
await
RunAnalyzersAsync
(
analyzers
,
document
,
(
a
,
d
,
c
)
=>
a
.
AnalyzeDocumentAsync
(
d
,
null
,
reasons
,
c
),
cancellationToken
).
ConfigureAwait
(
false
);
}
else
{
...
...
@@ -207,10 +208,11 @@ private static async Task RunBodyAnalyzersAsync(ImmutableArray<IIncrementalAnaly
{
var
root
=
await
GetOrDefaultAsync
(
document
,
(
d
,
c
)
=>
d
.
GetSyntaxRootAsync
(
c
),
cancellationToken
).
ConfigureAwait
(
false
);
var
syntaxFactsService
=
document
.
Project
.
LanguageServices
.
GetService
<
ISyntaxFactsService
>();
var
reasons
=
workItem
.
InvocationReasons
;
if
(
root
==
null
||
syntaxFactsService
==
null
)
{
// as a fallback mechanism, if we can't run one method body due to some missing service, run whole document analyzer.
await
RunAnalyzersAsync
(
analyzers
,
document
,
(
a
,
d
,
c
)
=>
a
.
AnalyzeDocumentAsync
(
d
,
null
,
c
),
cancellationToken
).
ConfigureAwait
(
false
);
await
RunAnalyzersAsync
(
analyzers
,
document
,
(
a
,
d
,
c
)
=>
a
.
AnalyzeDocumentAsync
(
d
,
null
,
reasons
,
c
),
cancellationToken
).
ConfigureAwait
(
false
);
return
;
}
...
...
@@ -221,12 +223,12 @@ private static async Task RunBodyAnalyzersAsync(ImmutableArray<IIncrementalAnaly
{
// no active member means, change is out side of a method body, but it didn't affect semantics (such as change in comment)
// in that case, we update whole document (just this document) so that we can have updated locations.
await
RunAnalyzersAsync
(
analyzers
,
document
,
(
a
,
d
,
c
)
=>
a
.
AnalyzeDocumentAsync
(
d
,
null
,
c
),
cancellationToken
).
ConfigureAwait
(
false
);
await
RunAnalyzersAsync
(
analyzers
,
document
,
(
a
,
d
,
c
)
=>
a
.
AnalyzeDocumentAsync
(
d
,
null
,
reasons
,
c
),
cancellationToken
).
ConfigureAwait
(
false
);
return
;
}
// re-run just the body
await
RunAnalyzersAsync
(
analyzers
,
document
,
(
a
,
d
,
c
)
=>
a
.
AnalyzeDocumentAsync
(
d
,
activeMember
,
c
),
cancellationToken
).
ConfigureAwait
(
false
);
await
RunAnalyzersAsync
(
analyzers
,
document
,
(
a
,
d
,
c
)
=>
a
.
AnalyzeDocumentAsync
(
d
,
activeMember
,
reasons
,
c
),
cancellationToken
).
ConfigureAwait
(
false
);
}
catch
(
Exception
e
)
when
(
FatalError
.
ReportUnlessCanceled
(
e
))
{
...
...
src/Features/Core/Portable/SolutionCrawler/WorkCoordinator.LowPriorityProcessor.cs
浏览文件 @
52d00a2f
...
...
@@ -145,12 +145,13 @@ private async Task ProcessProjectAsync(ImmutableArray<IIncrementalAnalyzer> anal
var
project
=
processingSolution
.
GetProject
(
projectId
);
if
(
project
!=
null
)
{
var
semanticsChanged
=
workItem
.
InvocationReasons
.
Contains
(
PredefinedInvocationReasons
.
SemanticChanged
)
||
workItem
.
InvocationReasons
.
Contains
(
PredefinedInvocationReasons
.
SolutionRemoved
);
var
reasons
=
workItem
.
InvocationReasons
;
var
semanticsChanged
=
reasons
.
Contains
(
PredefinedInvocationReasons
.
SemanticChanged
)
||
reasons
.
Contains
(
PredefinedInvocationReasons
.
SolutionRemoved
);
using
(
Processor
.
EnableCaching
(
project
.
Id
))
{
await
RunAnalyzersAsync
(
analyzers
,
project
,
(
a
,
p
,
c
)
=>
a
.
AnalyzeProjectAsync
(
p
,
semanticsChanged
,
c
),
cancellationToken
).
ConfigureAwait
(
false
);
await
RunAnalyzersAsync
(
analyzers
,
project
,
(
a
,
p
,
c
)
=>
a
.
AnalyzeProjectAsync
(
p
,
semanticsChanged
,
reasons
,
c
),
cancellationToken
).
ConfigureAwait
(
false
);
}
}
else
...
...
src/Features/Core/Portable/SolutionCrawler/WorkCoordinator.NormalPriorityProcessor.cs
浏览文件 @
52d00a2f
...
...
@@ -472,15 +472,16 @@ private async Task ProcessReanalyzeDocumentAsync(WorkItem workItem, Document doc
await
RunAnalyzersAsync
(
reanalyzers
,
document
,
(
a
,
d
,
c
)
=>
a
.
DocumentResetAsync
(
d
,
c
),
cancellationToken
).
ConfigureAwait
(
false
);
// no request to re-run syntax change analysis. run it here
if
(!
workItem
.
InvocationReasons
.
Contains
(
PredefinedInvocationReasons
.
SyntaxChanged
))
var
reasons
=
workItem
.
InvocationReasons
;
if
(!
reasons
.
Contains
(
PredefinedInvocationReasons
.
SyntaxChanged
))
{
await
RunAnalyzersAsync
(
reanalyzers
,
document
,
(
a
,
d
,
c
)
=>
a
.
AnalyzeSyntaxAsync
(
d
,
c
),
cancellationToken
).
ConfigureAwait
(
false
);
await
RunAnalyzersAsync
(
reanalyzers
,
document
,
(
a
,
d
,
c
)
=>
a
.
AnalyzeSyntaxAsync
(
d
,
reasons
,
c
),
cancellationToken
).
ConfigureAwait
(
false
);
}
// no request to re-run semantic change analysis. run it here
if
(!
workItem
.
InvocationReasons
.
Contains
(
PredefinedInvocationReasons
.
SemanticChanged
))
{
await
RunAnalyzersAsync
(
reanalyzers
,
document
,
(
a
,
d
,
c
)
=>
a
.
AnalyzeDocumentAsync
(
d
,
null
,
c
),
cancellationToken
).
ConfigureAwait
(
false
);
await
RunAnalyzersAsync
(
reanalyzers
,
document
,
(
a
,
d
,
c
)
=>
a
.
AnalyzeDocumentAsync
(
d
,
null
,
reasons
,
c
),
cancellationToken
).
ConfigureAwait
(
false
);
}
}
catch
(
Exception
e
)
when
(
FatalError
.
ReportUnlessCanceled
(
e
))
...
...
@@ -530,7 +531,7 @@ private async Task ResetStatesAsync()
_currentSnapshotVersionTrackingSet
.
Clear
();
_processingSolution
=
currentSolution
;
await
RunAnalyzersAsync
(
this
.
Analyzers
,
currentSolution
,
(
a
,
s
,
c
)
=>
a
.
NewSolutionSnapshotAsync
(
s
,
c
),
this
.
CancellationToken
).
ConfigureAwait
(
false
);
foreach
(
var
id
in
this
.
Processor
.
GetOpenDocumentIds
())
...
...
src/VisualStudio/Core/Def/Implementation/DesignerAttribute/AbstractDesignerAttributeIncrementalAnalyzer.cs
浏览文件 @
52d00a2f
...
...
@@ -11,6 +11,7 @@
using
Microsoft.CodeAnalysis.Options
;
using
Microsoft.CodeAnalysis.Shared.Extensions
;
using
Microsoft.CodeAnalysis.Shared.TestHooks
;
using
Microsoft.CodeAnalysis.SolutionCrawler
;
using
Microsoft.CodeAnalysis.Versions
;
using
Microsoft.VisualStudio.Designer.Interfaces
;
using
Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem
;
...
...
@@ -63,7 +64,7 @@ public bool NeedsReanalysisOnOptionChanged(object sender, OptionChangedEventArgs
return
false
;
}
public
async
System
.
Threading
.
Tasks
.
Task
AnalyzeDocumentAsync
(
Document
document
,
SyntaxNode
bodyOpt
,
CancellationToken
cancellationToken
)
public
async
System
.
Threading
.
Tasks
.
Task
AnalyzeDocumentAsync
(
Document
document
,
SyntaxNode
bodyOpt
,
InvocationReasons
reasons
,
CancellationToken
cancellationToken
)
{
Contract
.
ThrowIfFalse
(
document
.
IsFromPrimaryBranch
());
...
...
@@ -309,12 +310,12 @@ public System.Threading.Tasks.Task DocumentCloseAsync(Document document, Cancell
return
SpecializedTasks
.
EmptyTask
;
}
public
System
.
Threading
.
Tasks
.
Task
AnalyzeSyntaxAsync
(
Document
document
,
CancellationToken
cancellationToken
)
public
System
.
Threading
.
Tasks
.
Task
AnalyzeSyntaxAsync
(
Document
document
,
InvocationReasons
reasons
,
CancellationToken
cancellationToken
)
{
return
SpecializedTasks
.
EmptyTask
;
}
public
System
.
Threading
.
Tasks
.
Task
AnalyzeProjectAsync
(
Project
project
,
bool
semanticsChanged
,
CancellationToken
cancellationToken
)
public
System
.
Threading
.
Tasks
.
Task
AnalyzeProjectAsync
(
Project
project
,
bool
semanticsChanged
,
InvocationReasons
reasons
,
CancellationToken
cancellationToken
)
{
return
SpecializedTasks
.
EmptyTask
;
}
...
...
src/VisualStudio/Core/Def/Implementation/SolutionSize/SolutionSizeTracker.cs
浏览文件 @
52d00a2f
...
...
@@ -64,7 +64,7 @@ public Task NewSolutionSnapshotAsync(Solution solution, CancellationToken cancel
return
SpecializedTasks
.
EmptyTask
;
}
public
async
Task
AnalyzeSyntaxAsync
(
Document
document
,
CancellationToken
cancellationToken
)
public
async
Task
AnalyzeSyntaxAsync
(
Document
document
,
InvocationReasons
reasons
,
CancellationToken
cancellationToken
)
{
if
(!
document
.
SupportsSyntaxTree
)
{
...
...
@@ -110,7 +110,7 @@ public void RemoveDocument(DocumentId documentId)
}
#
region
Not
Used
public
Task
AnalyzeDocumentAsync
(
Document
document
,
SyntaxNode
bodyOpt
,
CancellationToken
cancellationToken
)
public
Task
AnalyzeDocumentAsync
(
Document
document
,
SyntaxNode
bodyOpt
,
InvocationReasons
reasons
,
CancellationToken
cancellationToken
)
{
return
SpecializedTasks
.
EmptyTask
;
}
...
...
@@ -135,7 +135,7 @@ public bool NeedsReanalysisOnOptionChanged(object sender, OptionChangedEventArgs
return
false
;
}
public
Task
AnalyzeProjectAsync
(
Project
project
,
bool
semanticsChanged
,
CancellationToken
cancellationToken
)
public
Task
AnalyzeProjectAsync
(
Project
project
,
bool
semanticsChanged
,
InvocationReasons
reasons
,
CancellationToken
cancellationToken
)
{
return
SpecializedTasks
.
EmptyTask
;
}
...
...
src/Workspaces/Core/Portable/SolutionCrawler/IIncrementalAnalyzer.cs
浏览文件 @
52d00a2f
...
...
@@ -18,9 +18,9 @@ internal interface IIncrementalAnalyzer
/// </summary>
Task
DocumentResetAsync
(
Document
document
,
CancellationToken
cancellationToken
);
Task
AnalyzeSyntaxAsync
(
Document
document
,
CancellationToken
cancellationToken
);
Task
AnalyzeDocumentAsync
(
Document
document
,
SyntaxNode
bodyOpt
,
CancellationToken
cancellationToken
);
Task
AnalyzeProjectAsync
(
Project
project
,
bool
semanticsChanged
,
CancellationToken
cancellationToken
);
Task
AnalyzeSyntaxAsync
(
Document
document
,
InvocationReasons
reasons
,
CancellationToken
cancellationToken
);
Task
AnalyzeDocumentAsync
(
Document
document
,
SyntaxNode
bodyOpt
,
InvocationReasons
reasons
,
CancellationToken
cancellationToken
);
Task
AnalyzeProjectAsync
(
Project
project
,
bool
semanticsChanged
,
InvocationReasons
reasons
,
CancellationToken
cancellationToken
);
void
RemoveDocument
(
DocumentId
documentId
);
void
RemoveProject
(
ProjectId
projectId
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录