Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
f0ea86f3
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,发现更多精彩内容 >>
提交
f0ea86f3
编写于
11月 12, 2016
作者:
C
CyrusNajmabadi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use tuples in more cases.
上级
2814463d
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
30 addition
and
38 deletion
+30
-38
src/Workspaces/Core/Portable/FindSymbols/SyntaxTree/SyntaxTreeInfo.cs
...es/Core/Portable/FindSymbols/SyntaxTree/SyntaxTreeInfo.cs
+30
-38
未找到文件。
src/Workspaces/Core/Portable/FindSymbols/SyntaxTree/SyntaxTreeInfo.cs
浏览文件 @
f0ea86f3
...
...
@@ -71,12 +71,11 @@ await SyntaxTreeDeclarationInfo.PrecalculatedAsync(document, cancellationToken).
Document
document
,
ConditionalWeakTable
<
Document
,
T
>
cache
,
Func
<
Document
,
CancellationToken
,
Task
<
T
>>
generator
,
Func
<
ValueTuple
<
SyntaxTreeIdentifierInfo
,
SyntaxTreeContextInfo
,
SyntaxTreeDeclarationInfo
>
,
T
>
selector
,
Func
<
(
SyntaxTreeIdentifierInfo
identifierInfo
,
SyntaxTreeContextInfo
contextInfo
,
SyntaxTreeDeclarationInfo
declarationInfo
)
,
T
>
selector
,
CancellationToken
cancellationToken
)
where
T
:
class
{
T
info
;
if
(
cache
.
TryGetValue
(
document
,
out
info
))
if
(
cache
.
TryGetValue
(
document
,
out
var
info
))
{
return
info
;
}
...
...
@@ -91,9 +90,9 @@ await SyntaxTreeDeclarationInfo.PrecalculatedAsync(document, cancellationToken).
var
data
=
await
CreateInfoAsync
(
document
,
cancellationToken
).
ConfigureAwait
(
false
);
// okay, persist this info
await
data
.
Item1
.
SaveAsync
(
document
,
cancellationToken
).
ConfigureAwait
(
false
);
await
data
.
Item2
.
SaveAsync
(
document
,
cancellationToken
).
ConfigureAwait
(
false
);
await
data
.
Item3
.
SaveAsync
(
document
,
cancellationToken
).
ConfigureAwait
(
false
);
await
data
.
identifierInfo
.
SaveAsync
(
document
,
cancellationToken
).
ConfigureAwait
(
false
);
await
data
.
contextInfo
.
SaveAsync
(
document
,
cancellationToken
).
ConfigureAwait
(
false
);
await
data
.
declarationInfo
.
SaveAsync
(
document
,
cancellationToken
).
ConfigureAwait
(
false
);
info
=
selector
(
data
);
return
cache
.
GetValue
(
document
,
_
=>
info
);
...
...
@@ -111,7 +110,7 @@ public static Task<SyntaxTreeIdentifierInfo> GetIdentifierInfoAsync(Document doc
private
static
Func
<
Document
,
CancellationToken
,
Task
<
SyntaxTreeDeclarationInfo
>>
s_loadAsync
=
SyntaxTreeDeclarationInfo
.
LoadAsync
;
private
static
Func
<
ValueTuple
<
SyntaxTreeIdentifierInfo
,
SyntaxTreeContextInfo
,
SyntaxTreeDeclarationInfo
>
,
SyntaxTreeDeclarationInfo
>
s_getThirdItem
private
static
Func
<
(
SyntaxTreeIdentifierInfo
identifierInfo
,
SyntaxTreeContextInfo
contextInfo
,
SyntaxTreeDeclarationInfo
declarationInfo
)
,
SyntaxTreeDeclarationInfo
>
s_getThirdItem
=
tuple
=>
tuple
.
Item3
;
public
static
Task
<
SyntaxTreeDeclarationInfo
>
GetDeclarationInfoAsync
(
...
...
@@ -125,15 +124,13 @@ public static Task<SyntaxTreeIdentifierInfo> GetIdentifierInfoAsync(Document doc
// The probability of getting a false positive when calling ContainsIdentifier.
private
const
double
FalsePositiveProbability
=
0.0001
;
private
static
async
Task
<
ValueTuple
<
SyntaxTreeIdentifierInfo
,
SyntaxTreeContextInfo
,
SyntaxTreeDeclarationInfo
>
>
CreateInfoAsync
(
Document
document
,
CancellationToken
cancellationToken
)
private
static
async
Task
<
(
SyntaxTreeIdentifierInfo
identifierInfo
,
SyntaxTreeContextInfo
contextInfo
,
SyntaxTreeDeclarationInfo
declarationInfo
)
>
CreateInfoAsync
(
Document
document
,
CancellationToken
cancellationToken
)
{
var
syntaxFacts
=
document
.
GetLanguageService
<
ISyntaxFactsService
>();
var
ignoreCase
=
syntaxFacts
!=
null
&&
!
syntaxFacts
.
IsCaseSensitive
;
var
isCaseSensitive
=
!
ignoreCase
;
HashSet
<
string
>
identifiers
;
HashSet
<
string
>
escapedIdentifiers
;
GetIdentifierSet
(
ignoreCase
,
out
identifiers
,
out
escapedIdentifiers
);
GetIdentifierSet
(
ignoreCase
,
out
var
identifiers
,
out
var
escapedIdentifiers
);
try
{
...
...
@@ -167,7 +164,6 @@ public static Task<SyntaxTreeIdentifierInfo> GetIdentifierInfoAsync(Document doc
containsQueryExpression
=
containsQueryExpression
||
syntaxFacts
.
IsQueryExpression
(
node
);
containsElementAccess
=
containsElementAccess
||
syntaxFacts
.
IsElementAccessExpression
(
node
);
containsIndexerMemberCref
=
containsIndexerMemberCref
||
syntaxFacts
.
IsIndexerMemberCRef
(
node
);
// We've received a number of error reports where DeclaredSymbolInfo.GetSymbolAsync() will
// crash because the document's syntax root doesn't contain the span of the node returned
// by TryGetDeclaredSymbolInfo(). There are two possibilities for this crash:
...
...
@@ -178,8 +174,7 @@ public static Task<SyntaxTreeIdentifierInfo> GetIdentifierInfoAsync(Document doc
// the future then we know the problem lies in (2). If, however, the problem is really in
// TryGetDeclaredSymbolInfo, then this will at least prevent us from returning bad spans
// and will prevent the crash from occurring.
DeclaredSymbolInfo
declaredSymbolInfo
;
if
(
syntaxFacts
.
TryGetDeclaredSymbolInfo
(
node
,
out
declaredSymbolInfo
))
if
(
syntaxFacts
.
TryGetDeclaredSymbolInfo
(
node
,
out
var
declaredSymbolInfo
))
{
if
(
root
.
FullSpan
.
Contains
(
declaredSymbolInfo
.
Span
))
{
...
...
@@ -213,14 +208,12 @@ public static Task<SyntaxTreeIdentifierInfo> GetIdentifierInfoAsync(Document doc
}
}
PredefinedType
predefinedType
;
if
(
syntaxFacts
.
TryGetPredefinedType
(
token
,
out
predefinedType
))
if
(
syntaxFacts
.
TryGetPredefinedType
(
token
,
out
var
predefinedType
))
{
predefinedTypes
|=
(
int
)
predefinedType
;
}
PredefinedOperator
predefinedOperator
;
if
(
syntaxFacts
.
TryGetPredefinedOperator
(
token
,
out
predefinedOperator
))
if
(
syntaxFacts
.
TryGetPredefinedOperator
(
token
,
out
var
predefinedOperator
))
{
predefinedOperators
|=
(
int
)
predefinedOperator
;
}
...
...
@@ -230,26 +223,25 @@ public static Task<SyntaxTreeIdentifierInfo> GetIdentifierInfoAsync(Document doc
var
version
=
await
document
.
GetSyntaxVersionAsync
(
cancellationToken
).
ConfigureAwait
(
false
);
return
ValueTuple
.
Create
(
new
SyntaxTreeIdentifierInfo
(
version
,
new
BloomFilter
(
FalsePositiveProbability
,
isCaseSensitive
,
identifiers
),
new
BloomFilter
(
FalsePositiveProbability
,
isCaseSensitive
,
escapedIdentifiers
)),
new
SyntaxTreeContextInfo
(
version
,
predefinedTypes
,
predefinedOperators
,
containsForEachStatement
,
containsLockStatement
,
containsUsingStatement
,
containsQueryExpression
,
containsThisConstructorInitializer
,
containsBaseConstructorInitializer
,
containsElementAccess
,
containsIndexerMemberCref
),
new
SyntaxTreeDeclarationInfo
(
version
,
declaredSymbolInfos
));
return
(
new
SyntaxTreeIdentifierInfo
(
version
,
new
BloomFilter
(
FalsePositiveProbability
,
isCaseSensitive
,
identifiers
),
new
BloomFilter
(
FalsePositiveProbability
,
isCaseSensitive
,
escapedIdentifiers
)),
new
SyntaxTreeContextInfo
(
version
,
predefinedTypes
,
predefinedOperators
,
containsForEachStatement
,
containsLockStatement
,
containsUsingStatement
,
containsQueryExpression
,
containsThisConstructorInitializer
,
containsBaseConstructorInitializer
,
containsElementAccess
,
containsIndexerMemberCref
),
new
SyntaxTreeDeclarationInfo
(
version
,
declaredSymbolInfos
));
}
finally
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录