Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
b94c6fb8
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,发现更多精彩内容 >>
提交
b94c6fb8
编写于
3月 18, 2020
作者:
C
Cyrus Najmabadi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add the external reference concept
上级
0a220a62
变更
17
隐藏空白更改
内联
并排
Showing
17 changed file
with
405 addition
and
88 deletion
+405
-88
src/EditorFeatures/CSharp/FindUsages/CSharpFindUsagesService.cs
...itorFeatures/CSharp/FindUsages/CSharpFindUsagesService.cs
+7
-2
src/EditorFeatures/Core/FindUsages/AbstractFindUsagesService.CodeIndex.cs
...es/Core/FindUsages/AbstractFindUsagesService.CodeIndex.cs
+126
-0
src/EditorFeatures/Core/FindUsages/AbstractFindUsagesService.DefinitionTrackingContext.cs
...es/AbstractFindUsagesService.DefinitionTrackingContext.cs
+3
-0
src/EditorFeatures/Core/FindUsages/AbstractFindUsagesService.cs
...itorFeatures/Core/FindUsages/AbstractFindUsagesService.cs
+11
-34
src/EditorFeatures/Core/FindUsages/AggregateFindUsagesContext.cs
...torFeatures/Core/FindUsages/AggregateFindUsagesContext.cs
+125
-0
src/EditorFeatures/Core/FindUsages/FindUsagesContext.cs
src/EditorFeatures/Core/FindUsages/FindUsagesContext.cs
+2
-2
src/EditorFeatures/Core/FindUsages/FindUsagesHelpers.cs
src/EditorFeatures/Core/FindUsages/FindUsagesHelpers.cs
+38
-0
src/EditorFeatures/Core/FindUsages/IDefinitionsAndReferencesFactory.cs
...tures/Core/FindUsages/IDefinitionsAndReferencesFactory.cs
+4
-34
src/EditorFeatures/Core/FindUsages/IFindUsagesContext.cs
src/EditorFeatures/Core/FindUsages/IFindUsagesContext.cs
+1
-0
src/EditorFeatures/Core/Host/IStreamingFindReferencesPresenter.cs
...orFeatures/Core/Host/IStreamingFindReferencesPresenter.cs
+0
-1
src/EditorFeatures/VisualBasic/FindUsages/VisualBasicFindUsagesService.vb
...es/VisualBasic/FindUsages/VisualBasicFindUsagesService.vb
+4
-2
src/Features/Core/Portable/FindUsages/ExternalReferenceItem.cs
...eatures/Core/Portable/FindUsages/ExternalReferenceItem.cs
+43
-0
src/Tools/ExternalAccess/Debugger/DebuggerFindReferencesService.cs
.../ExternalAccess/Debugger/DebuggerFindReferencesService.cs
+3
-1
src/VisualStudio/Core/Def/Implementation/FindReferences/Contexts/AbstractTableDataSourceFindUsagesContext.cs
...nces/Contexts/AbstractTableDataSourceFindUsagesContext.cs
+11
-9
src/VisualStudio/Core/Def/Implementation/FindReferences/Contexts/WithReferencesFindUsagesContext.cs
...indReferences/Contexts/WithReferencesFindUsagesContext.cs
+15
-0
src/VisualStudio/Core/Def/Implementation/FindReferences/Contexts/WithoutReferencesFindUsagesContext.cs
...References/Contexts/WithoutReferencesFindUsagesContext.cs
+4
-0
src/VisualStudio/Core/Def/Implementation/Library/ObjectBrowser/AbstractObjectBrowserLibraryManager.cs
...rary/ObjectBrowser/AbstractObjectBrowserLibraryManager.cs
+8
-3
未找到文件。
src/EditorFeatures/CSharp/FindUsages/CSharpFindUsagesService.cs
浏览文件 @
b94c6fb8
...
@@ -2,11 +2,14 @@
...
@@ -2,11 +2,14 @@
// The .NET Foundation licenses this file to you under the MIT license.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
// See the LICENSE file in the project root for more information.
#
nullable
enable
using
System
;
using
System
;
using
System.Composition
;
using
System.Composition
;
using
Microsoft.CodeAnalysis.Editor.FindUsages
;
using
Microsoft.CodeAnalysis.Editor.FindUsages
;
using
Microsoft.CodeAnalysis.Editor.Shared.Utilities
;
using
Microsoft.CodeAnalysis.Editor.Shared.Utilities
;
using
Microsoft.CodeAnalysis.Host.Mef
;
using
Microsoft.CodeAnalysis.Host.Mef
;
using
VS.IntelliNav.Contracts
;
namespace
Microsoft.CodeAnalysis.Editor.CSharp.FindUsages
namespace
Microsoft.CodeAnalysis.Editor.CSharp.FindUsages
{
{
...
@@ -15,8 +18,10 @@ internal class CSharpFindUsagesService : AbstractFindUsagesService
...
@@ -15,8 +18,10 @@ internal class CSharpFindUsagesService : AbstractFindUsagesService
{
{
[
ImportingConstructor
]
[
ImportingConstructor
]
[
Obsolete
(
MefConstruction
.
ImportingConstructorMessage
,
error
:
true
)]
[
Obsolete
(
MefConstruction
.
ImportingConstructorMessage
,
error
:
true
)]
public
CSharpFindUsagesService
(
IThreadingContext
threadingContext
)
public
CSharpFindUsagesService
(
:
base
(
threadingContext
)
IThreadingContext
threadingContext
,
[
Import
(
AllowDefault
=
true
)]
ICodeIndexProvider
?
codeIndexProvider
)
:
base
(
threadingContext
,
codeIndexProvider
)
{
{
}
}
}
}
...
...
src/EditorFeatures/Core/FindUsages/AbstractFindUsagesService.CodeIndex.cs
0 → 100644
浏览文件 @
b94c6fb8
// Licensed to the .NET Foundation under one or more agreements.
// 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
;
using
System.Linq
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
Microsoft.CodeAnalysis.Editor.Shared.Utilities
;
using
Microsoft.CodeAnalysis.FindSymbols
;
using
Microsoft.CodeAnalysis.FindUsages
;
using
Microsoft.CodeAnalysis.LanguageServices
;
using
Microsoft.CodeAnalysis.Shared.Extensions
;
using
Microsoft.CodeAnalysis.Shared.Utilities
;
using
Microsoft.CodeAnalysis.SymbolMonikers
;
using
Roslyn.Utilities
;
using
VS.IntelliNav.Contracts
;
namespace
Microsoft.CodeAnalysis.Editor.FindUsages
{
using
static
FindUsagesHelpers
;
internal
abstract
partial
class
AbstractFindUsagesService
{
private
static
async
Task
FindCodeIndexReferencesAsync
(
ICodeIndexProvider
?
codeIndexProvider
,
ISymbol
definition
,
IFindUsagesContext
context
,
CancellationToken
cancellationToken
)
{
if
(
codeIndexProvider
==
null
)
return
;
var
moniker
=
SymbolMoniker
.
TryCreate
(
definition
);
if
(
moniker
==
null
)
return
;
var
progress
=
new
StreamingProgressTracker
(
context
.
ReportProgressAsync
);
try
{
await
progress
.
AddItemsAsync
(
1
).
ConfigureAwait
(
false
);
// TODO: loc this
var
displayParts
=
GetDisplayParts
(
definition
).
Add
(
new
TaggedText
(
TextTags
.
Text
,
" - (external)"
));
var
definitionItem
=
DefinitionItem
.
CreateNonNavigableItem
(
GlyphTags
.
GetTags
(
definition
.
GetGlyph
()),
displayParts
,
originationParts
:
ImmutableArray
.
Create
(
new
TaggedText
(
TextTags
.
Text
,
"external"
)));
var
monikers
=
SpecializedCollections
.
SingletonEnumerable
(
moniker
);
var
currentPage
=
0
;
while
(
true
)
{
var
keepGoing
=
await
FindCodeIndexReferencesAsync
(
codeIndexProvider
,
monikers
,
context
,
progress
,
definitionItem
,
currentPage
,
cancellationToken
).
ConfigureAwait
(
false
);
if
(!
keepGoing
)
break
;
}
}
finally
{
await
progress
.
ItemCompletedAsync
().
ConfigureAwait
(
false
);
}
}
/// <summary>
/// Returns <c>false</c> when it's time to stop searching.
/// </summary>
private
static
async
Task
<
bool
>
FindCodeIndexReferencesAsync
(
ICodeIndexProvider
codeIndexProvider
,
IEnumerable
<
ISymbolMoniker
>
monikers
,
IFindUsagesContext
context
,
IStreamingProgressTracker
progress
,
DefinitionItem
definitionItem
,
int
currentPage
,
CancellationToken
cancellationToken
)
{
try
{
await
progress
.
AddItemsAsync
(
1
).
ConfigureAwait
(
false
);
var
results
=
await
codeIndexProvider
.
FindReferencesByMonikerAsync
(
monikers
,
includeDecleration
:
true
,
pageIndex
:
currentPage
,
cancellationToken
:
cancellationToken
).
ConfigureAwait
(
false
);
if
(
results
==
null
||
results
.
Count
==
0
)
return
false
;
if
(
currentPage
==
0
)
{
// found some results. Add the definition item to the context.
await
context
.
OnDefinitionFoundAsync
(
definitionItem
).
ConfigureAwait
(
false
);
}
currentPage
++;
await
ProcessCodeIndexResultsAsync
(
codeIndexProvider
,
context
,
definitionItem
,
results
,
cancellationToken
).
ConfigureAwait
(
false
);
return
true
;
}
finally
{
await
progress
.
ItemCompletedAsync
().
ConfigureAwait
(
false
);
}
}
private
static
async
Task
ProcessCodeIndexResultsAsync
(
ICodeIndexProvider
codeIndexProvider
,
IFindUsagesContext
context
,
DefinitionItem
definitionItem
,
ICollection
<
string
>
results
,
CancellationToken
cancellationToken
)
{
foreach
(
var
result
in
results
)
{
var
referenceItem
=
new
ExternalReferenceItem
(
definitionItem
,
null
,
null
,
null
,
null
);
await
context
.
OnExternalReferenceFoundAsync
(
referenceItem
).
ConfigureAwait
(
false
);
}
}
}
}
src/EditorFeatures/Core/FindUsages/AbstractFindUsagesService.DefinitionTrackingContext.cs
浏览文件 @
b94c6fb8
...
@@ -43,6 +43,9 @@ public Task SetSearchTitleAsync(string title)
...
@@ -43,6 +43,9 @@ public Task SetSearchTitleAsync(string title)
public
Task
OnReferenceFoundAsync
(
SourceReferenceItem
reference
)
public
Task
OnReferenceFoundAsync
(
SourceReferenceItem
reference
)
=>
_underlyingContext
.
OnReferenceFoundAsync
(
reference
);
=>
_underlyingContext
.
OnReferenceFoundAsync
(
reference
);
public
Task
OnExternalReferenceFoundAsync
(
ExternalReferenceItem
reference
)
=>
_underlyingContext
.
OnExternalReferenceFoundAsync
(
reference
);
public
Task
ReportProgressAsync
(
int
current
,
int
maximum
)
public
Task
ReportProgressAsync
(
int
current
,
int
maximum
)
=>
_underlyingContext
.
ReportProgressAsync
(
current
,
maximum
);
=>
_underlyingContext
.
ReportProgressAsync
(
current
,
maximum
);
...
...
src/EditorFeatures/Core/FindUsages/AbstractFindUsagesService.cs
浏览文件 @
b94c6fb8
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
using
Microsoft.CodeAnalysis.FindUsages
;
using
Microsoft.CodeAnalysis.FindUsages
;
using
Microsoft.CodeAnalysis.LanguageServices
;
using
Microsoft.CodeAnalysis.LanguageServices
;
using
Microsoft.CodeAnalysis.Shared.Extensions
;
using
Microsoft.CodeAnalysis.Shared.Extensions
;
using
Microsoft.CodeAnalysis.Shared.Utilities
;
using
Microsoft.CodeAnalysis.SymbolMonikers
;
using
Microsoft.CodeAnalysis.SymbolMonikers
;
using
Roslyn.Utilities
;
using
Roslyn.Utilities
;
using
VS.IntelliNav.Contracts
;
using
VS.IntelliNav.Contracts
;
...
@@ -153,7 +154,14 @@ internal abstract partial class AbstractFindUsagesService : IFindUsagesService
...
@@ -153,7 +154,14 @@ internal abstract partial class AbstractFindUsagesService : IFindUsagesService
FindUsagesHelpers
.
GetDisplayName
(
symbol
))).
ConfigureAwait
(
false
);
FindUsagesHelpers
.
GetDisplayName
(
symbol
))).
ConfigureAwait
(
false
);
var
options
=
FindReferencesSearchOptions
.
GetFeatureOptionsForStartingSymbol
(
symbol
);
var
options
=
FindReferencesSearchOptions
.
GetFeatureOptionsForStartingSymbol
(
symbol
);
var
progressAdapter
=
new
FindReferencesProgressAdapter
(
threadingContext
,
project
.
Solution
,
context
,
options
);
// We're doing to kick off two find-references here. One that roslyn performs, and one
// that goes through rich-nav. In order for things like progress to work, we have each
// subsystem call into their context object. These then get aggregated and passed along
// to the real context object.
var
aggregator
=
new
FindUsagesContextAggregator
(
context
);
var
roslynFindUsagesContext
=
aggregator
.
CreateForwardingContext
();
var
codeIndexFindUsagesContext
=
aggregator
.
CreateForwardingContext
();
// Now call into the underlying FAR engine to find reference. The FAR
// Now call into the underlying FAR engine to find reference. The FAR
// engine will push results into the 'progress' instance passed into it.
// engine will push results into the 'progress' instance passed into it.
...
@@ -162,7 +170,7 @@ internal abstract partial class AbstractFindUsagesService : IFindUsagesService
...
@@ -162,7 +170,7 @@ internal abstract partial class AbstractFindUsagesService : IFindUsagesService
var
normalFindReferencesTask
=
SymbolFinder
.
FindReferencesAsync
(
var
normalFindReferencesTask
=
SymbolFinder
.
FindReferencesAsync
(
SymbolAndProjectId
.
Create
(
symbol
,
project
.
Id
),
SymbolAndProjectId
.
Create
(
symbol
,
project
.
Id
),
project
.
Solution
,
project
.
Solution
,
progressAdapter
,
new
FindReferencesProgressAdapter
(
threadingContext
,
project
.
Solution
,
roslynFindUsagesContext
,
options
)
,
documents
:
null
,
documents
:
null
,
options
,
options
,
cancellationToken
);
cancellationToken
);
...
@@ -171,43 +179,12 @@ internal abstract partial class AbstractFindUsagesService : IFindUsagesService
...
@@ -171,43 +179,12 @@ internal abstract partial class AbstractFindUsagesService : IFindUsagesService
var
codeIndexReferencesTask
=
FindCodeIndexReferencesAsync
(
var
codeIndexReferencesTask
=
FindCodeIndexReferencesAsync
(
codeIndexProvider
,
codeIndexProvider
,
symbol
,
symbol
,
project
.
Solution
,
codeIndexFindUsagesContext
,
progressAdapter
,
options
,
cancellationToken
);
cancellationToken
);
await
Task
.
WhenAll
(
normalFindReferencesTask
,
codeIndexReferencesTask
).
ConfigureAwait
(
false
);
await
Task
.
WhenAll
(
normalFindReferencesTask
,
codeIndexReferencesTask
).
ConfigureAwait
(
false
);
}
}
private
async
Task
FindCodeIndexReferencesAsync
(
ICodeIndexProvider
?
codeIndexProvider
,
ISymbol
symbol
,
Solution
solution
,
FindReferencesProgressAdapter
progressAdapter
,
FindReferencesSearchOptions
options
,
CancellationToken
cancellationToken
)
{
if
(
codeIndexProvider
==
null
)
return
;
var
moniker
=
SymbolMoniker
.
TryCreate
(
symbol
);
if
(
moniker
==
null
)
return
;
var
monikers
=
SpecializedCollections
.
SingletonEnumerable
(
moniker
);
var
currentPage
=
0
;
while
(
true
)
{
var
results
=
await
codeIndexProvider
.
FindReferencesByMonikerAsync
(
monikers
,
includeDecleration
:
true
,
pageIndex
:
currentPage
,
cancellationToken
:
cancellationToken
).
ConfigureAwait
(
false
);
if
(
results
==
null
||
results
.
Count
==
0
)
break
;
currentPage
++;
await
ProcessCodeIndexResultsAsync
(
codeIndexProvider
,
results
,
cancellationToken
).
ConfigureAwait
(
false
);
}
}
private
async
Task
<
bool
>
TryFindLiteralReferencesAsync
(
private
async
Task
<
bool
>
TryFindLiteralReferencesAsync
(
Document
document
,
int
position
,
IFindUsagesContext
context
)
Document
document
,
int
position
,
IFindUsagesContext
context
)
{
{
...
...
src/EditorFeatures/Core/FindUsages/AggregateFindUsagesContext.cs
0 → 100644
浏览文件 @
b94c6fb8
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using
System
;
using
System.Collections.Generic
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
Microsoft.CodeAnalysis.FindUsages
;
using
Roslyn.Utilities
;
namespace
Microsoft.CodeAnalysis.Editor.FindUsages
{
/// <summary>
/// Helper class that allows us to provide a unified Find-Usages progress over multiple
/// subroutines computing different types of usages.
/// </summary>
internal
class
FindUsagesContextAggregator
{
/// <summary>
/// Real context object we'll forward messages to.
/// </summary>
private
readonly
IFindUsagesContext
_context
;
/// <summary>
/// Underlying context objects that we'll receive messages from and forward to <see cref="_context"/>
/// </summary>
private
readonly
List
<
ForwardingFindUsagesContext
>
_underlyingContexts
=
new
List
<
ForwardingFindUsagesContext
>();
private
readonly
object
_gate
=
new
object
();
private
readonly
Dictionary
<
ForwardingFindUsagesContext
,
(
int
current
,
int
maxium
)>
_underlyingContextToProgress
=
new
Dictionary
<
ForwardingFindUsagesContext
,
(
int
current
,
int
maxium
)>();
public
FindUsagesContextAggregator
(
IFindUsagesContext
context
)
{
_context
=
context
;
}
public
IFindUsagesContext
CreateForwardingContext
()
{
var
result
=
new
ForwardingFindUsagesContext
(
this
);
lock
(
_gate
)
{
_underlyingContexts
.
Add
(
result
);
}
return
result
;
}
private
Task
ReportProgressAsync
(
ForwardingFindUsagesContext
context
,
int
current
,
int
maximum
)
{
int
combinedCurrent
=
0
,
combinedMaximum
=
0
;
lock
(
_gate
)
{
_underlyingContextToProgress
[
context
]
=
(
current
,
maximum
);
foreach
(
var
(
_
,
(
singleCurrent
,
singleMaximum
))
in
_underlyingContextToProgress
)
{
combinedCurrent
+=
singleCurrent
;
combinedMaximum
+=
singleMaximum
;
}
}
return
_context
.
ReportProgressAsync
(
combinedCurrent
,
combinedMaximum
);
}
#
region
Simple
forwarding
calls
private
CancellationToken
CancellationToken
=>
_context
.
CancellationToken
;
private
Task
OnDefinitionFoundAsync
(
DefinitionItem
definition
)
=>
_context
.
OnDefinitionFoundAsync
(
definition
);
private
Task
OnReferenceFoundAsync
(
SourceReferenceItem
reference
)
=>
_context
.
OnReferenceFoundAsync
(
reference
);
private
Task
OnExternalReferenceFoundAsync
(
ExternalReferenceItem
reference
)
=>
_context
.
OnExternalReferenceFoundAsync
(
reference
);
private
Task
ReportMessageAsync
(
string
message
)
=>
_context
.
ReportMessageAsync
(
message
);
private
Task
SetSearchTitleAsync
(
string
title
)
=>
_context
.
ReportMessageAsync
(
title
);
#
endregion
private
class
ForwardingFindUsagesContext
:
IFindUsagesContext
{
private
readonly
FindUsagesContextAggregator
_aggregator
;
public
ForwardingFindUsagesContext
(
FindUsagesContextAggregator
aggregateFindUsagesContext
)
{
_aggregator
=
aggregateFindUsagesContext
;
}
// We pass ourselves along to the aggregator so it can keep track of the current/max
// *per* underlying context.
public
Task
ReportProgressAsync
(
int
current
,
int
maximum
)
=>
_aggregator
.
ReportProgressAsync
(
this
,
current
,
maximum
);
#
region
Simple
forwarding
calls
public
CancellationToken
CancellationToken
=>
_aggregator
.
CancellationToken
;
public
Task
OnDefinitionFoundAsync
(
DefinitionItem
definition
)
=>
_aggregator
.
OnDefinitionFoundAsync
(
definition
);
public
Task
OnReferenceFoundAsync
(
SourceReferenceItem
reference
)
=>
_aggregator
.
OnReferenceFoundAsync
(
reference
);
public
Task
OnExternalReferenceFoundAsync
(
ExternalReferenceItem
reference
)
=>
_aggregator
.
OnExternalReferenceFoundAsync
(
reference
);
public
Task
ReportMessageAsync
(
string
message
)
=>
_aggregator
.
ReportMessageAsync
(
message
);
public
Task
SetSearchTitleAsync
(
string
title
)
=>
_aggregator
.
ReportMessageAsync
(
title
);
#
endregion
}
}
}
src/EditorFeatures/Core/FindUsages/FindUsagesContext.cs
浏览文件 @
b94c6fb8
...
@@ -2,10 +2,8 @@
...
@@ -2,10 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
// See the LICENSE file in the project root for more information.
using
System
;
using
System.Threading
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
using
Roslyn.Utilities
;
namespace
Microsoft.CodeAnalysis.FindUsages
namespace
Microsoft.CodeAnalysis.FindUsages
{
{
...
@@ -27,6 +25,8 @@ protected FindUsagesContext()
...
@@ -27,6 +25,8 @@ protected FindUsagesContext()
public
virtual
Task
OnReferenceFoundAsync
(
SourceReferenceItem
reference
)
=>
Task
.
CompletedTask
;
public
virtual
Task
OnReferenceFoundAsync
(
SourceReferenceItem
reference
)
=>
Task
.
CompletedTask
;
public
virtual
Task
OnExternalReferenceFoundAsync
(
ExternalReferenceItem
reference
)
=>
Task
.
CompletedTask
;
public
virtual
Task
ReportProgressAsync
(
int
current
,
int
maximum
)
=>
Task
.
CompletedTask
;
public
virtual
Task
ReportProgressAsync
(
int
current
,
int
maximum
)
=>
Task
.
CompletedTask
;
}
}
}
}
src/EditorFeatures/Core/FindUsages/FindUsagesHelpers.cs
浏览文件 @
b94c6fb8
...
@@ -138,5 +138,43 @@ public static async Task<(ISymbol symbol, Project project, ImmutableArray<ISymbo
...
@@ -138,5 +138,43 @@ public static async Task<(ISymbol symbol, Project project, ImmutableArray<ISymbo
return
ImmutableArray
.
Create
(
symbol
);
return
ImmutableArray
.
Create
(
symbol
);
}
}
}
}
private
static
SymbolDisplayFormat
GetFormat
(
ISymbol
definition
)
{
return
definition
.
Kind
==
SymbolKind
.
Parameter
?
s_parameterDefinitionFormat
:
s_definitionFormat
;
}
private
static
readonly
SymbolDisplayFormat
s_namePartsFormat
=
new
SymbolDisplayFormat
(
memberOptions
:
SymbolDisplayMemberOptions
.
IncludeContainingType
);
private
static
readonly
SymbolDisplayFormat
s_definitionFormat
=
new
SymbolDisplayFormat
(
typeQualificationStyle
:
SymbolDisplayTypeQualificationStyle
.
NameOnly
,
genericsOptions
:
SymbolDisplayGenericsOptions
.
IncludeTypeParameters
,
parameterOptions
:
SymbolDisplayParameterOptions
.
IncludeType
,
propertyStyle
:
SymbolDisplayPropertyStyle
.
ShowReadWriteDescriptor
,
delegateStyle
:
SymbolDisplayDelegateStyle
.
NameAndSignature
,
kindOptions
:
SymbolDisplayKindOptions
.
IncludeMemberKeyword
|
SymbolDisplayKindOptions
.
IncludeNamespaceKeyword
|
SymbolDisplayKindOptions
.
IncludeTypeKeyword
,
localOptions
:
SymbolDisplayLocalOptions
.
IncludeType
,
memberOptions
:
SymbolDisplayMemberOptions
.
IncludeContainingType
|
SymbolDisplayMemberOptions
.
IncludeExplicitInterface
|
SymbolDisplayMemberOptions
.
IncludeModifiers
|
SymbolDisplayMemberOptions
.
IncludeParameters
|
SymbolDisplayMemberOptions
.
IncludeType
,
miscellaneousOptions
:
SymbolDisplayMiscellaneousOptions
.
EscapeKeywordIdentifiers
|
SymbolDisplayMiscellaneousOptions
.
UseSpecialTypes
);
private
static
readonly
SymbolDisplayFormat
s_parameterDefinitionFormat
=
s_definitionFormat
.
AddParameterOptions
(
SymbolDisplayParameterOptions
.
IncludeName
);
public
static
ImmutableArray
<
TaggedText
>
GetDisplayParts
(
ISymbol
definition
)
=>
definition
.
ToDisplayParts
(
GetFormat
(
definition
)).
ToTaggedText
();
public
static
ImmutableArray
<
TaggedText
>
GetNameDisplayParts
(
ISymbol
definition
)
=>
definition
.
ToDisplayParts
(
s_namePartsFormat
).
ToTaggedText
();
}
}
}
}
src/EditorFeatures/Core/FindUsages/IDefinitionsAndReferencesFactory.cs
浏览文件 @
b94c6fb8
...
@@ -20,6 +20,8 @@
...
@@ -20,6 +20,8 @@
namespace
Microsoft.CodeAnalysis.Editor.FindUsages
namespace
Microsoft.CodeAnalysis.Editor.FindUsages
{
{
using
static
FindUsagesHelpers
;
internal
interface
IDefinitionsAndReferencesFactory
:
IWorkspaceService
internal
interface
IDefinitionsAndReferencesFactory
:
IWorkspaceService
{
{
DefinitionItem
GetThirdPartyDefinitionItem
(
DefinitionItem
GetThirdPartyDefinitionItem
(
...
@@ -94,8 +96,8 @@ internal static class DefinitionItemExtensions
...
@@ -94,8 +96,8 @@ internal static class DefinitionItemExtensions
definition
=
definition
.
OriginalDefinition
;
definition
=
definition
.
OriginalDefinition
;
}
}
var
displayParts
=
definition
.
ToDisplayParts
(
GetFormat
(
definition
)).
ToTaggedText
(
);
var
displayParts
=
GetDisplayParts
(
definition
);
var
nameDisplayParts
=
definition
.
ToDisplayParts
(
s_namePartsFormat
).
ToTaggedText
(
);
var
nameDisplayParts
=
GetNameDisplayParts
(
definition
);
var
tags
=
GlyphTags
.
GetTags
(
definition
.
GetGlyph
());
var
tags
=
GlyphTags
.
GetTags
(
definition
.
GetGlyph
());
var
displayIfNoReferences
=
definition
.
ShouldShowWithNoReferenceLocations
(
var
displayIfNoReferences
=
definition
.
ShouldShowWithNoReferenceLocations
(
...
@@ -204,37 +206,5 @@ internal static class DefinitionItemExtensions
...
@@ -204,37 +206,5 @@ internal static class DefinitionItemExtensions
return
new
SourceReferenceItem
(
definitionItem
,
documentSpan
,
referenceLocation
.
SymbolUsageInfo
,
referenceLocation
.
AdditionalProperties
);
return
new
SourceReferenceItem
(
definitionItem
,
documentSpan
,
referenceLocation
.
SymbolUsageInfo
,
referenceLocation
.
AdditionalProperties
);
}
}
private
static
SymbolDisplayFormat
GetFormat
(
ISymbol
definition
)
{
return
definition
.
Kind
==
SymbolKind
.
Parameter
?
s_parameterDefinitionFormat
:
s_definitionFormat
;
}
private
static
readonly
SymbolDisplayFormat
s_namePartsFormat
=
new
SymbolDisplayFormat
(
memberOptions
:
SymbolDisplayMemberOptions
.
IncludeContainingType
);
private
static
readonly
SymbolDisplayFormat
s_definitionFormat
=
new
SymbolDisplayFormat
(
typeQualificationStyle
:
SymbolDisplayTypeQualificationStyle
.
NameOnly
,
genericsOptions
:
SymbolDisplayGenericsOptions
.
IncludeTypeParameters
,
parameterOptions
:
SymbolDisplayParameterOptions
.
IncludeType
,
propertyStyle
:
SymbolDisplayPropertyStyle
.
ShowReadWriteDescriptor
,
delegateStyle
:
SymbolDisplayDelegateStyle
.
NameAndSignature
,
kindOptions
:
SymbolDisplayKindOptions
.
IncludeMemberKeyword
|
SymbolDisplayKindOptions
.
IncludeNamespaceKeyword
|
SymbolDisplayKindOptions
.
IncludeTypeKeyword
,
localOptions
:
SymbolDisplayLocalOptions
.
IncludeType
,
memberOptions
:
SymbolDisplayMemberOptions
.
IncludeContainingType
|
SymbolDisplayMemberOptions
.
IncludeExplicitInterface
|
SymbolDisplayMemberOptions
.
IncludeModifiers
|
SymbolDisplayMemberOptions
.
IncludeParameters
|
SymbolDisplayMemberOptions
.
IncludeType
,
miscellaneousOptions
:
SymbolDisplayMiscellaneousOptions
.
EscapeKeywordIdentifiers
|
SymbolDisplayMiscellaneousOptions
.
UseSpecialTypes
);
private
static
readonly
SymbolDisplayFormat
s_parameterDefinitionFormat
=
s_definitionFormat
.
AddParameterOptions
(
SymbolDisplayParameterOptions
.
IncludeName
);
}
}
}
}
src/EditorFeatures/Core/FindUsages/IFindUsagesContext.cs
浏览文件 @
b94c6fb8
...
@@ -23,6 +23,7 @@ internal interface IFindUsagesContext
...
@@ -23,6 +23,7 @@ internal interface IFindUsagesContext
Task
OnDefinitionFoundAsync
(
DefinitionItem
definition
);
Task
OnDefinitionFoundAsync
(
DefinitionItem
definition
);
Task
OnReferenceFoundAsync
(
SourceReferenceItem
reference
);
Task
OnReferenceFoundAsync
(
SourceReferenceItem
reference
);
Task
OnExternalReferenceFoundAsync
(
ExternalReferenceItem
reference
);
Task
ReportProgressAsync
(
int
current
,
int
maximum
);
Task
ReportProgressAsync
(
int
current
,
int
maximum
);
}
}
...
...
src/EditorFeatures/Core/Host/IStreamingFindReferencesPresenter.cs
浏览文件 @
b94c6fb8
...
@@ -3,7 +3,6 @@
...
@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
// See the LICENSE file in the project root for more information.
using
System.Collections.Immutable
;
using
System.Collections.Immutable
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
using
Microsoft.CodeAnalysis.FindUsages
;
using
Microsoft.CodeAnalysis.FindUsages
;
...
...
src/EditorFeatures/VisualBasic/FindUsages/VisualBasicFindUsagesService.vb
浏览文件 @
b94c6fb8
...
@@ -6,6 +6,7 @@ Imports System.Composition
...
@@ -6,6 +6,7 @@ Imports System.Composition
Imports
Microsoft.CodeAnalysis.Editor.FindUsages
Imports
Microsoft.CodeAnalysis.Editor.FindUsages
Imports
Microsoft.CodeAnalysis.Editor.Shared.Utilities
Imports
Microsoft.CodeAnalysis.Editor.Shared.Utilities
Imports
Microsoft.CodeAnalysis.Host.Mef
Imports
Microsoft.CodeAnalysis.Host.Mef
Imports
VS.IntelliNav.Contracts
Namespace
Microsoft.CodeAnalysis.Editor.VisualBasic.FindUsages
Namespace
Microsoft.CodeAnalysis.Editor.VisualBasic.FindUsages
<
ExportLanguageService
(
GetType
(
IFindUsagesService
),
LanguageNames
.
VisualBasic
),
[
Shared
]
>
<
ExportLanguageService
(
GetType
(
IFindUsagesService
),
LanguageNames
.
VisualBasic
),
[
Shared
]
>
...
@@ -14,8 +15,9 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.FindUsages
...
@@ -14,8 +15,9 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.FindUsages
<
ImportingConstructor
>
<
ImportingConstructor
>
<
Obsolete
(
MefConstruction
.
ImportingConstructorMessage
,
True
)
>
<
Obsolete
(
MefConstruction
.
ImportingConstructorMessage
,
True
)
>
Public
Sub
New
(
threadingContext
As
IThreadingContext
)
Public
Sub
New
(
threadingContext
As
IThreadingContext
,
MyBase
.
New
(
threadingContext
)
<
Import
(
AllowDefault
:
=
True
)
>
codeIndexProvider
As
ICodeIndexProvider
)
MyBase
.
New
(
threadingContext
,
codeIndexProvider
)
End
Sub
End
Sub
End
Class
End
Class
End
Namespace
End
Namespace
src/Features/Core/Portable/FindUsages/ExternalReferenceItem.cs
0 → 100644
浏览文件 @
b94c6fb8
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
namespace
Microsoft.CodeAnalysis.FindUsages
{
/// <summary>
/// Information about a symbol's reference that can be used for display and navigation in an
/// editor. These generally reference items outside of the Roslyn <see cref="Solution"/> model
/// provided by external sources (for example: RichNav).
/// </summary>
internal
sealed
class
ExternalReferenceItem
{
/// <summary>
/// The definition this reference corresponds to.
/// </summary>
public
DefinitionItem
Definition
{
get
;
}
public
ExternalReferenceItem
(
DefinitionItem
definition
,
string
documentName
,
string
projectName
,
object
text
,
string
displayPath
)
{
Definition
=
definition
;
DocumentName
=
documentName
;
ProjectName
=
projectName
;
Text
=
text
;
DisplayPath
=
displayPath
;
}
public
string
DocumentName
{
get
;
}
public
string
ProjectName
{
get
;
}
/// <remarks>
/// Must be of type Microsoft.VisualStudio.Text.Adornments.ImageElement or
/// Microsoft.VisualStudio.Text.Adornments.ContainerElement or
/// Microsoft.VisualStudio.Text.Adornments.ClassifiedTextElement or System.String
/// </remarks>
public
object
Text
{
get
;
}
public
string
DisplayPath
{
get
;
}
}
}
src/Tools/ExternalAccess/Debugger/DebuggerFindReferencesService.cs
浏览文件 @
b94c6fb8
...
@@ -39,7 +39,9 @@ public async Task FindSymbolReferencesAsync(ISymbol symbol, Project project, Can
...
@@ -39,7 +39,9 @@ public async Task FindSymbolReferencesAsync(ISymbol symbol, Project project, Can
// the context object that the FAR service will push results into.
// the context object that the FAR service will push results into.
var
context
=
streamingPresenter
.
StartSearch
(
EditorFeaturesResources
.
Find_References
,
supportsReferences
:
true
);
var
context
=
streamingPresenter
.
StartSearch
(
EditorFeaturesResources
.
Find_References
,
supportsReferences
:
true
);
await
AbstractFindUsagesService
.
FindSymbolReferencesAsync
(
_threadingContext
,
context
,
symbol
,
project
,
cancellationToken
).
ConfigureAwait
(
false
);
await
AbstractFindUsagesService
.
FindSymbolReferencesAsync
(
_threadingContext
,
codeIndexProvider
:
null
,
context
,
symbol
,
project
,
cancellationToken
).
ConfigureAwait
(
false
);
// Note: we don't need to put this in a finally. The only time we might not hit
// Note: we don't need to put this in a finally. The only time we might not hit
// this is if cancellation or another error gets thrown. In the former case,
// this is if cancellation or another error gets thrown. In the former case,
...
...
src/VisualStudio/Core/Def/Implementation/FindReferences/Contexts/AbstractTableDataSourceFindUsagesContext.cs
浏览文件 @
b94c6fb8
...
@@ -6,23 +6,19 @@
...
@@ -6,23 +6,19 @@
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Collections.Immutable
;
using
System.Collections.Immutable
;
using
System.Diagnostics
;
using
System.Diagnostics
;
using
System.Linq
;
using
System.Threading
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
using
Microsoft.CodeAnalysis
;
using
Microsoft.CodeAnalysis
;
using
Microsoft.CodeAnalysis.Classification
;
using
Microsoft.CodeAnalysis.Classification
;
using
Microsoft.CodeAnalysis.DocumentHighlighting
;
using
Microsoft.CodeAnalysis.DocumentHighlighting
;
using
Microsoft.CodeAnalysis.FindSymbols.Finders
;
using
Microsoft.CodeAnalysis.FindSymbols.Finders
;
using
Microsoft.CodeAnalysis.FindSymbols.FindReferences
;
using
Microsoft.CodeAnalysis.FindUsages
;
using
Microsoft.CodeAnalysis.FindUsages
;
using
Microsoft.CodeAnalysis.Host
;
using
Microsoft.CodeAnalysis.Host
;
using
Microsoft.CodeAnalysis.PooledObjects
;
using
Microsoft.CodeAnalysis.PooledObjects
;
using
Microsoft.CodeAnalysis.Text
;
using
Microsoft.CodeAnalysis.Text
;
using
Microsoft.VisualStudio.LanguageServices.Implementation.FindReferences
;
using
Microsoft.VisualStudio.Shell.FindAllReferences
;
using
Microsoft.VisualStudio.Shell.FindAllReferences
;
using
Microsoft.VisualStudio.Shell.TableControl
;
using
Microsoft.VisualStudio.Shell.TableControl
;
using
Microsoft.VisualStudio.Shell.TableManager
;
using
Microsoft.VisualStudio.Shell.TableManager
;
using
Roslyn.Utilities
;
namespace
Microsoft.VisualStudio.LanguageServices.FindUsages
namespace
Microsoft.VisualStudio.LanguageServices.FindUsages
{
{
...
@@ -259,7 +255,7 @@ public IDisposable Subscribe(ITableDataSink sink)
...
@@ -259,7 +255,7 @@ public IDisposable Subscribe(ITableDataSink sink)
#
endregion
#
endregion
#
region
FindUsagesContext
overrides
.
#
region
IFindUsagesContext
implementation
.
public
sealed
override
Task
SetSearchTitleAsync
(
string
title
)
public
sealed
override
Task
SetSearchTitleAsync
(
string
title
)
{
{
...
@@ -268,7 +264,7 @@ public sealed override Task SetSearchTitleAsync(string title)
...
@@ -268,7 +264,7 @@ public sealed override Task SetSearchTitleAsync(string title)
return
Task
.
CompletedTask
;
return
Task
.
CompletedTask
;
}
}
public
sealed
override
async
Task
OnCompletedAsync
()
public
async
sealed
override
Task
OnCompletedAsync
()
{
{
await
OnCompletedAsyncWorkerAsync
().
ConfigureAwait
(
false
);
await
OnCompletedAsyncWorkerAsync
().
ConfigureAwait
(
false
);
...
@@ -355,12 +351,15 @@ private async Task<(ExcerptResult, SourceText)> ExcerptAsync(SourceText sourceTe
...
@@ -355,12 +351,15 @@ private async Task<(ExcerptResult, SourceText)> ExcerptAsync(SourceText sourceTe
}
}
public
sealed
override
Task
OnReferenceFoundAsync
(
SourceReferenceItem
reference
)
public
sealed
override
Task
OnReferenceFoundAsync
(
SourceReferenceItem
reference
)
{
=>
OnReferenceFoundWorkerAsync
(
reference
);
return
OnReferenceFoundWorkerAsync
(
reference
);
}
protected
abstract
Task
OnReferenceFoundWorkerAsync
(
SourceReferenceItem
reference
);
protected
abstract
Task
OnReferenceFoundWorkerAsync
(
SourceReferenceItem
reference
);
public
sealed
override
Task
OnExternalReferenceFoundAsync
(
ExternalReferenceItem
reference
)
=>
OnExternalReferenceFoundWorkerAsync
(
reference
);
protected
abstract
Task
OnExternalReferenceFoundWorkerAsync
(
ExternalReferenceItem
reference
);
protected
RoslynDefinitionBucket
GetOrCreateDefinitionBucket
(
DefinitionItem
definition
)
protected
RoslynDefinitionBucket
GetOrCreateDefinitionBucket
(
DefinitionItem
definition
)
{
{
lock
(
Gate
)
lock
(
Gate
)
...
@@ -375,6 +374,9 @@ protected RoslynDefinitionBucket GetOrCreateDefinitionBucket(DefinitionItem defi
...
@@ -375,6 +374,9 @@ protected RoslynDefinitionBucket GetOrCreateDefinitionBucket(DefinitionItem defi
}
}
}
}
public
sealed
override
Task
ReportMessageAsync
(
string
message
)
=>
throw
new
InvalidOperationException
(
"This should never be called in the streaming case."
);
public
sealed
override
Task
ReportProgressAsync
(
int
current
,
int
maximum
)
public
sealed
override
Task
ReportProgressAsync
(
int
current
,
int
maximum
)
{
{
// https://devdiv.visualstudio.com/web/wi.aspx?pcguid=011b8bdf-6d56-4f87-be0d-0092136884d9&id=359162
// https://devdiv.visualstudio.com/web/wi.aspx?pcguid=011b8bdf-6d56-4f87-be0d-0092136884d9&id=359162
...
...
src/VisualStudio/Core/Def/Implementation/FindReferences/Contexts/WithReferencesFindUsagesContext.cs
浏览文件 @
b94c6fb8
...
@@ -117,6 +117,21 @@ protected override Task OnReferenceFoundWorkerAsync(SourceReferenceItem referenc
...
@@ -117,6 +117,21 @@ protected override Task OnReferenceFoundWorkerAsync(SourceReferenceItem referenc
addToEntriesWhenNotGroupingByDefinition
:
true
);
addToEntriesWhenNotGroupingByDefinition
:
true
);
}
}
protected
override
Task
OnExternalReferenceFoundWorkerAsync
(
ExternalReferenceItem
reference
)
{
// Normal references go into both sets of entries.
return
OnEntryFoundAsync
(
reference
.
Definition
,
bucket
=>
TryCreateExternalItemEntryAsync
(
reference
),
addToEntriesWhenGroupingByDefinition
:
true
,
addToEntriesWhenNotGroupingByDefinition
:
true
);
}
private
Task
<
Entry
>
TryCreateExternalItemEntryAsync
(
ExternalReferenceItem
reference
)
{
throw
new
NotImplementedException
();
}
protected
async
Task
OnEntryFoundAsync
(
protected
async
Task
OnEntryFoundAsync
(
DefinitionItem
definition
,
DefinitionItem
definition
,
Func
<
RoslynDefinitionBucket
,
Task
<
Entry
>>
createEntryAsync
,
Func
<
RoslynDefinitionBucket
,
Task
<
Entry
>>
createEntryAsync
,
...
...
src/VisualStudio/Core/Def/Implementation/FindReferences/Contexts/WithoutReferencesFindUsagesContext.cs
浏览文件 @
b94c6fb8
...
@@ -37,6 +37,10 @@ private class WithoutReferencesFindUsagesContext : AbstractTableDataSourceFindUs
...
@@ -37,6 +37,10 @@ private class WithoutReferencesFindUsagesContext : AbstractTableDataSourceFindUs
protected
override
Task
OnReferenceFoundWorkerAsync
(
SourceReferenceItem
reference
)
protected
override
Task
OnReferenceFoundWorkerAsync
(
SourceReferenceItem
reference
)
=>
throw
new
InvalidOperationException
();
=>
throw
new
InvalidOperationException
();
// We should never be called in a context where we get references.
protected
override
Task
OnExternalReferenceFoundWorkerAsync
(
ExternalReferenceItem
reference
)
=>
throw
new
InvalidOperationException
();
// Nothing to do on completion.
// Nothing to do on completion.
protected
override
Task
OnCompletedAsyncWorkerAsync
()
protected
override
Task
OnCompletedAsyncWorkerAsync
()
=>
Task
.
CompletedTask
;
=>
Task
.
CompletedTask
;
...
...
src/VisualStudio/Core/Def/Implementation/Library/ObjectBrowser/AbstractObjectBrowserLibraryManager.cs
浏览文件 @
b94c6fb8
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
using
Microsoft.VisualStudio.OLE.Interop
;
using
Microsoft.VisualStudio.OLE.Interop
;
using
Microsoft.VisualStudio.Shell
;
using
Microsoft.VisualStudio.Shell
;
using
Microsoft.VisualStudio.Shell.Interop
;
using
Microsoft.VisualStudio.Shell.Interop
;
using
VS.IntelliNav.Contracts
;
using
IServiceProvider
=
System
.
IServiceProvider
;
using
IServiceProvider
=
System
.
IServiceProvider
;
using
Task
=
System
.
Threading
.
Tasks
.
Task
;
using
Task
=
System
.
Threading
.
Tasks
.
Task
;
...
@@ -44,6 +45,7 @@ internal abstract partial class AbstractObjectBrowserLibraryManager : AbstractLi
...
@@ -44,6 +45,7 @@ internal abstract partial class AbstractObjectBrowserLibraryManager : AbstractLi
private
readonly
IStreamingFindUsagesPresenter
_streamingPresenter
;
private
readonly
IStreamingFindUsagesPresenter
_streamingPresenter
;
private
readonly
IThreadingContext
_threadingContext
;
private
readonly
IThreadingContext
_threadingContext
;
private
readonly
ICodeIndexProvider
_codeIndexProvider
;
protected
AbstractObjectBrowserLibraryManager
(
protected
AbstractObjectBrowserLibraryManager
(
string
languageName
,
string
languageName
,
...
@@ -64,6 +66,7 @@ internal abstract partial class AbstractObjectBrowserLibraryManager : AbstractLi
...
@@ -64,6 +66,7 @@ internal abstract partial class AbstractObjectBrowserLibraryManager : AbstractLi
_libraryService
=
new
Lazy
<
ILibraryService
>(()
=>
Workspace
.
Services
.
GetLanguageServices
(
_languageName
).
GetService
<
ILibraryService
>());
_libraryService
=
new
Lazy
<
ILibraryService
>(()
=>
Workspace
.
Services
.
GetLanguageServices
(
_languageName
).
GetService
<
ILibraryService
>());
_streamingPresenter
=
componentModel
.
DefaultExportProvider
.
GetExportedValue
<
IStreamingFindUsagesPresenter
>();
_streamingPresenter
=
componentModel
.
DefaultExportProvider
.
GetExportedValue
<
IStreamingFindUsagesPresenter
>();
_threadingContext
=
componentModel
.
DefaultExportProvider
.
GetExportedValue
<
IThreadingContext
>();
_threadingContext
=
componentModel
.
DefaultExportProvider
.
GetExportedValue
<
IThreadingContext
>();
_codeIndexProvider
=
componentModel
.
DefaultExportProvider
.
GetExportedValue
<
ICodeIndexProvider
>();
}
}
internal
abstract
AbstractDescriptionBuilder
CreateDescriptionBuilder
(
internal
abstract
AbstractDescriptionBuilder
CreateDescriptionBuilder
(
...
@@ -542,7 +545,7 @@ protected override bool TryExec(Guid commandGroup, uint commandId)
...
@@ -542,7 +545,7 @@ protected override bool TryExec(Guid commandGroup, uint commandId)
// thread.
// thread.
await
Task
.
Run
(
async
()
=>
await
Task
.
Run
(
async
()
=>
{
{
await
FindReferencesAsync
(
_threadingContext
,
symbolListItem
,
project
,
context
,
cancellationToken
).
ConfigureAwait
(
false
);
await
FindReferencesAsync
(
_threadingContext
,
_codeIndexProvider
,
symbolListItem
,
project
,
context
,
cancellationToken
).
ConfigureAwait
(
false
);
},
cancellationToken
).
ConfigureAwait
(
false
);
},
cancellationToken
).
ConfigureAwait
(
false
);
// Note: we don't need to put this in a finally. The only time we might not hit
// Note: we don't need to put this in a finally. The only time we might not hit
...
@@ -560,14 +563,16 @@ protected override bool TryExec(Guid commandGroup, uint commandId)
...
@@ -560,14 +563,16 @@ protected override bool TryExec(Guid commandGroup, uint commandId)
}
}
}
}
private
static
async
Task
FindReferencesAsync
(
IThreadingContext
threadingContext
,
SymbolListItem
symbolListItem
,
Project
project
,
CodeAnalysis
.
FindUsages
.
FindUsagesContext
context
,
CancellationToken
cancellationToken
)
private
static
async
Task
FindReferencesAsync
(
IThreadingContext
threadingContext
,
ICodeIndexProvider
codeIndexProvider
,
SymbolListItem
symbolListItem
,
Project
project
,
CodeAnalysis
.
FindUsages
.
FindUsagesContext
context
,
CancellationToken
cancellationToken
)
{
{
var
compilation
=
await
project
.
GetCompilationAsync
(
cancellationToken
).
ConfigureAwait
(
false
);
var
compilation
=
await
project
.
GetCompilationAsync
(
cancellationToken
).
ConfigureAwait
(
false
);
var
symbol
=
symbolListItem
.
ResolveSymbol
(
compilation
);
var
symbol
=
symbolListItem
.
ResolveSymbol
(
compilation
);
if
(
symbol
!=
null
)
if
(
symbol
!=
null
)
{
{
await
AbstractFindUsagesService
.
FindSymbolReferencesAsync
(
await
AbstractFindUsagesService
.
FindSymbolReferencesAsync
(
threadingContext
,
threadingContext
,
codeIndexProvider
,
context
,
symbol
,
project
,
cancellationToken
).
ConfigureAwait
(
false
);
context
,
symbol
,
project
,
cancellationToken
).
ConfigureAwait
(
false
);
}
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录