Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
637cb4c8
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,发现更多精彩内容 >>
未验证
提交
637cb4c8
编写于
9月 22, 2020
作者:
C
CyrusNajmabadi
提交者:
GitHub
9月 22, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #47895 from CyrusNajmabadi/nrtFAR
Add NRT annotations to FAR engine
上级
59051436
3caae714
变更
30
隐藏空白更改
内联
并排
Showing
30 changed file
with
107 addition
and
42 deletion
+107
-42
src/Workspaces/Core/Portable/FindSymbols/FindReferences/FindReferencesSearchEngine.cs
.../FindSymbols/FindReferences/FindReferencesSearchEngine.cs
+4
-2
src/Workspaces/Core/Portable/FindSymbols/FindReferences/FindReferencesSearchEngine_MapCreation.cs
.../FindReferences/FindReferencesSearchEngine_MapCreation.cs
+7
-4
src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/AbstractMemberScopedReferenceFinder.cs
...References/Finders/AbstractMemberScopedReferenceFinder.cs
+9
-7
src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/AbstractMethodOrPropertyOrEventSymbolReferenceFinder.cs
...s/AbstractMethodOrPropertyOrEventSymbolReferenceFinder.cs
+14
-5
src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/AbstractReferenceFinder_GlobalSuppressions.cs
...ces/Finders/AbstractReferenceFinder_GlobalSuppressions.cs
+1
-1
src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/ConstructorInitializerSymbolReferenceFinder.cs
...es/Finders/ConstructorInitializerSymbolReferenceFinder.cs
+3
-1
src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/DestructorSymbolReferenceFinder.cs
...FindReferences/Finders/DestructorSymbolReferenceFinder.cs
+2
-0
src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/EventSymbolReferenceFinder.cs
...bols/FindReferences/Finders/EventSymbolReferenceFinder.cs
+2
-0
src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/ExplicitInterfaceMethodReferenceFinder.cs
...erences/Finders/ExplicitInterfaceMethodReferenceFinder.cs
+2
-0
src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/FieldSymbolReferenceFinder.cs
...bols/FindReferences/Finders/FieldSymbolReferenceFinder.cs
+2
-0
src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/FinderLocation.cs
...able/FindSymbols/FindReferences/Finders/FinderLocation.cs
+2
-0
src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/ILanguageServiceReferenceFinder.cs
...FindReferences/Finders/ILanguageServiceReferenceFinder.cs
+2
-0
src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/IReferenceFinder.cs
...le/FindSymbols/FindReferences/Finders/IReferenceFinder.cs
+2
-0
src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/LabelSymbolReferenceFinder.cs
...bols/FindReferences/Finders/LabelSymbolReferenceFinder.cs
+2
-0
src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/LinkedFileReferenceFinder.cs
...mbols/FindReferences/Finders/LinkedFileReferenceFinder.cs
+3
-1
src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/LocalSymbolReferenceFinder.cs
...bols/FindReferences/Finders/LocalSymbolReferenceFinder.cs
+2
-0
src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/MethodTypeParameterSymbolReferenceFinder.cs
...ences/Finders/MethodTypeParameterSymbolReferenceFinder.cs
+3
-0
src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/NamedTypeSymbolReferenceFinder.cs
.../FindReferences/Finders/NamedTypeSymbolReferenceFinder.cs
+7
-3
src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/NamespaceSymbolReferenceFinder.cs
.../FindReferences/Finders/NamespaceSymbolReferenceFinder.cs
+5
-3
src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/OperatorSymbolReferenceFinder.cs
...s/FindReferences/Finders/OperatorSymbolReferenceFinder.cs
+3
-1
src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/OrdinaryMethodReferenceFinder.cs
...s/FindReferences/Finders/OrdinaryMethodReferenceFinder.cs
+2
-0
src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/ParameterSymbolReferenceFinder.cs
.../FindReferences/Finders/ParameterSymbolReferenceFinder.cs
+8
-6
src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/PropertyAccessorSymbolReferenceFinder.cs
...ferences/Finders/PropertyAccessorSymbolReferenceFinder.cs
+4
-2
src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/PropertySymbolReferenceFinder.cs
...s/FindReferences/Finders/PropertySymbolReferenceFinder.cs
+2
-2
src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/RangeVariableSymbolReferenceFinder.cs
...dReferences/Finders/RangeVariableSymbolReferenceFinder.cs
+2
-0
src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/ReferenceFinders.cs
...le/FindSymbols/FindReferences/Finders/ReferenceFinders.cs
+2
-0
src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/TypeParameterSymbolReferenceFinder.cs
...dReferences/Finders/TypeParameterSymbolReferenceFinder.cs
+2
-0
src/Workspaces/Core/Portable/FindSymbols/SymbolFinder_FindReferences_Current.cs
...rtable/FindSymbols/SymbolFinder_FindReferences_Current.cs
+2
-2
src/Workspaces/Core/Portable/FindSymbols/SymbolFinder_FindRenamableReferences.cs
...table/FindSymbols/SymbolFinder_FindRenamableReferences.cs
+3
-2
src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/SyntaxTokenExtensions.cs
...ensions/Compiler/Core/Extensions/SyntaxTokenExtensions.cs
+3
-0
未找到文件。
src/Workspaces/Core/Portable/FindSymbols/FindReferences/FindReferencesSearchEngine.cs
浏览文件 @
637cb4c8
...
...
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#
nullable
enable
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Immutable
;
...
...
@@ -22,7 +24,7 @@ namespace Microsoft.CodeAnalysis.FindSymbols
internal
partial
class
FindReferencesSearchEngine
{
private
readonly
Solution
_solution
;
private
readonly
IImmutableSet
<
Document
>
_documents
;
private
readonly
IImmutableSet
<
Document
>
?
_documents
;
private
readonly
ImmutableArray
<
IReferenceFinder
>
_finders
;
private
readonly
IStreamingProgressTracker
_progressTracker
;
private
readonly
IStreamingFindReferencesProgress
_progress
;
...
...
@@ -31,7 +33,7 @@ internal partial class FindReferencesSearchEngine
public
FindReferencesSearchEngine
(
Solution
solution
,
IImmutableSet
<
Document
>
documents
,
IImmutableSet
<
Document
>
?
documents
,
ImmutableArray
<
IReferenceFinder
>
finders
,
IStreamingFindReferencesProgress
progress
,
FindReferencesSearchOptions
options
,
...
...
src/Workspaces/Core/Portable/FindSymbols/FindReferences/FindReferencesSearchEngine_MapCreation.cs
浏览文件 @
637cb4c8
...
...
@@ -126,7 +126,8 @@ private async Task<ProjectMap> CreateProjectMapAsync(ConcurrentSet<ISymbol> symb
searchSymbol
=
sourceSymbol
;
}
if
(
searchSymbol
!=
null
&&
result
.
Add
(
searchSymbol
))
Contract
.
ThrowIfNull
(
searchSymbol
);
if
(
result
.
Add
(
searchSymbol
))
{
await
_progress
.
OnDefinitionFoundAsync
(
searchSymbol
).
ConfigureAwait
(
false
);
...
...
@@ -135,12 +136,12 @@ private async Task<ProjectMap> CreateProjectMapAsync(ConcurrentSet<ISymbol> symb
_cancellationToken
.
ThrowIfCancellationRequested
();
var
finderTasks
=
new
List
<
Task
>(
);
using
var
_
=
ArrayBuilder
<
Task
>.
GetInstance
(
out
var
finderTasks
);
foreach
(
var
f
in
_finders
)
{
finderTasks
.
Add
(
Task
.
Run
(
async
()
=>
{
var
symbolTasks
=
new
List
<
Task
>(
);
using
var
_
=
ArrayBuilder
<
Task
>.
GetInstance
(
out
var
symbolTasks
);
var
symbols
=
await
f
.
DetermineCascadedSymbolsAsync
(
searchSymbol
,
_solution
,
projects
,
_options
,
_cancellationToken
).
ConfigureAwait
(
false
);
...
...
@@ -169,12 +170,13 @@ private async Task<ProjectMap> CreateProjectMapAsync(ConcurrentSet<ISymbol> symb
private
void
AddSymbolTasks
(
ConcurrentSet
<
ISymbol
>
result
,
ImmutableArray
<
ISymbol
>
symbols
,
List
<
Task
>
symbolTasks
)
ArrayBuilder
<
Task
>
symbolTasks
)
{
if
(!
symbols
.
IsDefault
)
{
foreach
(
var
child
in
symbols
)
{
Contract
.
ThrowIfNull
(
child
);
_cancellationToken
.
ThrowIfCancellationRequested
();
symbolTasks
.
Add
(
Task
.
Run
(()
=>
DetermineAllSymbolsCoreAsync
(
child
,
result
),
_cancellationToken
));
}
...
...
@@ -227,6 +229,7 @@ private static ISymbol MapToAppropriateSymbol(ISymbol symbol)
searchSymbol
=
symbol
.
ContainingType
;
}
Contract
.
ThrowIfNull
(
searchSymbol
);
return
searchSymbol
;
}
}
...
...
src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/AbstractMemberScopedReferenceFinder.cs
浏览文件 @
637cb4c8
...
...
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#
nullable
enable
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Immutable
;
...
...
@@ -62,7 +64,7 @@ protected sealed override bool CanFind(TSymbol symbol)
if
(
symbol
.
ContainingType
!=
null
&&
symbol
.
ContainingType
.
IsScriptClass
)
{
var
syntaxTree
=
await
document
.
GetSyntaxTreeAsync
(
cancellationToken
).
ConfigureAwait
(
false
);
var
syntaxTree
=
await
document
.
Get
Required
SyntaxTreeAsync
(
cancellationToken
).
ConfigureAwait
(
false
);
var
syntaxFactsService
=
document
.
GetLanguageService
<
ISyntaxFactsService
>();
var
root
=
await
syntaxTree
.
GetRootAsync
(
cancellationToken
).
ConfigureAwait
(
false
);
var
tokens
=
root
.
DescendantTokens
();
...
...
@@ -74,7 +76,7 @@ protected sealed override bool CanFind(TSymbol symbol)
return
ImmutableArray
<
FinderLocation
>.
Empty
;
}
private
static
ISymbol
GetContainer
(
ISymbol
symbol
)
private
static
ISymbol
?
GetContainer
(
ISymbol
symbol
)
{
for
(
var
current
=
symbol
;
current
!=
null
;
current
=
current
.
ContainingSymbol
)
{
...
...
@@ -126,11 +128,11 @@ private static ISymbol GetContainer(ISymbol symbol)
Document
document
,
SemanticModel
semanticModel
,
IEnumerable
<
SyntaxToken
>
tokens
,
Func
<
SyntaxToken
,
SyntaxNode
>
findParentNode
,
Func
<
SyntaxToken
,
SyntaxNode
>
?
findParentNode
,
CancellationToken
cancellationToken
)
{
var
name
=
symbol
.
Name
;
var
syntaxFacts
=
document
.
GetLanguageService
<
ISyntaxFactsService
>();
var
syntaxFacts
=
document
.
Get
Required
LanguageService
<
ISyntaxFactsService
>();
var
symbolsMatch
=
GetStandardSymbolsMatchFunction
(
symbol
,
findParentNode
,
document
.
Project
.
Solution
,
cancellationToken
);
return
FindReferencesInTokensAsync
(
...
...
@@ -159,15 +161,15 @@ private static ISymbol GetContainer(ISymbol symbol)
ISymbol
container
,
Document
document
,
SemanticModel
semanticModel
,
Func
<
SyntaxToken
,
SyntaxNode
>
findParentNode
,
Func
<
SyntaxToken
,
SyntaxNode
>
?
findParentNode
,
CancellationToken
cancellationToken
)
{
var
service
=
document
.
GetLanguageService
<
ISymbolDeclarationService
>();
var
service
=
document
.
Get
Required
LanguageService
<
ISymbolDeclarationService
>();
var
declarations
=
service
.
GetDeclarations
(
container
);
var
tokens
=
declarations
.
SelectMany
(
r
=>
r
.
GetSyntax
(
cancellationToken
).
DescendantTokens
());
var
name
=
symbol
.
Name
;
var
syntaxFacts
=
document
.
GetLanguageService
<
ISyntaxFactsService
>();
var
syntaxFacts
=
document
.
Get
Required
LanguageService
<
ISyntaxFactsService
>();
var
symbolsMatch
=
GetStandardSymbolsMatchFunction
(
symbol
,
findParentNode
,
document
.
Project
.
Solution
,
cancellationToken
);
var
tokensMatch
=
GetTokensMatchFunction
(
syntaxFacts
,
name
);
...
...
src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/AbstractMethodOrPropertyOrEventSymbolReferenceFinder.cs
浏览文件 @
637cb4c8
...
...
@@ -2,10 +2,13 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#
nullable
enable
using
System.Collections.Immutable
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
Microsoft.CodeAnalysis.LanguageServices
;
using
Microsoft.CodeAnalysis.PooledObjects
;
using
Microsoft.CodeAnalysis.Shared.Extensions
;
namespace
Microsoft.CodeAnalysis.FindSymbols.Finders
...
...
@@ -69,16 +72,22 @@ protected AbstractMethodOrPropertyOrEventSymbolReferenceFinder()
// the only accessor method referenced in a foreach-statement is the .Current's
// get-accessor
return
ImmutableArray
.
Create
(
symbols
.
CurrentProperty
.
GetMethod
);
return
symbols
.
CurrentProperty
.
GetMethod
==
null
?
ImmutableArray
<
IMethodSymbol
>.
Empty
:
ImmutableArray
.
Create
(
symbols
.
CurrentProperty
.
GetMethod
);
}
if
(
semanticFacts
.
IsWrittenTo
(
model
,
node
,
cancellationToken
))
{
// if it was only written to, then only the setter was referenced.
// if it was written *and* read, then both accessors were referenced.
return
semanticFacts
.
IsOnlyWrittenTo
(
model
,
node
,
cancellationToken
)
?
ImmutableArray
.
Create
(
property
.
SetMethod
)
:
ImmutableArray
.
Create
(
property
.
GetMethod
,
property
.
SetMethod
);
using
var
_
=
ArrayBuilder
<
IMethodSymbol
>.
GetInstance
(
out
var
result
);
result
.
AddIfNotNull
(
property
.
SetMethod
);
if
(!
semanticFacts
.
IsOnlyWrittenTo
(
model
,
node
,
cancellationToken
))
result
.
AddIfNotNull
(
property
.
GetMethod
);
return
result
.
ToImmutable
();
}
else
{
...
...
@@ -93,7 +102,7 @@ protected AbstractMethodOrPropertyOrEventSymbolReferenceFinder()
var
inNameOf
=
semanticFacts
.
IsInsideNameOfExpression
(
model
,
node
,
cancellationToken
);
var
inStructuredTrivia
=
node
.
IsPartOfStructuredTrivia
();
return
inNameOf
||
inStructuredTrivia
return
inNameOf
||
inStructuredTrivia
||
property
.
GetMethod
==
null
?
ImmutableArray
<
IMethodSymbol
>.
Empty
:
ImmutableArray
.
Create
(
property
.
GetMethod
);
}
...
...
src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/AbstractReferenceFinder_GlobalSuppressions.cs
浏览文件 @
637cb4c8
...
...
@@ -105,7 +105,7 @@ static bool SupportsGlobalSuppression(ISymbol symbol)
if
(
IsCandidate
(
token
,
expectedDocCommentId
,
semanticModel
,
syntaxFacts
,
suppressMessageAttribute
,
cancellationToken
,
out
var
offsetOfReferenceInToken
))
{
var
referenceLocation
=
CreateReferenceLocation
(
offsetOfReferenceInToken
,
token
,
root
,
document
,
syntaxFacts
);
locations
.
Add
(
new
FinderLocation
(
token
.
Parent
,
referenceLocation
));
locations
.
Add
(
new
FinderLocation
(
token
.
GetRequiredParent
()
,
referenceLocation
));
}
}
...
...
src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/ConstructorInitializerSymbolReferenceFinder.cs
浏览文件 @
637cb4c8
...
...
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#
nullable
enable
using
System.Collections.Immutable
;
using
System.Linq
;
using
System.Threading
;
...
...
@@ -56,7 +58,7 @@ protected override bool CanFind(IMethodSymbol symbol)
FindReferencesSearchOptions
options
,
CancellationToken
cancellationToken
)
{
var
syntaxFactsService
=
document
.
GetLanguageService
<
ISyntaxFactsService
>();
var
syntaxFactsService
=
document
.
Get
Required
LanguageService
<
ISyntaxFactsService
>();
var
typeName
=
methodSymbol
.
ContainingType
.
Name
;
var
tokens
=
await
document
.
GetConstructorInitializerTokensAsync
(
semanticModel
,
cancellationToken
).
ConfigureAwait
(
false
);
...
...
src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/DestructorSymbolReferenceFinder.cs
浏览文件 @
637cb4c8
...
...
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#
nullable
enable
using
System.Collections.Immutable
;
using
System.Threading
;
using
System.Threading.Tasks
;
...
...
src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/EventSymbolReferenceFinder.cs
浏览文件 @
637cb4c8
...
...
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#
nullable
enable
using
System.Collections.Immutable
;
using
System.Linq
;
using
System.Threading
;
...
...
src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/ExplicitInterfaceMethodReferenceFinder.cs
浏览文件 @
637cb4c8
...
...
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#
nullable
enable
using
System.Collections.Immutable
;
using
System.Threading
;
using
System.Threading.Tasks
;
...
...
src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/FieldSymbolReferenceFinder.cs
浏览文件 @
637cb4c8
...
...
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#
nullable
enable
using
System.Collections.Immutable
;
using
System.Threading
;
using
System.Threading.Tasks
;
...
...
src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/FinderLocation.cs
浏览文件 @
637cb4c8
...
...
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#
nullable
enable
namespace
Microsoft.CodeAnalysis.FindSymbols.Finders
{
internal
readonly
struct
FinderLocation
...
...
src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/ILanguageServiceReferenceFinder.cs
浏览文件 @
637cb4c8
...
...
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#
nullable
enable
using
System.Collections.Immutable
;
using
System.Threading
;
using
System.Threading.Tasks
;
...
...
src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/IReferenceFinder.cs
浏览文件 @
637cb4c8
...
...
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#
nullable
enable
using
System.Collections.Immutable
;
using
System.Threading
;
using
System.Threading.Tasks
;
...
...
src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/LabelSymbolReferenceFinder.cs
浏览文件 @
637cb4c8
...
...
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#
nullable
enable
using
System
;
using
Microsoft.CodeAnalysis.LanguageServices
;
...
...
src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/LinkedFileReferenceFinder.cs
浏览文件 @
637cb4c8
...
...
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#
nullable
enable
using
System.Collections.Immutable
;
using
System.Threading
;
using
System.Threading.Tasks
;
...
...
@@ -25,7 +27,7 @@ internal class LinkedFileReferenceFinder : IReferenceFinder
return
SpecializedTasks
.
EmptyImmutableArray
<
Document
>();
}
public
Task
<
ImmutableArray
<
Project
>>
DetermineProjectsToSearchAsync
(
ISymbol
symbol
,
Solution
solution
,
IImmutableSet
<
Project
>
projects
=
null
,
CancellationToken
cancellationToken
=
default
)
public
Task
<
ImmutableArray
<
Project
>>
DetermineProjectsToSearchAsync
(
ISymbol
symbol
,
Solution
solution
,
IImmutableSet
<
Project
>
?
projects
=
null
,
CancellationToken
cancellationToken
=
default
)
=>
SpecializedTasks
.
EmptyImmutableArray
<
Project
>();
public
Task
<
ImmutableArray
<
FinderLocation
>>
FindReferencesInDocumentAsync
(
...
...
src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/LocalSymbolReferenceFinder.cs
浏览文件 @
637cb4c8
...
...
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#
nullable
enable
using
System
;
using
Microsoft.CodeAnalysis.LanguageServices
;
...
...
src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/MethodTypeParameterSymbolReferenceFinder.cs
浏览文件 @
637cb4c8
...
...
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#
nullable
enable
using
System.Collections.Immutable
;
using
System.Threading
;
using
System.Threading.Tasks
;
...
...
@@ -59,6 +61,7 @@ protected override bool CanFind(ITypeParameterSymbol symbol)
//
// Also, we only look for files that have the name of the owning type. This helps filter
// down the set considerably.
Contract
.
ThrowIfNull
(
symbol
.
DeclaringMethod
);
return
FindDocumentsAsync
(
project
,
documents
,
findInGlobalSuppressions
:
false
,
cancellationToken
,
symbol
.
Name
,
GetMemberNameWithoutInterfaceName
(
symbol
.
DeclaringMethod
.
Name
),
symbol
.
DeclaringMethod
.
ContainingType
.
Name
);
...
...
src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/NamedTypeSymbolReferenceFinder.cs
浏览文件 @
637cb4c8
...
...
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#
nullable
enable
using
System.Collections.Immutable
;
using
System.Linq
;
using
System.Threading
;
...
...
@@ -53,9 +55,11 @@ protected override bool CanFind(INamedTypeSymbol symbol)
FindReferencesSearchOptions
options
,
CancellationToken
cancellationToken
)
{
var
syntaxFacts
=
project
.
LanguageServices
.
GetRequiredService
<
ISyntaxFactsService
>();
var
documentsWithName
=
await
FindDocumentsAsync
(
project
,
documents
,
findInGlobalSuppressions
:
true
,
cancellationToken
,
symbol
.
Name
).
ConfigureAwait
(
false
);
var
documentsWithType
=
await
FindDocumentsAsync
(
project
,
documents
,
symbol
.
SpecialType
.
ToPredefinedType
(),
cancellationToken
).
ConfigureAwait
(
false
);
var
documentsWithAttribute
=
TryGetNameWithoutAttributeSuffix
(
symbol
.
Name
,
project
.
LanguageServices
.
GetService
<
ISyntaxFactsService
>()
,
out
var
simpleName
)
var
documentsWithAttribute
=
TryGetNameWithoutAttributeSuffix
(
symbol
.
Name
,
syntaxFacts
,
out
var
simpleName
)
?
await
FindDocumentsAsync
(
project
,
documents
,
findInGlobalSuppressions
:
false
,
cancellationToken
,
simpleName
).
ConfigureAwait
(
false
)
:
ImmutableArray
<
Document
>.
Empty
;
...
...
@@ -127,7 +131,7 @@ protected override bool CanFind(INamedTypeSymbol symbol)
return
SpecializedTasks
.
EmptyImmutableArray
<
FinderLocation
>();
}
var
syntaxFacts
=
document
.
GetLanguageService
<
ISyntaxFactsService
>();
var
syntaxFacts
=
document
.
Get
Required
LanguageService
<
ISyntaxFactsService
>();
return
FindReferencesInDocumentAsync
(
document
,
semanticModel
,
t
=>
IsPotentialReference
(
predefinedType
,
syntaxFacts
,
t
),
(
t
,
m
)
=>
new
ValueTask
<(
bool
matched
,
CandidateReason
reason
)>((
matched
:
true
,
reason
:
CandidateReason
.
None
)),
...
...
@@ -143,7 +147,7 @@ protected override bool CanFind(INamedTypeSymbol symbol)
CancellationToken
cancellationToken
)
{
var
symbolsMatch
=
GetStandardSymbolsMatchFunction
(
namedType
,
null
,
document
.
Project
.
Solution
,
cancellationToken
);
var
syntaxFacts
=
document
.
GetLanguageService
<
ISyntaxFactsService
>();
var
syntaxFacts
=
document
.
Get
Required
LanguageService
<
ISyntaxFactsService
>();
return
TryGetNameWithoutAttributeSuffix
(
namedType
.
Name
,
syntaxFacts
,
out
var
simpleName
)
?
FindReferencesInDocumentUsingIdentifierAsync
(
simpleName
,
document
,
semanticModel
,
symbolsMatch
,
docCommentId
:
null
,
findInGlobalSuppressions
:
false
,
cancellationToken
)
...
...
src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/NamespaceSymbolReferenceFinder.cs
浏览文件 @
637cb4c8
...
...
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#
nullable
enable
using
System.Collections.Immutable
;
using
System.Threading
;
using
System.Threading.Tasks
;
...
...
@@ -42,7 +44,7 @@ private static string GetNamespaceIdentifierName(INamespaceSymbol symbol)
CancellationToken
cancellationToken
)
{
var
identifierName
=
GetNamespaceIdentifierName
(
symbol
);
var
syntaxFacts
Service
=
document
.
Get
LanguageService
<
ISyntaxFactsService
>();
var
syntaxFacts
=
document
.
GetRequired
LanguageService
<
ISyntaxFactsService
>();
var
tokens
=
await
GetIdentifierOrGlobalNamespaceTokensWithTextAsync
(
document
,
semanticModel
,
identifierName
,
cancellationToken
).
ConfigureAwait
(
false
);
...
...
@@ -50,14 +52,14 @@ private static string GetNamespaceIdentifierName(INamespaceSymbol symbol)
document
,
semanticModel
,
tokens
,
t
=>
syntaxFacts
Service
.
TextMatch
(
t
.
ValueText
,
identifierName
),
t
=>
syntaxFacts
.
TextMatch
(
t
.
ValueText
,
identifierName
),
cancellationToken
).
ConfigureAwait
(
false
);
var
aliasReferences
=
await
FindAliasReferencesAsync
(
nonAliasReferences
,
symbol
,
document
,
semanticModel
,
cancellationToken
).
ConfigureAwait
(
false
);
var
suppressionReferences
=
ShouldFindReferencesInGlobalSuppressions
(
symbol
,
out
var
docCommentId
)
?
await
FindReferencesInDocumentInsideGlobalSuppressionsAsync
(
document
,
semanticModel
,
syntaxFacts
Service
,
docCommentId
,
cancellationToken
).
ConfigureAwait
(
false
)
syntaxFacts
,
docCommentId
,
cancellationToken
).
ConfigureAwait
(
false
)
:
ImmutableArray
<
FinderLocation
>.
Empty
;
return
nonAliasReferences
.
Concat
(
aliasReferences
).
Concat
(
suppressionReferences
);
...
...
src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/OperatorSymbolReferenceFinder.cs
浏览文件 @
637cb4c8
...
...
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#
nullable
enable
using
System.Collections.Immutable
;
using
System.Threading
;
using
System.Threading.Tasks
;
...
...
@@ -33,7 +35,7 @@ protected override bool CanFind(IMethodSymbol symbol)
FindReferencesSearchOptions
options
,
CancellationToken
cancellationToken
)
{
var
syntaxFacts
=
document
.
GetLanguageService
<
ISyntaxFactsService
>();
var
syntaxFacts
=
document
.
Get
Required
LanguageService
<
ISyntaxFactsService
>();
var
op
=
symbol
.
GetPredefinedOperator
();
return
FindReferencesInDocumentAsync
(
symbol
,
document
,
semanticModel
,
t
=>
...
...
src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/OrdinaryMethodReferenceFinder.cs
浏览文件 @
637cb4c8
...
...
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#
nullable
enable
using
System.Collections.Immutable
;
using
System.Threading
;
using
System.Threading.Tasks
;
...
...
src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/ParameterSymbolReferenceFinder.cs
浏览文件 @
637cb4c8
...
...
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#
nullable
enable
using
System
;
using
System.Collections.Immutable
;
using
System.Linq
;
...
...
@@ -131,18 +133,18 @@ protected override bool CanFind(IParameterSymbol symbol)
var
document
=
solution
.
GetDocument
(
parameterNode
.
SyntaxTree
);
if
(
document
!=
null
)
{
var
semanticFacts
=
document
.
GetLanguageService
<
ISemanticFactsService
>();
var
semanticFacts
=
document
.
Get
Required
LanguageService
<
ISemanticFactsService
>();
if
(
semanticFacts
.
ExposesAnonymousFunctionParameterNames
)
{
var
semanticModel
=
await
document
.
GetSemanticModelAsync
(
cancellationToken
).
ConfigureAwait
(
false
);
var
semanticModel
=
await
document
.
Get
Required
SemanticModelAsync
(
cancellationToken
).
ConfigureAwait
(
false
);
var
lambdaNode
=
parameter
.
ContainingSymbol
.
DeclaringSyntaxReferences
.
Select
(
r
=>
r
.
GetSyntax
(
cancellationToken
)).
FirstOrDefault
();
var
convertedType
=
semanticModel
.
GetTypeInfo
(
lambdaNode
,
cancellationToken
).
ConvertedType
;
if
(
convertedType
!=
null
)
{
var
syntaxFacts
Service
=
document
.
Get
LanguageService
<
ISyntaxFactsService
>();
var
container
=
GetContainer
(
semanticModel
,
parameterNode
,
syntaxFacts
Service
);
var
syntaxFacts
=
document
.
GetRequired
LanguageService
<
ISyntaxFactsService
>();
var
container
=
GetContainer
(
semanticModel
,
parameterNode
,
syntaxFacts
);
if
(
container
!=
null
)
{
CascadeBetweenAnonymousFunctionParameters
(
...
...
@@ -165,12 +167,12 @@ protected override bool CanFind(IParameterSymbol symbol)
ArrayBuilder
<
ISymbol
>
results
,
CancellationToken
cancellationToken
)
{
var
syntaxFacts
=
document
.
GetLanguageService
<
ISyntaxFactsService
>();
var
syntaxFacts
=
document
.
Get
Required
LanguageService
<
ISyntaxFactsService
>();
foreach
(
var
token
in
container
.
DescendantTokens
())
{
if
(
IdentifiersMatch
(
syntaxFacts
,
parameter
.
Name
,
token
))
{
var
symbol
=
semanticModel
.
GetDeclaredSymbol
(
token
.
Parent
,
cancellationToken
);
var
symbol
=
semanticModel
.
GetDeclaredSymbol
(
token
.
GetRequiredParent
()
,
cancellationToken
);
if
(
symbol
is
IParameterSymbol
&&
symbol
.
ContainingSymbol
.
IsAnonymousFunction
()
&&
SignatureComparer
.
Instance
.
HaveSameSignatureAndConstraintsAndReturnTypeAndAccessors
(
parameter
.
ContainingSymbol
,
symbol
.
ContainingSymbol
,
syntaxFacts
.
IsCaseSensitive
)
&&
...
...
src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/PropertyAccessorSymbolReferenceFinder.cs
浏览文件 @
637cb4c8
...
...
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#
nullable
enable
using
System.Collections.Immutable
;
using
System.Threading
;
using
System.Threading.Tasks
;
...
...
@@ -80,8 +82,8 @@ protected override bool CanFind(IMethodSymbol symbol)
options
.
WithAssociatePropertyReferencesWithSpecificAccessor
(
false
),
cancellationToken
).
ConfigureAwait
(
false
);
var
syntaxFacts
=
document
.
GetLanguageService
<
ISyntaxFactsService
>();
var
semanticFacts
=
document
.
GetLanguageService
<
ISemanticFactsService
>();
var
syntaxFacts
=
document
.
Get
Required
LanguageService
<
ISyntaxFactsService
>();
var
semanticFacts
=
document
.
Get
Required
LanguageService
<
ISemanticFactsService
>();
var
accessorReferences
=
propertyReferences
.
WhereAsArray
(
loc
=>
...
...
src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/PropertySymbolReferenceFinder.cs
浏览文件 @
637cb4c8
...
...
@@ -95,8 +95,8 @@ private static bool IsForEachProperty(IPropertySymbol symbol)
// We want to associate property references to a specific accessor (if an accessor
// is being referenced). Check if this reference would match an accessor. If so, do
// not add it. It will be added by PropertyAccessorSymbolReferenceFinder.
var
syntaxFacts
=
document
.
GetLanguageService
<
ISyntaxFactsService
>();
var
semanticFacts
=
document
.
GetLanguageService
<
ISemanticFactsService
>();
var
syntaxFacts
=
document
.
Get
Required
LanguageService
<
ISyntaxFactsService
>();
var
semanticFacts
=
document
.
Get
Required
LanguageService
<
ISemanticFactsService
>();
nameReferences
=
nameReferences
.
WhereAsArray
(
loc
=>
{
...
...
src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/RangeVariableSymbolReferenceFinder.cs
浏览文件 @
637cb4c8
...
...
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#
nullable
enable
using
System
;
using
Microsoft.CodeAnalysis.LanguageServices
;
...
...
src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/ReferenceFinders.cs
浏览文件 @
637cb4c8
...
...
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#
nullable
enable
using
System.Collections.Immutable
;
namespace
Microsoft.CodeAnalysis.FindSymbols.Finders
...
...
src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/TypeParameterSymbolReferenceFinder.cs
浏览文件 @
637cb4c8
...
...
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#
nullable
enable
using
System.Collections.Immutable
;
using
System.Threading
;
using
System.Threading.Tasks
;
...
...
src/Workspaces/Core/Portable/FindSymbols/SymbolFinder_FindReferences_Current.cs
浏览文件 @
637cb4c8
...
...
@@ -58,7 +58,7 @@ public static partial class SymbolFinder
}
internal
static
Task
FindReferencesInCurrentProcessAsync
(
ISymbol
symbol
AndProjectId
,
ISymbol
symbol
,
Solution
solution
,
IStreamingFindReferencesProgress
progress
,
IImmutableSet
<
Document
>
documents
,
...
...
@@ -69,7 +69,7 @@ public static partial class SymbolFinder
progress
??=
NoOpStreamingFindReferencesProgress
.
Instance
;
var
engine
=
new
FindReferencesSearchEngine
(
solution
,
documents
,
finders
,
progress
,
options
,
cancellationToken
);
return
engine
.
FindReferencesAsync
(
symbol
AndProjectId
);
return
engine
.
FindReferencesAsync
(
symbol
);
}
}
}
src/Workspaces/Core/Portable/FindSymbols/SymbolFinder_FindRenamableReferences.cs
浏览文件 @
637cb4c8
...
...
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#
nullable
enable
using
System.Collections.Immutable
;
using
System.Threading
;
using
System.Threading.Tasks
;
...
...
@@ -21,10 +23,9 @@ public static partial class SymbolFinder
{
var
streamingProgress
=
new
StreamingProgressCollector
();
IImmutableSet
<
Document
>
documents
=
null
;
var
engine
=
new
FindReferencesSearchEngine
(
solution
,
documents
,
documents
:
null
,
ReferenceFinders
.
DefaultRenameReferenceFinders
,
streamingProgress
,
FindReferencesSearchOptions
.
Default
,
...
...
src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Extensions/SyntaxTokenExtensions.cs
浏览文件 @
637cb4c8
...
...
@@ -159,5 +159,8 @@ public static SyntaxToken With(this SyntaxToken token, SyntaxTriviaList leading,
public
static
SyntaxTrivia
[]
GetTrivia
(
this
IEnumerable
<
SyntaxToken
>
tokens
)
=>
tokens
.
SelectMany
(
token
=>
SyntaxNodeOrTokenExtensions
.
GetTrivia
(
token
)).
ToArray
();
public
static
SyntaxNode
GetRequiredParent
(
this
SyntaxToken
token
)
=>
token
.
Parent
??
throw
new
InvalidOperationException
(
"Token's parent was null"
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录