Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
f14e7819
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,发现更多精彩内容 >>
提交
f14e7819
编写于
9月 20, 2014
作者:
R
RoslynTeam
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Respond to yet more code review feedback from the Diagnostics API change. (changeset 1339194)
上级
17d175f1
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
43 addition
and
21 deletion
+43
-21
Src/Compilers/Core/Portable/DiagnosticAnalyzer/AnalyzerDriver.cs
...pilers/Core/Portable/DiagnosticAnalyzer/AnalyzerDriver.cs
+43
-21
未找到文件。
Src/Compilers/Core/Portable/DiagnosticAnalyzer/AnalyzerDriver.cs
浏览文件 @
f14e7819
...
...
@@ -765,30 +765,54 @@ protected override async Task AnalyzeDeclaringReferenceAsync(SymbolDeclaredCompi
declaredNode
.
DescendantNodesAndSelf
(
descendIntoTrivia
:
true
)
:
declaredNode
.
DescendantNodesAndSelf
(
n
=>
!
descendantDeclsToSkip
.
Contains
(
n
),
descendIntoTrivia
:
true
).
Except
(
descendantDeclsToSkip
);
ExecuteSyntax
Analyzer
s
(
nodesToAnalyze
,
analyzersByKind
,
semanticModel
,
a
ddDiagnostic
,
continueOnAnalyzerException
,
analyzerOptions
,
getKind
,
cancellationToken
);
ExecuteSyntax
NodeAction
s
(
nodesToAnalyze
,
analyzersByKind
,
semanticModel
,
a
nalyzerOptions
,
addDiagnostic
,
continueOnAnalyzerException
,
getKind
,
cancellationToken
);
}
/// <summary>
/// Executes the given code block analyzers on all the executable code blocks for each declaration info in <paramref name="declarationsInNode"/>.
/// Executes the given syntax node action on the given syntax node.
/// </summary>
/// <param name="syntaxNodeAction">Action to execute.</param>
/// <param name="node">Syntax node to be analyzed.</param>
/// <param name="semanticModel">SemanticModel to be used in the analysis.</param>
/// <param name="analyzerOptions">Analyzer options.</param>
/// <param name="addDiagnostic">Delegate to add diagnostics.</param>
/// <param name="continueOnAnalyzerException">Predicate to decide if exceptions from the action should be handled or not.</param>
/// <param name="cancellationToken">Cancellation token.</param>
public
static
void
ExecuteSyntaxNodeAction
(
SyntaxNodeAnalyzerAction
<
TSyntaxKind
>
syntaxNodeAction
,
SyntaxNode
node
,
SemanticModel
semanticModel
,
AnalyzerOptions
analyzerOptions
,
Action
<
Diagnostic
>
addDiagnostic
,
Func
<
Exception
,
DiagnosticAnalyzer
,
bool
>
continueOnAnalyzerException
,
CancellationToken
cancellationToken
)
{
var
syntaxNodeContext
=
new
SyntaxNodeAnalysisContext
(
node
,
semanticModel
,
analyzerOptions
,
addDiagnostic
,
cancellationToken
);
// Catch Exception from action.
ExecuteAndCatchIfThrows
(
syntaxNodeAction
.
Analyzer
,
addDiagnostic
,
continueOnAnalyzerException
,
cancellationToken
,
()
=>
syntaxNodeAction
.
Action
(
syntaxNodeContext
));
}
/// <summary>
/// Executes the given code block actions on all the executable code blocks for each declaration info in <paramref name="declarationsInNode"/>.
/// </summary>
/// <param name="codeBlockStartedAnalyzers">Code block analyzer factories.</param>
/// <param name="codeBlockEndedAnalyzers">Stateless code block analyzers.</param>
/// <param name="declarationsInNode">Declarations to be analyzed.</param>
/// <param name="semanticModel">SemanticModel to be shared amongst all actions.</param>
/// <param name="analyzerOptions">Analyzer options.</param>
/// <param name="semanticModel">SemanticModel to be shared amongst all analyzers.</param>
/// <param name="addDiagnostic">Delegate to add diagnostics.</param>
/// <param name="continueOnAnalyzerException">Predicate to decide if exceptions from any a
nalyzer
should be handled or not.</param>
/// <param name="continueOnAnalyzerException">Predicate to decide if exceptions from any a
ction
should be handled or not.</param>
/// <param name="getKind">Delegate to compute language specific syntax kind for a syntax node.</param>
/// <param name="cancellationToken">Cancellation token.</param>
/// <param name="getAnalyzerKindsOfInterest">Optional delegate to return cached syntax kinds.
/// If null, then this property is explicitly invoked by the driver to compute syntax kinds of interest.</param>
public
static
void
ExecuteCodeBlockA
nalyzer
s
(
public
static
void
ExecuteCodeBlockA
ction
s
(
IEnumerable
<
CodeBlockStartAnalyzerAction
<
TSyntaxKind
>>
codeBlockStartedAnalyzers
,
IEnumerable
<
CodeBlockEndAnalyzerAction
<
TSyntaxKind
>>
codeBlockEndedAnalyzers
,
IEnumerable
<
DeclarationInfo
>
declarationsInNode
,
AnalyzerOptions
analyzerOptions
,
SemanticModel
semanticModel
,
AnalyzerOptions
analyzerOptions
,
Action
<
Diagnostic
>
addDiagnostic
,
Func
<
Exception
,
DiagnosticAnalyzer
,
bool
>
continueOnAnalyzerException
,
Func
<
SyntaxNode
,
TSyntaxKind
>
getKind
,
...
...
@@ -862,8 +886,8 @@ protected override async Task AnalyzeDeclaringReferenceAsync(SymbolDeclaredCompi
GetNodeAnalyzersByKind
(
executableNodeAnalyzers
,
executableNodeAnalyzersByKind
,
addDiagnostic
,
getAnalyzerKindsOfInterest
);
var
nodesToAnalyze
=
executableCodeBlocks
.
SelectMany
(
cb
=>
cb
.
DescendantNodesAndSelf
());
ExecuteSyntax
Analyzer
s
(
nodesToAnalyze
,
executableNodeAnalyzersByKind
,
semanticModel
,
a
ddDiagnostic
,
continueOnAnalyzerException
,
analyzerOptions
,
getKind
,
cancellationToken
);
ExecuteSyntax
NodeAction
s
(
nodesToAnalyze
,
executableNodeAnalyzersByKind
,
semanticModel
,
a
nalyzerOptions
,
addDiagnostic
,
continueOnAnalyzerException
,
getKind
,
cancellationToken
);
foreach
(
var
b
in
executableNodeAnalyzersByKind
.
Values
)
{
...
...
@@ -949,29 +973,27 @@ protected override async Task AnalyzeDeclaringReferenceAsync(SymbolDeclaredCompi
}
}
private
static
void
ExecuteSyntax
Analyzer
s
(
private
static
void
ExecuteSyntax
NodeAction
s
(
IEnumerable
<
SyntaxNode
>
nodesToAnalyze
,
IDictionary
<
TSyntaxKind
,
ArrayBuilder
<
SyntaxNodeAnalyzerAction
<
TSyntaxKind
>>>
nodeA
nalyzer
sByKind
,
IDictionary
<
TSyntaxKind
,
ArrayBuilder
<
SyntaxNodeAnalyzerAction
<
TSyntaxKind
>>>
nodeA
ction
sByKind
,
SemanticModel
model
,
Action
<
Diagnostic
>
addDiagnostic
,
Func
<
Exception
,
DiagnosticAnalyzer
,
bool
>
continueOnAnalyzerException
,
AnalyzerOptions
analyzerOptions
,
Action
<
Diagnostic
>
addDiagnostic
,
Func
<
Exception
,
DiagnosticAnalyzer
,
bool
>
continueOnException
,
Func
<
SyntaxNode
,
TSyntaxKind
>
getKind
,
CancellationToken
cancellationToken
)
{
Debug
.
Assert
(
nodeA
nalyzer
sByKind
!=
null
);
Debug
.
Assert
(
nodeA
nalyzer
sByKind
.
Any
());
Debug
.
Assert
(
nodeA
ction
sByKind
!=
null
);
Debug
.
Assert
(
nodeA
ction
sByKind
.
Any
());
foreach
(
var
child
in
nodesToAnalyze
)
{
ArrayBuilder
<
SyntaxNodeAnalyzerAction
<
TSyntaxKind
>>
a
nalyzer
sForKind
;
if
(
nodeA
nalyzersByKind
.
TryGetValue
(
getKind
(
child
),
out
analyzer
sForKind
))
ArrayBuilder
<
SyntaxNodeAnalyzerAction
<
TSyntaxKind
>>
a
ction
sForKind
;
if
(
nodeA
ctionsByKind
.
TryGetValue
(
getKind
(
child
),
out
action
sForKind
))
{
foreach
(
var
analyzer
in
a
nalyzer
sForKind
)
foreach
(
var
analyzer
in
a
ction
sForKind
)
{
var
syntaxNodeContext
=
new
SyntaxNodeAnalysisContext
(
child
,
model
,
analyzerOptions
,
addDiagnostic
,
cancellationToken
);
// Catch Exception from analyzer.
ExecuteAndCatchIfThrows
(
analyzer
.
Analyzer
,
addDiagnostic
,
continueOnAnalyzerException
,
cancellationToken
,
()
=>
analyzer
.
Action
(
syntaxNodeContext
));
ExecuteSyntaxNodeAction
(
analyzer
,
child
,
model
,
analyzerOptions
,
addDiagnostic
,
continueOnException
,
cancellationToken
);
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录