Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
f88f4cde
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,发现更多精彩内容 >>
提交
f88f4cde
编写于
12月 26, 2016
作者:
C
CyrusNajmabadi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Store data in the decl-table so we don't have to go back to the source tree.
上级
886ece81
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
44 addition
and
18 deletion
+44
-18
src/Compilers/CSharp/Portable/Declarations/DeclarationTreeBuilder.cs
...rs/CSharp/Portable/Declarations/DeclarationTreeBuilder.cs
+13
-3
src/Compilers/CSharp/Portable/Declarations/MergedTypeDeclaration.cs
...ers/CSharp/Portable/Declarations/MergedTypeDeclaration.cs
+16
-0
src/Compilers/CSharp/Portable/Declarations/SingleTypeDeclaration.cs
...ers/CSharp/Portable/Declarations/SingleTypeDeclaration.cs
+3
-0
src/Compilers/CSharp/Portable/Symbols/Source/SourceNamedTypeSymbol.cs
...s/CSharp/Portable/Symbols/Source/SourceNamedTypeSymbol.cs
+9
-9
src/Compilers/CSharp/Test/Symbol/DeclarationTests.cs
src/Compilers/CSharp/Test/Symbol/DeclarationTests.cs
+3
-6
未找到文件。
src/Compilers/CSharp/Portable/Declarations/DeclarationTreeBuilder.cs
浏览文件 @
f88f4cde
...
@@ -279,6 +279,11 @@ private SingleNamespaceOrTypeDeclaration VisitTypeDeclaration(TypeDeclarationSyn
...
@@ -279,6 +279,11 @@ private SingleNamespaceOrTypeDeclaration VisitTypeDeclaration(TypeDeclarationSyn
declFlags
|=
SingleTypeDeclaration
.
TypeDeclarationFlags
.
HasBaseDeclarations
;
declFlags
|=
SingleTypeDeclaration
.
TypeDeclarationFlags
.
HasBaseDeclarations
;
}
}
if
(
node
.
ConstraintClauses
.
Count
>
0
)
{
declFlags
|=
SingleTypeDeclaration
.
TypeDeclarationFlags
.
HasConstraints
;
}
var
memberNames
=
GetNonTypeMemberNames
(((
Syntax
.
InternalSyntax
.
TypeDeclarationSyntax
)(
node
.
Green
)).
Members
,
var
memberNames
=
GetNonTypeMemberNames
(((
Syntax
.
InternalSyntax
.
TypeDeclarationSyntax
)(
node
.
Green
)).
Members
,
ref
declFlags
);
ref
declFlags
);
...
@@ -316,9 +321,14 @@ private ImmutableArray<SingleTypeDeclaration> VisitTypeChildren(TypeDeclarationS
...
@@ -316,9 +321,14 @@ private ImmutableArray<SingleTypeDeclaration> VisitTypeChildren(TypeDeclarationS
public
override
SingleNamespaceOrTypeDeclaration
VisitDelegateDeclaration
(
DelegateDeclarationSyntax
node
)
public
override
SingleNamespaceOrTypeDeclaration
VisitDelegateDeclaration
(
DelegateDeclarationSyntax
node
)
{
{
SingleTypeDeclaration
.
TypeDeclarationFlags
declFlags
=
node
.
AttributeLists
.
Any
()
?
var
declFlags
=
node
.
AttributeLists
.
Any
()
SingleTypeDeclaration
.
TypeDeclarationFlags
.
HasAnyAttributes
:
?
SingleTypeDeclaration
.
TypeDeclarationFlags
.
HasAnyAttributes
SingleTypeDeclaration
.
TypeDeclarationFlags
.
None
;
:
SingleTypeDeclaration
.
TypeDeclarationFlags
.
None
;
if
(
node
.
ConstraintClauses
.
Count
>
0
)
{
declFlags
|=
SingleTypeDeclaration
.
TypeDeclarationFlags
.
HasConstraints
;
}
declFlags
|=
SingleTypeDeclaration
.
TypeDeclarationFlags
.
HasAnyNontypeMembers
;
declFlags
|=
SingleTypeDeclaration
.
TypeDeclarationFlags
.
HasAnyNontypeMembers
;
...
...
src/Compilers/CSharp/Portable/Declarations/MergedTypeDeclaration.cs
浏览文件 @
f88f4cde
...
@@ -123,6 +123,22 @@ public bool AnyMemberHasAttributes
...
@@ -123,6 +123,22 @@ public bool AnyMemberHasAttributes
}
}
}
}
public
bool
HasConstraints
{
get
{
foreach
(
var
decl
in
this
.
Declarations
)
{
if
(
decl
.
HasConstraints
)
{
return
true
;
}
}
return
false
;
}
}
public
LexicalSortKey
GetLexicalSortKey
(
CSharpCompilation
compilation
)
public
LexicalSortKey
GetLexicalSortKey
(
CSharpCompilation
compilation
)
{
{
LexicalSortKey
sortKey
=
new
LexicalSortKey
(
Declarations
[
0
].
NameLocation
,
compilation
);
LexicalSortKey
sortKey
=
new
LexicalSortKey
(
Declarations
[
0
].
NameLocation
,
compilation
);
...
...
src/Compilers/CSharp/Portable/Declarations/SingleTypeDeclaration.cs
浏览文件 @
f88f4cde
...
@@ -26,6 +26,7 @@ internal enum TypeDeclarationFlags : byte
...
@@ -26,6 +26,7 @@ internal enum TypeDeclarationFlags : byte
HasBaseDeclarations
=
1
<<
3
,
HasBaseDeclarations
=
1
<<
3
,
AnyMemberHasAttributes
=
1
<<
4
,
AnyMemberHasAttributes
=
1
<<
4
,
HasAnyNontypeMembers
=
1
<<
5
,
HasAnyNontypeMembers
=
1
<<
5
,
HasConstraints
=
1
<<
6
,
}
}
internal
SingleTypeDeclaration
(
internal
SingleTypeDeclaration
(
...
@@ -124,6 +125,8 @@ public bool AnyMemberHasAttributes
...
@@ -124,6 +125,8 @@ public bool AnyMemberHasAttributes
}
}
}
}
public
bool
HasConstraints
=>
(
_flags
&
TypeDeclarationFlags
.
HasConstraints
)
!=
0
;
public
bool
HasAnyNontypeMembers
public
bool
HasAnyNontypeMembers
{
{
get
get
...
...
src/Compilers/CSharp/Portable/Symbols/Source/SourceNamedTypeSymbol.cs
浏览文件 @
f88f4cde
...
@@ -84,6 +84,15 @@ internal SourceNamedTypeSymbol(NamespaceOrTypeSymbol containingSymbol, MergedTyp
...
@@ -84,6 +84,15 @@ internal SourceNamedTypeSymbol(NamespaceOrTypeSymbol containingSymbol, MergedTyp
// Nested types are never unified.
// Nested types are never unified.
_lazyIsExplicitDefinitionOfNoPiaLocalType
=
ThreeState
.
False
;
_lazyIsExplicitDefinitionOfNoPiaLocalType
=
ThreeState
.
False
;
}
}
if
(
declaration
.
Arity
==
0
&&
declaration
.
HasConstraints
)
{
foreach
(
var
syntaxRef
in
this
.
SyntaxReferences
)
{
var
constraintClauses
=
GetConstraintClauses
((
CSharpSyntaxNode
)
syntaxRef
.
GetSyntax
());
ReportErrorIfHasConstraints
(
constraintClauses
,
diagnostics
);
}
}
}
}
#
region
Syntax
#
region
Syntax
...
@@ -118,15 +127,6 @@ private ImmutableArray<TypeParameterSymbol> MakeTypeParameters(DiagnosticBag dia
...
@@ -118,15 +127,6 @@ private ImmutableArray<TypeParameterSymbol> MakeTypeParameters(DiagnosticBag dia
{
{
if
(
declaration
.
Arity
==
0
)
if
(
declaration
.
Arity
==
0
)
{
{
if
(
declaration
.
Kind
!=
DeclarationKind
.
Enum
)
{
foreach
(
var
syntaxRef
in
this
.
SyntaxReferences
)
{
var
constraintClauses
=
GetConstraintClauses
((
CSharpSyntaxNode
)
syntaxRef
.
GetSyntax
());
ReportErrorIfHasConstraints
(
constraintClauses
,
diagnostics
);
}
}
return
ImmutableArray
<
TypeParameterSymbol
>.
Empty
;
return
ImmutableArray
<
TypeParameterSymbol
>.
Empty
;
}
}
...
...
src/Compilers/CSharp/Test/Symbol/DeclarationTests.cs
浏览文件 @
f88f4cde
...
@@ -304,15 +304,12 @@ public class B
...
@@ -304,15 +304,12 @@ public class B
var
method
=
(
MethodSymbol
)
type
.
GetMembers
().
First
();
var
method
=
(
MethodSymbol
)
type
.
GetMembers
().
First
();
Assert
.
Equal
(
1
,
countedTree
.
AccessCount
);
Assert
.
Equal
(
1
,
countedTree
.
AccessCount
);
// To get the return type, we need to get the type parameters of the containing type.
// Once we have the method, we shouldn't need to go back to syntax again.
// That may cause us to go back to the syntax to check for Type-Parameter + Constraint
// issues.
var
returnType
=
method
.
ReturnType
;
var
returnType
=
method
.
ReturnType
;
Assert
.
Equal
(
3
,
countedTree
.
AccessCount
);
Assert
.
Equal
(
1
,
countedTree
.
AccessCount
);
// Once we have the method, we shouldn't need to go back to syntax again.
var
parameterType
=
method
.
Parameters
.
Single
();
var
parameterType
=
method
.
Parameters
.
Single
();
Assert
.
Equal
(
3
,
countedTree
.
AccessCount
);
Assert
.
Equal
(
1
,
countedTree
.
AccessCount
);
}
}
private
class
CountedSyntaxTree
:
CSharpSyntaxTree
private
class
CountedSyntaxTree
:
CSharpSyntaxTree
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录