Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
1c933e04
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,发现更多精彩内容 >>
提交
1c933e04
编写于
8月 10, 2020
作者:
C
Cyrus Najmabadi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Simplify type checks.
上级
9062814b
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
19 addition
and
23 deletion
+19
-23
src/Workspaces/CSharp/Portable/CodeGeneration/CSharpSyntaxGenerator.cs
...s/CSharp/Portable/CodeGeneration/CSharpSyntaxGenerator.cs
+3
-11
src/Workspaces/CSharp/Portable/SemanticModelReuse/CSharpSemanticModelReuseLanguageService.cs
...nticModelReuse/CSharpSemanticModelReuseLanguageService.cs
+7
-6
src/Workspaces/Core/Portable/SemanticModelReuse/AbstractSemanticModelReuseLanguageService.cs
...icModelReuse/AbstractSemanticModelReuseLanguageService.cs
+6
-4
src/Workspaces/VisualBasic/Portable/SemanticModelReuse/VisualBasicSemanticModelReuseLanguageService.vb
...odelReuse/VisualBasicSemanticModelReuseLanguageService.vb
+3
-2
未找到文件。
src/Workspaces/CSharp/Portable/CodeGeneration/CSharpSyntaxGenerator.cs
浏览文件 @
1c933e04
...
...
@@ -2495,13 +2495,7 @@ public override SyntaxNode InsertAccessors(SyntaxNode declaration, int index, IE
}
internal
static
AccessorListSyntax
GetAccessorList
(
SyntaxNode
declaration
)
=>
declaration
switch
{
PropertyDeclarationSyntax
property
=>
property
.
AccessorList
,
IndexerDeclarationSyntax
indexer
=>
indexer
.
AccessorList
,
EventDeclarationSyntax
@event
=>
@event
.
AccessorList
,
_
=>
null
,
};
=>
(
declaration
as
BasePropertyDeclarationSyntax
)?.
AccessorList
;
private
static
bool
CanHaveAccessors
(
SyntaxNode
declaration
)
=>
declaration
.
Kind
()
switch
...
...
@@ -2513,11 +2507,9 @@ private static bool CanHaveAccessors(SyntaxNode declaration)
};
private
static
SyntaxNode
WithAccessorList
(
SyntaxNode
declaration
,
AccessorListSyntax
accessorList
)
=>
declaration
.
Kind
()
switch
=>
declaration
switch
{
SyntaxKind
.
PropertyDeclaration
=>
((
PropertyDeclarationSyntax
)
declaration
).
WithAccessorList
(
accessorList
),
SyntaxKind
.
IndexerDeclaration
=>
((
PropertyDeclarationSyntax
)
declaration
).
WithAccessorList
(
accessorList
),
SyntaxKind
.
EventDeclaration
=>
((
EventDeclarationSyntax
)
declaration
).
WithAccessorList
(
accessorList
),
BasePropertyDeclarationSyntax
baseProperty
=>
baseProperty
.
WithAccessorList
(
accessorList
),
_
=>
declaration
,
};
...
...
src/Workspaces/CSharp/Portable/SemanticModelReuse/CSharpSemanticModelReuseLanguageService.cs
浏览文件 @
1c933e04
...
...
@@ -22,6 +22,7 @@ namespace Microsoft.CodeAnalysis.CSharp.SemanticModelReuse
internal
class
CSharpSemanticModelReuseLanguageService
:
AbstractSemanticModelReuseLanguageService
<
MemberDeclarationSyntax
,
BaseMethodDeclarationSyntax
,
BasePropertyDeclarationSyntax
,
AccessorDeclarationSyntax
>
{
[
ImportingConstructor
]
...
...
@@ -32,15 +33,15 @@ public CSharpSemanticModelReuseLanguageService()
protected
override
ISyntaxFacts
SyntaxFacts
=>
CSharpSyntaxFacts
.
Instance
;
protected
override
MemberDeclarationSyntax
GetAccessorContainerDeclaration
(
AccessorDeclarationSyntax
currentA
ccessor
)
protected
override
BasePropertyDeclarationSyntax
GetBasePropertyDeclaration
(
AccessorDeclarationSyntax
a
ccessor
)
{
Contract
.
ThrowIfFalse
(
currentA
ccessor
.
Parent
is
AccessorListSyntax
);
Contract
.
ThrowIfFalse
(
currentAccessor
.
Parent
.
Parent
is
Member
DeclarationSyntax
);
return
(
MemberDeclarationSyntax
)
currentA
ccessor
.
Parent
.
Parent
;
Contract
.
ThrowIfFalse
(
a
ccessor
.
Parent
is
AccessorListSyntax
);
Contract
.
ThrowIfFalse
(
accessor
.
Parent
.
Parent
is
BaseProperty
DeclarationSyntax
);
return
(
BasePropertyDeclarationSyntax
)
a
ccessor
.
Parent
.
Parent
;
}
protected
override
SyntaxList
<
AccessorDeclarationSyntax
>
GetAccessors
(
MemberDeclarationSyntax
member
)
=>
CSharpSyntaxGenerator
.
GetAccessorList
(
member
)
.
Accessors
;
protected
override
SyntaxList
<
AccessorDeclarationSyntax
>
GetAccessors
(
BasePropertyDeclarationSyntax
baseProperty
)
=>
baseProperty
.
AccessorList
.
Accessors
;
public
override
SyntaxNode
?
TryGetContainingMethodBodyForSpeculation
(
SyntaxNode
node
)
{
...
...
src/Workspaces/Core/Portable/SemanticModelReuse/AbstractSemanticModelReuseLanguageService.cs
浏览文件 @
1c933e04
...
...
@@ -15,9 +15,11 @@ namespace Microsoft.CodeAnalysis.SemanticModelReuse
internal
abstract
class
AbstractSemanticModelReuseLanguageService
<
TMemberDeclarationSyntax
,
TBaseMethodDeclarationSyntax
,
TBasePropertyDeclarationSyntax
,
TAccessorDeclarationSyntax
>
:
ISemanticModelReuseLanguageService
where
TMemberDeclarationSyntax
:
SyntaxNode
where
TBaseMethodDeclarationSyntax
:
TMemberDeclarationSyntax
where
TBasePropertyDeclarationSyntax
:
TMemberDeclarationSyntax
where
TAccessorDeclarationSyntax
:
SyntaxNode
{
protected
abstract
ISyntaxFacts
SyntaxFacts
{
get
;
}
...
...
@@ -25,8 +27,8 @@ internal abstract class AbstractSemanticModelReuseLanguageService<
public
abstract
SyntaxNode
?
TryGetContainingMethodBodyForSpeculation
(
SyntaxNode
node
);
protected
abstract
Task
<
SemanticModel
?>
TryGetSpeculativeSemanticModelWorkerAsync
(
SemanticModel
previousSemanticModel
,
SyntaxNode
currentBodyNode
,
CancellationToken
cancellationToken
);
protected
abstract
SyntaxList
<
TAccessorDeclarationSyntax
>
GetAccessors
(
T
MemberDeclarationSyntax
member
);
protected
abstract
T
MemberDeclarationSyntax
GetAccessorContainerDeclaration
(
TAccessorDeclarationSyntax
currentA
ccessor
);
protected
abstract
SyntaxList
<
TAccessorDeclarationSyntax
>
GetAccessors
(
T
BasePropertyDeclarationSyntax
baseProperty
);
protected
abstract
T
BasePropertyDeclarationSyntax
GetBasePropertyDeclaration
(
TAccessorDeclarationSyntax
a
ccessor
);
public
Task
<
SemanticModel
?>
TryGetSpeculativeSemanticModelAsync
(
SemanticModel
previousSemanticModel
,
SyntaxNode
currentBodyNode
,
CancellationToken
cancellationToken
)
{
...
...
@@ -45,10 +47,10 @@ protected SyntaxNode GetPreviousBodyNode(SyntaxNode previousRoot, SyntaxNode cur
// in the case of an accessor, have to find the previous accessor in the previous prop/event corresponding
// to the current prop/event.
var
currentContainer
=
Get
AccessorContainer
Declaration
(
currentAccessor
);
var
currentContainer
=
Get
BaseProperty
Declaration
(
currentAccessor
);
var
previousContainer
=
GetPreviousBodyNode
(
previousRoot
,
currentRoot
,
currentContainer
);
if
(
previousContainer
is
not
T
Member
DeclarationSyntax
previousMember
)
if
(
previousContainer
is
not
T
BaseProperty
DeclarationSyntax
previousMember
)
{
Debug
.
Fail
(
"Previous container didn't map back to a normal accessor container."
);
return
null
;
...
...
src/Workspaces/VisualBasic/Portable/SemanticModelReuse/VisualBasicSemanticModelReuseLanguageService.vb
浏览文件 @
1c933e04
...
...
@@ -17,6 +17,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.SemanticModelReuse
Inherits
AbstractSemanticModelReuseLanguageService
(
Of
DeclarationStatementSyntax
,
MethodBlockBaseSyntax
,
DeclarationStatementSyntax
,
AccessorBlockSyntax
)
<
ImportingConstructor
>
...
...
@@ -26,8 +27,8 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.SemanticModelReuse
Protected
Overrides
ReadOnly
Property
SyntaxFacts
As
ISyntaxFacts
=
VisualBasicSyntaxFacts
.
Instance
Protected
Overrides
Function
Get
AccessorContainerDeclaration
(
currentA
ccessor
As
AccessorBlockSyntax
)
As
DeclarationStatementSyntax
Dim
container
=
currentA
ccessor
.
Parent
Protected
Overrides
Function
Get
BasePropertyDeclaration
(
a
ccessor
As
AccessorBlockSyntax
)
As
DeclarationStatementSyntax
Dim
container
=
a
ccessor
.
Parent
Contract
.
ThrowIfFalse
(
TypeOf
container
Is
PropertyBlockSyntax
OrElse
TypeOf
container
Is
EventBlockSyntax
)
Return
DirectCast
(
container
,
DeclarationStatementSyntax
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录