Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
e031fa96
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,发现更多精彩内容 >>
提交
e031fa96
编写于
9月 29, 2015
作者:
A
Andrew Casey
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Reduce code duplication.
上级
0b6941b8
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
23 addition
and
50 deletion
+23
-50
src/Compilers/CSharp/Portable/Binder/Binder_Lookup.cs
src/Compilers/CSharp/Portable/Binder/Binder_Lookup.cs
+16
-11
src/Compilers/CSharp/Portable/Binder/Imports.cs
src/Compilers/CSharp/Portable/Binder/Imports.cs
+5
-17
src/Compilers/CSharp/Portable/Compilation/CSharpCompilation.cs
...ompilers/CSharp/Portable/Compilation/CSharpCompilation.cs
+2
-22
未找到文件。
src/Compilers/CSharp/Portable/Binder/Binder_Lookup.cs
浏览文件 @
e031fa96
...
...
@@ -1504,17 +1504,7 @@ private void AddMemberLookupSymbolsInfoInSubmissions(LookupSymbolsInfo result, T
{
foreach
(
var
usingAlias
in
usingAliases
)
{
var
aliasSymbol
=
usingAlias
.
Alias
;
var
targetSymbol
=
aliasSymbol
.
GetAliasTarget
(
basesBeingResolved
:
null
);
if
(
originalBinder
.
CanAddLookupSymbolInfo
(
targetSymbol
,
options
,
null
))
{
// Note: we do not mark nodes when looking up arities or names. This is because these two
// types of lookup are only around to make the public
// SemanticModel.LookupNames/LookupSymbols work and do not count as usages of the directives
// when the actual code is bound.
result
.
AddSymbol
(
aliasSymbol
,
aliasSymbol
.
Name
,
0
);
}
AddAliasSymbolToResult
(
result
,
usingAlias
.
Alias
,
options
,
originalBinder
);
}
}
...
...
@@ -1525,6 +1515,21 @@ private void AddMemberLookupSymbolsInfoInSubmissions(LookupSymbolsInfo result, T
}
}
/// <remarks>
/// Note: we do not mark nodes when looking up arities or names. This is because these two
/// types of lookup are only around to make the public
/// SemanticModel.LookupNames/LookupSymbols work and do not count as usages of the directives
/// when the actual code is bound.
/// </remarks>
internal
static
void
AddAliasSymbolToResult
(
LookupSymbolsInfo
result
,
AliasSymbol
aliasSymbol
,
LookupOptions
options
,
Binder
originalBinder
)
{
var
targetSymbol
=
aliasSymbol
.
GetAliasTarget
(
basesBeingResolved
:
null
);
if
(
originalBinder
.
CanAddLookupSymbolInfo
(
targetSymbol
,
options
,
null
))
{
result
.
AddSymbol
(
aliasSymbol
,
aliasSymbol
.
Name
,
0
);
}
}
private
static
void
AddMemberLookupSymbolsInfoInNamespace
(
LookupSymbolsInfo
result
,
NamespaceSymbol
ns
,
LookupOptions
options
,
Binder
originalBinder
)
{
foreach
(
var
symbol
in
GetCandidateMembers
(
ns
,
options
,
originalBinder
))
...
...
src/Compilers/CSharp/Portable/Binder/Imports.cs
浏览文件 @
e031fa96
...
...
@@ -318,7 +318,8 @@ private void MarkImportDirective(CSharpSyntaxNode directive, bool callerIsSemant
private
static
void
MarkImportDirective
(
CSharpCompilation
compilation
,
CSharpSyntaxNode
directive
,
bool
callerIsSemanticModel
)
{
if
(
directive
!=
null
&&
compilation
!=
null
&&
!
callerIsSemanticModel
)
Debug
.
Assert
(
compilation
!=
null
);
// If any directives are used, then there must be a compilation.
if
(
directive
!=
null
&&
!
callerIsSemanticModel
)
{
compilation
.
MarkImportDirectiveAsUsed
(
directive
);
}
...
...
@@ -598,25 +599,12 @@ internal void AddLookupSymbolsInfoInAliases(Binder originalBinder, LookupSymbols
{
foreach
(
var
usingAlias
in
this
.
UsingAliases
.
Values
)
{
var
usingAliasSymbol
=
usingAlias
.
Alias
;
var
usingAliasTargetSymbol
=
usingAliasSymbol
.
GetAliasTarget
(
basesBeingResolved
:
null
);
if
(
originalBinder
.
CanAddLookupSymbolInfo
(
usingAliasTargetSymbol
,
options
,
null
))
{
result
.
AddSymbol
(
usingAliasSymbol
,
usingAliasSymbol
.
Name
,
0
);
}
Binder
.
AddAliasSymbolToResult
(
result
,
usingAlias
.
Alias
,
options
,
originalBinder
);
}
if
(
this
.
ExternAliases
!=
null
)
foreach
(
var
externAlias
in
this
.
ExternAliases
)
{
foreach
(
var
externAlias
in
this
.
ExternAliases
)
{
var
externAliasSymbol
=
externAlias
.
Alias
;
var
externAliasTargetSymbol
=
externAliasSymbol
.
GetAliasTarget
(
basesBeingResolved
:
null
);
if
(
originalBinder
.
CanAddLookupSymbolInfo
(
externAliasTargetSymbol
,
options
,
null
))
{
result
.
AddSymbol
(
externAliasSymbol
,
externAliasSymbol
.
Name
,
0
);
}
}
Binder
.
AddAliasSymbolToResult
(
result
,
externAlias
.
Alias
,
options
,
originalBinder
);
}
}
...
...
src/Compilers/CSharp/Portable/Compilation/CSharpCompilation.cs
浏览文件 @
e031fa96
...
...
@@ -1220,26 +1220,6 @@ private ImmutableArray<NamespaceOrTypeAndUsingDirective> BindExternalUsings()
var
externalUsings
=
ArrayBuilder
<
NamespaceOrTypeAndUsingDirective
>.
GetInstance
();
var
uniqueTargets
=
PooledHashSet
<
NamespaceOrTypeSymbol
>.
GetInstance
();
foreach
(
var
previousUsing
in
previousSubmission
.
ExternalUsings
)
{
var
previousTarget
=
previousUsing
.
NamespaceOrType
;
if
(
previousTarget
.
IsType
)
{
if
(
uniqueTargets
.
Add
(
previousTarget
))
{
externalUsings
.
Add
(
previousUsing
);
}
}
else
{
var
expandedNamespace
=
ExpandPreviousSubmissionNamespace
((
NamespaceSymbol
)
previousTarget
,
this
.
GlobalNamespace
);
if
(
uniqueTargets
.
Add
(
expandedNamespace
))
{
externalUsings
.
Add
(
new
NamespaceOrTypeAndUsingDirective
(
expandedNamespace
,
previousUsing
.
UsingDirective
));
}
}
}
// The previous submission should not have had extern aliases (unsupported)
// and using aliases are handled separately (during lookup) so we only need
// to extract the regular usings.
...
...
@@ -1258,7 +1238,7 @@ private ImmutableArray<NamespaceOrTypeAndUsingDirective> BindExternalUsings()
//}
//else
{
foreach
(
var
previousUsing
in
previousSubmission
.
SubmissionImports
.
Usings
)
foreach
(
var
previousUsing
in
previousSubmission
.
ExternalUsings
.
Concat
(
previousSubmission
.
SubmissionImports
.
Usings
)
)
{
var
previousTarget
=
previousUsing
.
NamespaceOrType
;
if
(
previousTarget
.
IsType
)
...
...
@@ -1324,7 +1304,7 @@ private static NamespaceSymbol ExpandPreviousSubmissionNamespace(NamespaceSymbol
/// <remarks>
/// Always consider whether usings should be considered before accessing this (e.g. not when binding other usings).
/// </remarks>
internal
Dictionary
<
string
,
AliasAndUsingDirective
>
SubmissionUsingAliases
=>
SubmissionImports
?.
UsingAliases
;
internal
Immutable
Dictionary
<
string
,
AliasAndUsingDirective
>
SubmissionUsingAliases
=>
SubmissionImports
?.
UsingAliases
;
private
Imports
SubmissionImports
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录