Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
bbe1d6b2
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,发现更多精彩内容 >>
提交
bbe1d6b2
编写于
4月 20, 2020
作者:
C
Cyrus Najmabadi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Siplify code
上级
05b2ed1b
变更
19
隐藏空白更改
内联
并排
Showing
19 changed file
with
63 addition
and
73 deletion
+63
-73
src/EditorFeatures/Core/FindUsages/AbstractFindUsagesService.ProgressAdapter.cs
...e/FindUsages/AbstractFindUsagesService.ProgressAdapter.cs
+1
-2
src/EditorFeatures/Core/FindUsages/AbstractFindUsagesService.cs
...itorFeatures/Core/FindUsages/AbstractFindUsagesService.cs
+10
-18
src/EditorFeatures/Core/FindUsages/FindUsagesHelpers.cs
src/EditorFeatures/Core/FindUsages/FindUsagesHelpers.cs
+6
-6
src/EditorFeatures/Core/FindUsages/IDefinitionsAndReferencesFactory.cs
...tures/Core/FindUsages/IDefinitionsAndReferencesFactory.cs
+7
-7
src/EditorFeatures/Core/GoToBase/AbstractGoToBaseService.cs
src/EditorFeatures/Core/GoToBase/AbstractGoToBaseService.cs
+6
-8
src/EditorFeatures/Core/GoToBase/FindBaseHelpers.cs
src/EditorFeatures/Core/GoToBase/FindBaseHelpers.cs
+2
-3
src/EditorFeatures/Core/GoToDefinition/AbstractGoToDefinitionService.cs
...ures/Core/GoToDefinition/AbstractGoToDefinitionService.cs
+2
-2
src/EditorFeatures/Core/GoToDefinition/AbstractGoToSymbolService.cs
...Features/Core/GoToDefinition/AbstractGoToSymbolService.cs
+3
-2
src/EditorFeatures/Core/GoToDefinition/GoToDefinitionHelpers.cs
...itorFeatures/Core/GoToDefinition/GoToDefinitionHelpers.cs
+8
-9
src/EditorFeatures/Core/Implementation/IntelliSense/Helpers.cs
...ditorFeatures/Core/Implementation/IntelliSense/Helpers.cs
+1
-1
src/EditorFeatures/Core/Implementation/Peek/PeekableItemFactory.cs
...rFeatures/Core/Implementation/Peek/PeekableItemFactory.cs
+1
-1
src/EditorFeatures/Core/NavigableSymbols/NavigableSymbolService.NavigableSymbol.cs
...avigableSymbols/NavigableSymbolService.NavigableSymbol.cs
+1
-1
src/Features/Core/Portable/FindUsages/DefinitionItem.cs
src/Features/Core/Portable/FindUsages/DefinitionItem.cs
+6
-3
src/Tools/ExternalAccess/Debugger/DebuggerFindReferencesService.cs
.../ExternalAccess/Debugger/DebuggerFindReferencesService.cs
+2
-1
src/VisualStudio/Core/Def/Implementation/Library/ObjectBrowser/AbstractObjectBrowserLibraryManager.cs
...rary/ObjectBrowser/AbstractObjectBrowserLibraryManager.cs
+1
-2
src/VisualStudio/Core/Def/Implementation/Workspace/VisualStudioSymbolNavigationService.cs
...entation/Workspace/VisualStudioSymbolNavigationService.cs
+3
-3
src/VisualStudio/Core/Impl/RoslynVisualStudioWorkspace.cs
src/VisualStudio/Core/Impl/RoslynVisualStudioWorkspace.cs
+1
-1
src/Workspaces/Core/Portable/FindSymbols/FindReferences/BaseTypeFinder.cs
...ore/Portable/FindSymbols/FindReferences/BaseTypeFinder.cs
+1
-2
src/Workspaces/CoreTest/FindReferencesTests.cs
src/Workspaces/CoreTest/FindReferencesTests.cs
+1
-1
未找到文件。
src/EditorFeatures/Core/FindUsages/AbstractFindUsagesService.ProgressAdapter.cs
浏览文件 @
bbe1d6b2
...
@@ -102,8 +102,7 @@ private async Task<DefinitionItem> GetDefinitionItemAsync(ISymbol definition)
...
@@ -102,8 +102,7 @@ private async Task<DefinitionItem> GetDefinitionItemAsync(ISymbol definition)
if
(!
_definitionToItem
.
TryGetValue
(
definition
,
out
var
definitionItem
))
if
(!
_definitionToItem
.
TryGetValue
(
definition
,
out
var
definitionItem
))
{
{
definitionItem
=
await
definition
.
ToClassifiedDefinitionItemAsync
(
definitionItem
=
await
definition
.
ToClassifiedDefinitionItemAsync
(
_solution
.
GetOriginatingProject
(
definition
),
includeHiddenLocations
:
false
,
_solution
,
includeHiddenLocations
:
false
,
_options
,
_context
.
CancellationToken
).
ConfigureAwait
(
false
);
_options
,
_context
.
CancellationToken
).
ConfigureAwait
(
false
);
_definitionToItem
[
definition
]
=
definitionItem
;
_definitionToItem
[
definition
]
=
definitionItem
;
}
}
...
...
src/EditorFeatures/Core/FindUsages/AbstractFindUsagesService.cs
浏览文件 @
bbe1d6b2
...
@@ -52,8 +52,7 @@ protected AbstractFindUsagesService(IThreadingContext threadingContext)
...
@@ -52,8 +52,7 @@ protected AbstractFindUsagesService(IThreadingContext threadingContext)
foreach
(
var
implementation
in
implementations
)
foreach
(
var
implementation
in
implementations
)
{
{
var
definitionItem
=
await
implementation
.
ToClassifiedDefinitionItemAsync
(
var
definitionItem
=
await
implementation
.
ToClassifiedDefinitionItemAsync
(
solution
.
GetOriginatingProject
(
implementation
),
includeHiddenLocations
:
false
,
solution
,
includeHiddenLocations
:
false
,
FindReferencesSearchOptions
.
Default
,
cancellationToken
).
ConfigureAwait
(
false
);
FindReferencesSearchOptions
.
Default
,
cancellationToken
).
ConfigureAwait
(
false
);
await
context
.
OnDefinitionFoundAsync
(
definitionItem
).
ConfigureAwait
(
false
);
await
context
.
OnDefinitionFoundAsync
(
definitionItem
).
ConfigureAwait
(
false
);
}
}
...
@@ -122,16 +121,16 @@ protected AbstractFindUsagesService(IThreadingContext threadingContext)
...
@@ -122,16 +121,16 @@ protected AbstractFindUsagesService(IThreadingContext threadingContext)
cancellationToken
.
ThrowIfCancellationRequested
();
cancellationToken
.
ThrowIfCancellationRequested
();
// Find the symbol we want to search and the solution we want to search in.
// Find the symbol we want to search and the solution we want to search in.
var
symbolAnd
ProjectOpt
=
await
FindUsagesHelpers
.
GetRelevantSymbolAndProject
AtPositionAsync
(
var
symbolAnd
SolutionOpt
=
await
FindUsagesHelpers
.
GetRelevantSymbolAndSolution
AtPositionAsync
(
document
,
position
,
cancellationToken
).
ConfigureAwait
(
false
);
document
,
position
,
cancellationToken
).
ConfigureAwait
(
false
);
if
(
symbolAnd
Project
Opt
==
null
)
if
(
symbolAnd
Solution
Opt
==
null
)
return
;
return
;
var
(
symbol
,
project
)
=
symbolAndProject
Opt
.
Value
;
var
(
symbol
,
solution
)
=
symbolAndSolution
Opt
.
Value
;
await
FindSymbolReferencesAsync
(
await
FindSymbolReferencesAsync
(
_threadingContext
,
context
,
_threadingContext
,
context
,
symbol
,
project
,
symbol
,
solution
,
cancellationToken
).
ConfigureAwait
(
false
);
cancellationToken
).
ConfigureAwait
(
false
);
}
}
...
@@ -141,9 +140,9 @@ protected AbstractFindUsagesService(IThreadingContext threadingContext)
...
@@ -141,9 +140,9 @@ protected AbstractFindUsagesService(IThreadingContext threadingContext)
/// </summary>
/// </summary>
public
static
async
Task
FindSymbolReferencesAsync
(
public
static
async
Task
FindSymbolReferencesAsync
(
IThreadingContext
threadingContext
,
IFindUsagesContext
context
,
IThreadingContext
threadingContext
,
IFindUsagesContext
context
,
ISymbol
symbol
,
Project
project
,
CancellationToken
cancellationToken
)
ISymbol
symbol
,
Solution
solution
,
CancellationToken
cancellationToken
)
{
{
var
monikerUsagesService
=
project
.
S
olution
.
Workspace
.
Services
.
GetRequiredService
<
IFindSymbolMonikerUsagesService
>();
var
monikerUsagesService
=
s
olution
.
Workspace
.
Services
.
GetRequiredService
<
IFindSymbolMonikerUsagesService
>();
await
context
.
SetSearchTitleAsync
(
string
.
Format
(
EditorFeaturesResources
.
_0_references
,
await
context
.
SetSearchTitleAsync
(
string
.
Format
(
EditorFeaturesResources
.
_0_references
,
FindUsagesHelpers
.
GetDisplayName
(
symbol
))).
ConfigureAwait
(
false
);
FindUsagesHelpers
.
GetDisplayName
(
symbol
))).
ConfigureAwait
(
false
);
...
@@ -154,20 +153,13 @@ protected AbstractFindUsagesService(IThreadingContext threadingContext)
...
@@ -154,20 +153,13 @@ protected AbstractFindUsagesService(IThreadingContext threadingContext)
// engine will push results into the 'progress' instance passed into it.
// engine will push results into the 'progress' instance passed into it.
// We'll take those results, massage them, and forward them along to the
// We'll take those results, massage them, and forward them along to the
// FindReferencesContext instance we were given.
// FindReferencesContext instance we were given.
var
progress
=
new
FindReferencesProgressAdapter
(
threadingContext
,
solution
,
context
,
options
);
var
normalFindReferencesTask
=
SymbolFinder
.
FindReferencesAsync
(
var
normalFindReferencesTask
=
SymbolFinder
.
FindReferencesAsync
(
symbol
,
symbol
,
solution
,
progress
,
documents
:
null
,
options
,
cancellationToken
);
project
.
Solution
,
new
FindReferencesProgressAdapter
(
threadingContext
,
project
.
Solution
,
context
,
options
),
documents
:
null
,
options
,
cancellationToken
);
// Kick off work to search the online code index system in parallel
// Kick off work to search the online code index system in parallel
var
codeIndexReferencesTask
=
FindSymbolMonikerReferencesAsync
(
var
codeIndexReferencesTask
=
FindSymbolMonikerReferencesAsync
(
monikerUsagesService
,
monikerUsagesService
,
symbol
,
context
,
cancellationToken
);
symbol
,
context
,
cancellationToken
);
await
Task
.
WhenAll
(
normalFindReferencesTask
,
codeIndexReferencesTask
).
ConfigureAwait
(
false
);
await
Task
.
WhenAll
(
normalFindReferencesTask
,
codeIndexReferencesTask
).
ConfigureAwait
(
false
);
}
}
...
...
src/EditorFeatures/Core/FindUsages/FindUsagesHelpers.cs
浏览文件 @
bbe1d6b2
...
@@ -31,7 +31,7 @@ public static string GetDisplayName(ISymbol symbol)
...
@@ -31,7 +31,7 @@ public static string GetDisplayName(ISymbol symbol)
/// there may be symbol mapping involved (for example in Metadata-As-Source
/// there may be symbol mapping involved (for example in Metadata-As-Source
/// scenarios).
/// scenarios).
/// </summary>
/// </summary>
public
static
async
Task
<(
ISymbol
symbol
,
Project
project
)?>
GetRelevantSymbolAndProject
AtPositionAsync
(
public
static
async
Task
<(
ISymbol
symbol
,
Solution
solution
)?>
GetRelevantSymbolAndSolution
AtPositionAsync
(
Document
document
,
int
position
,
CancellationToken
cancellationToken
)
Document
document
,
int
position
,
CancellationToken
cancellationToken
)
{
{
cancellationToken
.
ThrowIfCancellationRequested
();
cancellationToken
.
ThrowIfCancellationRequested
();
...
@@ -49,19 +49,19 @@ public static string GetDisplayName(ISymbol symbol)
...
@@ -49,19 +49,19 @@ public static string GetDisplayName(ISymbol symbol)
if
(
mapping
==
null
)
if
(
mapping
==
null
)
return
null
;
return
null
;
return
(
mapping
.
Symbol
,
mapping
.
Project
);
return
(
mapping
.
Symbol
,
mapping
.
Project
.
Solution
);
}
}
public
static
async
Task
<(
Solution
solution
,
ISymbol
symbol
,
ImmutableArray
<
ISymbol
>
implementations
,
string
message
)?>
FindSourceImplementationsAsync
(
Document
document
,
int
position
,
CancellationToken
cancellationToken
)
public
static
async
Task
<(
Solution
solution
,
ISymbol
symbol
,
ImmutableArray
<
ISymbol
>
implementations
,
string
message
)?>
FindSourceImplementationsAsync
(
Document
document
,
int
position
,
CancellationToken
cancellationToken
)
{
{
var
symbolAnd
ProjectOpt
=
await
GetRelevantSymbolAndProject
AtPositionAsync
(
var
symbolAnd
SolutionOpt
=
await
GetRelevantSymbolAndSolution
AtPositionAsync
(
document
,
position
,
cancellationToken
).
ConfigureAwait
(
false
);
document
,
position
,
cancellationToken
).
ConfigureAwait
(
false
);
if
(
symbolAnd
Project
Opt
==
null
)
if
(
symbolAnd
Solution
Opt
==
null
)
return
null
;
return
null
;
var
(
symbol
,
project
)
=
symbolAndProject
Opt
.
Value
;
var
(
symbol
,
solution
)
=
symbolAndSolution
Opt
.
Value
;
return
await
FindSourceImplementationsAsync
(
return
await
FindSourceImplementationsAsync
(
project
.
S
olution
,
symbol
,
cancellationToken
).
ConfigureAwait
(
false
);
s
olution
,
symbol
,
cancellationToken
).
ConfigureAwait
(
false
);
}
}
private
static
async
Task
<(
Solution
solution
,
ISymbol
symbol
,
ImmutableArray
<
ISymbol
>
implementations
,
string
message
)?>
FindSourceImplementationsAsync
(
private
static
async
Task
<(
Solution
solution
,
ISymbol
symbol
,
ImmutableArray
<
ISymbol
>
implementations
,
string
message
)?>
FindSourceImplementationsAsync
(
...
...
src/EditorFeatures/Core/FindUsages/IDefinitionsAndReferencesFactory.cs
浏览文件 @
bbe1d6b2
...
@@ -53,7 +53,7 @@ internal static class DefinitionItemExtensions
...
@@ -53,7 +53,7 @@ internal static class DefinitionItemExtensions
{
{
public
static
DefinitionItem
ToNonClassifiedDefinitionItem
(
public
static
DefinitionItem
ToNonClassifiedDefinitionItem
(
this
ISymbol
definition
,
this
ISymbol
definition
,
Project
project
,
Solution
solution
,
bool
includeHiddenLocations
)
bool
includeHiddenLocations
)
{
{
// Because we're passing in 'false' for 'includeClassifiedSpans', this won't ever have
// Because we're passing in 'false' for 'includeClassifiedSpans', this won't ever have
...
@@ -61,25 +61,25 @@ internal static class DefinitionItemExtensions
...
@@ -61,25 +61,25 @@ internal static class DefinitionItemExtensions
// to compute the classified spans for the locations of the definition. So it's totally
// to compute the classified spans for the locations of the definition. So it's totally
// fine to pass in CancellationToken.None and block on the result.
// fine to pass in CancellationToken.None and block on the result.
return
ToDefinitionItemAsync
(
return
ToDefinitionItemAsync
(
definition
,
project
,
includeHiddenLocations
,
includeClassifiedSpans
:
false
,
definition
,
solution
,
includeHiddenLocations
,
includeClassifiedSpans
:
false
,
options
:
FindReferencesSearchOptions
.
Default
,
cancellationToken
:
CancellationToken
.
None
).
WaitAndGetResult_CanCallOnBackground
(
CancellationToken
.
None
);
options
:
FindReferencesSearchOptions
.
Default
,
cancellationToken
:
CancellationToken
.
None
).
WaitAndGetResult_CanCallOnBackground
(
CancellationToken
.
None
);
}
}
public
static
Task
<
DefinitionItem
>
ToClassifiedDefinitionItemAsync
(
public
static
Task
<
DefinitionItem
>
ToClassifiedDefinitionItemAsync
(
this
ISymbol
definition
,
this
ISymbol
definition
,
Project
project
,
Solution
solution
,
bool
includeHiddenLocations
,
bool
includeHiddenLocations
,
FindReferencesSearchOptions
options
,
FindReferencesSearchOptions
options
,
CancellationToken
cancellationToken
)
CancellationToken
cancellationToken
)
{
{
return
ToDefinitionItemAsync
(
definition
,
project
,
return
ToDefinitionItemAsync
(
definition
,
solution
,
includeHiddenLocations
,
includeClassifiedSpans
:
true
,
includeHiddenLocations
,
includeClassifiedSpans
:
true
,
options
,
cancellationToken
);
options
,
cancellationToken
);
}
}
private
static
async
Task
<
DefinitionItem
>
ToDefinitionItemAsync
(
private
static
async
Task
<
DefinitionItem
>
ToDefinitionItemAsync
(
this
ISymbol
definition
,
this
ISymbol
definition
,
Project
project
,
Solution
solution
,
bool
includeHiddenLocations
,
bool
includeHiddenLocations
,
bool
includeClassifiedSpans
,
bool
includeClassifiedSpans
,
FindReferencesSearchOptions
options
,
FindReferencesSearchOptions
options
,
...
@@ -121,7 +121,7 @@ internal static class DefinitionItemExtensions
...
@@ -121,7 +121,7 @@ internal static class DefinitionItemExtensions
if
(
location
.
IsInMetadata
)
if
(
location
.
IsInMetadata
)
{
{
return
DefinitionItem
.
CreateMetadataDefinition
(
return
DefinitionItem
.
CreateMetadataDefinition
(
tags
,
displayParts
,
nameDisplayParts
,
project
,
tags
,
displayParts
,
nameDisplayParts
,
solution
,
definition
,
properties
,
displayIfNoReferences
);
definition
,
properties
,
displayIfNoReferences
);
}
}
else
if
(
location
.
IsInSource
)
else
if
(
location
.
IsInSource
)
...
@@ -132,7 +132,7 @@ internal static class DefinitionItemExtensions
...
@@ -132,7 +132,7 @@ internal static class DefinitionItemExtensions
continue
;
continue
;
}
}
var
document
=
project
.
S
olution
.
GetDocument
(
location
.
SourceTree
);
var
document
=
s
olution
.
GetDocument
(
location
.
SourceTree
);
if
(
document
!=
null
)
if
(
document
!=
null
)
{
{
var
documentLocation
=
!
includeClassifiedSpans
var
documentLocation
=
!
includeClassifiedSpans
...
...
src/EditorFeatures/Core/GoToBase/AbstractGoToBaseService.cs
浏览文件 @
bbe1d6b2
...
@@ -16,21 +16,20 @@ internal abstract partial class AbstractGoToBaseService : IGoToBaseService
...
@@ -16,21 +16,20 @@ internal abstract partial class AbstractGoToBaseService : IGoToBaseService
public
async
Task
FindBasesAsync
(
Document
document
,
int
position
,
IFindUsagesContext
context
)
public
async
Task
FindBasesAsync
(
Document
document
,
int
position
,
IFindUsagesContext
context
)
{
{
var
cancellationToken
=
context
.
CancellationToken
;
var
cancellationToken
=
context
.
CancellationToken
;
var
symbolAnd
ProjectOpt
=
await
FindUsagesHelpers
.
GetRelevantSymbolAndProject
AtPositionAsync
(
var
symbolAnd
SolutionOpt
=
await
FindUsagesHelpers
.
GetRelevantSymbolAndSolution
AtPositionAsync
(
document
,
position
,
cancellationToken
).
ConfigureAwait
(
false
);
document
,
position
,
cancellationToken
).
ConfigureAwait
(
false
);
if
(
symbolAnd
Project
Opt
==
null
)
if
(
symbolAnd
Solution
Opt
==
null
)
{
{
await
context
.
ReportMessageAsync
(
await
context
.
ReportMessageAsync
(
EditorFeaturesResources
.
Cannot_navigate_to_the_symbol_under_the_caret
).
ConfigureAwait
(
false
);
EditorFeaturesResources
.
Cannot_navigate_to_the_symbol_under_the_caret
).
ConfigureAwait
(
false
);
return
;
return
;
}
}
var
(
symbol
,
project
)
=
symbolAndProjectOpt
.
Value
;
var
(
symbol
,
solution
)
=
symbolAndSolutionOpt
.
Value
;
var
solution
=
project
.
Solution
;
var
bases
=
FindBaseHelpers
.
FindBases
(
var
bases
=
FindBaseHelpers
.
FindBases
(
symbol
,
project
,
cancellationToken
);
symbol
,
solution
,
cancellationToken
);
await
context
.
SetSearchTitleAsync
(
await
context
.
SetSearchTitleAsync
(
string
.
Format
(
EditorFeaturesResources
.
_0_bases
,
string
.
Format
(
EditorFeaturesResources
.
_0_bases
,
...
@@ -48,8 +47,7 @@ public async Task FindBasesAsync(Document document, int position, IFindUsagesCon
...
@@ -48,8 +47,7 @@ public async Task FindBasesAsync(Document document, int position, IFindUsagesCon
if
(
sourceDefinition
!=
null
)
if
(
sourceDefinition
!=
null
)
{
{
var
definitionItem
=
await
sourceDefinition
.
ToClassifiedDefinitionItemAsync
(
var
definitionItem
=
await
sourceDefinition
.
ToClassifiedDefinitionItemAsync
(
solution
.
GetOriginatingProject
(
sourceDefinition
),
includeHiddenLocations
:
false
,
solution
,
includeHiddenLocations
:
false
,
FindReferencesSearchOptions
.
Default
,
cancellationToken
:
cancellationToken
).
ConfigureAwait
(
false
);
FindReferencesSearchOptions
.
Default
,
cancellationToken
:
cancellationToken
).
ConfigureAwait
(
false
);
await
context
.
OnDefinitionFoundAsync
(
definitionItem
).
ConfigureAwait
(
false
);
await
context
.
OnDefinitionFoundAsync
(
definitionItem
).
ConfigureAwait
(
false
);
found
=
true
;
found
=
true
;
...
@@ -57,7 +55,7 @@ public async Task FindBasesAsync(Document document, int position, IFindUsagesCon
...
@@ -57,7 +55,7 @@ public async Task FindBasesAsync(Document document, int position, IFindUsagesCon
else
if
(
baseSymbol
.
Locations
.
Any
(
l
=>
l
.
IsInMetadata
))
else
if
(
baseSymbol
.
Locations
.
Any
(
l
=>
l
.
IsInMetadata
))
{
{
var
definitionItem
=
baseSymbol
.
ToNonClassifiedDefinitionItem
(
var
definitionItem
=
baseSymbol
.
ToNonClassifiedDefinitionItem
(
project
,
includeHiddenLocations
:
true
);
solution
,
includeHiddenLocations
:
true
);
await
context
.
OnDefinitionFoundAsync
(
definitionItem
).
ConfigureAwait
(
false
);
await
context
.
OnDefinitionFoundAsync
(
definitionItem
).
ConfigureAwait
(
false
);
found
=
true
;
found
=
true
;
}
}
...
...
src/EditorFeatures/Core/GoToBase/FindBaseHelpers.cs
浏览文件 @
bbe1d6b2
...
@@ -11,7 +11,7 @@ namespace Microsoft.CodeAnalysis.Editor.GoToBase
...
@@ -11,7 +11,7 @@ namespace Microsoft.CodeAnalysis.Editor.GoToBase
internal
static
class
FindBaseHelpers
internal
static
class
FindBaseHelpers
{
{
public
static
ImmutableArray
<
ISymbol
>
FindBases
(
public
static
ImmutableArray
<
ISymbol
>
FindBases
(
ISymbol
symbol
,
Project
project
,
CancellationToken
cancellationToken
)
ISymbol
symbol
,
Solution
solution
,
CancellationToken
cancellationToken
)
{
{
if
(
symbol
is
INamedTypeSymbol
namedTypeSymbol
&&
if
(
symbol
is
INamedTypeSymbol
namedTypeSymbol
&&
(
namedTypeSymbol
.
TypeKind
==
TypeKind
.
Class
||
(
namedTypeSymbol
.
TypeKind
==
TypeKind
.
Class
||
...
@@ -24,8 +24,7 @@ internal static class FindBaseHelpers
...
@@ -24,8 +24,7 @@ internal static class FindBaseHelpers
symbol
.
Kind
==
SymbolKind
.
Method
||
symbol
.
Kind
==
SymbolKind
.
Method
||
symbol
.
Kind
==
SymbolKind
.
Event
)
symbol
.
Kind
==
SymbolKind
.
Event
)
{
{
return
BaseTypeFinder
.
FindOverriddenAndImplementedMembers
(
return
BaseTypeFinder
.
FindOverriddenAndImplementedMembers
(
symbol
,
solution
,
cancellationToken
);
symbol
,
project
,
cancellationToken
);
}
}
else
else
{
{
...
...
src/EditorFeatures/Core/GoToDefinition/AbstractGoToDefinitionService.cs
浏览文件 @
bbe1d6b2
...
@@ -63,7 +63,7 @@ public bool TryGoToDefinition(Document document, int position, CancellationToken
...
@@ -63,7 +63,7 @@ public bool TryGoToDefinition(Document document, int position, CancellationToken
var
isThirdPartyNavigationAllowed
=
IsThirdPartyNavigationAllowed
(
symbol
,
position
,
document
,
cancellationToken
);
var
isThirdPartyNavigationAllowed
=
IsThirdPartyNavigationAllowed
(
symbol
,
position
,
document
,
cancellationToken
);
return
GoToDefinitionHelpers
.
TryGoToDefinition
(
symbol
,
return
GoToDefinitionHelpers
.
TryGoToDefinition
(
symbol
,
document
.
Project
,
document
.
Project
.
Solution
,
_streamingPresenter
.
Value
,
_streamingPresenter
.
Value
,
thirdPartyNavigationAllowed
:
isThirdPartyNavigationAllowed
,
thirdPartyNavigationAllowed
:
isThirdPartyNavigationAllowed
,
cancellationToken
:
cancellationToken
);
cancellationToken
:
cancellationToken
);
...
@@ -100,7 +100,7 @@ public bool TryGoToDefinition(Document document, int position, CancellationToken
...
@@ -100,7 +100,7 @@ public bool TryGoToDefinition(Document document, int position, CancellationToken
var
definitions
=
interfaceImpls
.
SelectMany
(
var
definitions
=
interfaceImpls
.
SelectMany
(
i
=>
GoToDefinitionHelpers
.
GetDefinitions
(
i
=>
GoToDefinitionHelpers
.
GetDefinitions
(
i
,
project
,
thirdPartyNavigationAllowed
:
false
,
cancellationToken
)).
ToImmutableArray
();
i
,
solution
,
thirdPartyNavigationAllowed
:
false
,
cancellationToken
)).
ToImmutableArray
();
var
title
=
string
.
Format
(
EditorFeaturesResources
.
_0_implemented_members
,
var
title
=
string
.
Format
(
EditorFeaturesResources
.
_0_implemented_members
,
FindUsagesHelpers
.
GetDisplayName
(
symbol
));
FindUsagesHelpers
.
GetDisplayName
(
symbol
));
...
...
src/EditorFeatures/Core/GoToDefinition/AbstractGoToSymbolService.cs
浏览文件 @
bbe1d6b2
...
@@ -40,8 +40,9 @@ public async Task GetSymbolsAsync(GoToSymbolContext context)
...
@@ -40,8 +40,9 @@ public async Task GetSymbolsAsync(GoToSymbolContext context)
await
ThreadingContext
.
JoinableTaskFactory
.
SwitchToMainThreadAsync
(
alwaysYield
:
true
,
cancellationToken
);
await
ThreadingContext
.
JoinableTaskFactory
.
SwitchToMainThreadAsync
(
alwaysYield
:
true
,
cancellationToken
);
cancellationToken
.
ThrowIfCancellationRequested
();
cancellationToken
.
ThrowIfCancellationRequested
();
var
definitions
=
GoToDefinitionHelpers
.
GetDefinitions
(
symbol
,
document
.
Project
,
thirdPartyNavigationAllowed
:
true
,
cancellationToken
)
var
solution
=
document
.
Project
.
Solution
;
.
WhereAsArray
(
d
=>
d
.
CanNavigateTo
(
document
.
Project
.
Solution
.
Workspace
));
var
definitions
=
GoToDefinitionHelpers
.
GetDefinitions
(
symbol
,
solution
,
thirdPartyNavigationAllowed
:
true
,
cancellationToken
)
.
WhereAsArray
(
d
=>
d
.
CanNavigateTo
(
solution
.
Workspace
));
await
TaskScheduler
.
Default
;
await
TaskScheduler
.
Default
;
...
...
src/EditorFeatures/Core/GoToDefinition/GoToDefinitionHelpers.cs
浏览文件 @
bbe1d6b2
...
@@ -20,7 +20,7 @@ internal static class GoToDefinitionHelpers
...
@@ -20,7 +20,7 @@ internal static class GoToDefinitionHelpers
{
{
public
static
ImmutableArray
<
DefinitionItem
>
GetDefinitions
(
public
static
ImmutableArray
<
DefinitionItem
>
GetDefinitions
(
ISymbol
symbol
,
ISymbol
symbol
,
Project
project
,
Solution
solution
,
bool
thirdPartyNavigationAllowed
,
bool
thirdPartyNavigationAllowed
,
CancellationToken
cancellationToken
)
CancellationToken
cancellationToken
)
{
{
...
@@ -36,13 +36,12 @@ internal static class GoToDefinitionHelpers
...
@@ -36,13 +36,12 @@ internal static class GoToDefinitionHelpers
// VB global import aliases have a synthesized SyntaxTree.
// VB global import aliases have a synthesized SyntaxTree.
// We can't go to the definition of the alias, so use the target type.
// We can't go to the definition of the alias, so use the target type.
var
solution
=
project
.
Solution
;
if
(
alias
!=
null
)
if
(
alias
!=
null
)
{
{
var
sourceLocations
=
NavigableItemFactory
.
GetPreferredSourceLocations
(
var
sourceLocations
=
NavigableItemFactory
.
GetPreferredSourceLocations
(
solution
,
symbol
,
cancellationToken
);
solution
,
symbol
,
cancellationToken
);
if
(
sourceLocations
.
All
(
l
=>
project
.
S
olution
.
GetDocument
(
l
.
SourceTree
)
==
null
))
if
(
sourceLocations
.
All
(
l
=>
s
olution
.
GetDocument
(
l
.
SourceTree
)
==
null
))
{
{
symbol
=
alias
.
Target
;
symbol
=
alias
.
Target
;
}
}
...
@@ -81,7 +80,7 @@ internal static class GoToDefinitionHelpers
...
@@ -81,7 +80,7 @@ internal static class GoToDefinitionHelpers
// So, if we only have a single location to go to, this does no unnecessary work. And,
// So, if we only have a single location to go to, this does no unnecessary work. And,
// if we do have multiple locations to show, it will just be done in the BG, unblocking
// if we do have multiple locations to show, it will just be done in the BG, unblocking
// this command thread so it can return the user faster.
// this command thread so it can return the user faster.
var
definitionItem
=
symbol
.
ToNonClassifiedDefinitionItem
(
project
,
includeHiddenLocations
:
true
);
var
definitionItem
=
symbol
.
ToNonClassifiedDefinitionItem
(
solution
,
includeHiddenLocations
:
true
);
if
(
thirdPartyNavigationAllowed
)
if
(
thirdPartyNavigationAllowed
)
{
{
...
@@ -96,23 +95,23 @@ internal static class GoToDefinitionHelpers
...
@@ -96,23 +95,23 @@ internal static class GoToDefinitionHelpers
public
static
bool
TryGoToDefinition
(
public
static
bool
TryGoToDefinition
(
ISymbol
symbol
,
ISymbol
symbol
,
Project
project
,
Solution
solution
,
IStreamingFindUsagesPresenter
streamingPresenter
,
IStreamingFindUsagesPresenter
streamingPresenter
,
CancellationToken
cancellationToken
,
CancellationToken
cancellationToken
,
bool
thirdPartyNavigationAllowed
=
true
)
bool
thirdPartyNavigationAllowed
=
true
)
{
{
var
definitions
=
GetDefinitions
(
symbol
,
project
,
thirdPartyNavigationAllowed
,
cancellationToken
);
var
definitions
=
GetDefinitions
(
symbol
,
solution
,
thirdPartyNavigationAllowed
,
cancellationToken
);
var
title
=
string
.
Format
(
EditorFeaturesResources
.
_0_declarations
,
var
title
=
string
.
Format
(
EditorFeaturesResources
.
_0_declarations
,
FindUsagesHelpers
.
GetDisplayName
(
symbol
));
FindUsagesHelpers
.
GetDisplayName
(
symbol
));
return
streamingPresenter
.
TryNavigateToOrPresentItemsAsync
(
return
streamingPresenter
.
TryNavigateToOrPresentItemsAsync
(
project
.
S
olution
.
Workspace
,
title
,
definitions
).
WaitAndGetResult
(
cancellationToken
);
s
olution
.
Workspace
,
title
,
definitions
).
WaitAndGetResult
(
cancellationToken
);
}
}
public
static
bool
TryGoToDefinition
(
public
static
bool
TryGoToDefinition
(
ImmutableArray
<
DefinitionItem
>
definitions
,
ImmutableArray
<
DefinitionItem
>
definitions
,
Project
project
,
Solution
solution
,
string
title
,
string
title
,
IStreamingFindUsagesPresenter
streamingPresenter
,
IStreamingFindUsagesPresenter
streamingPresenter
,
CancellationToken
cancellationToken
)
CancellationToken
cancellationToken
)
...
@@ -123,7 +122,7 @@ internal static class GoToDefinitionHelpers
...
@@ -123,7 +122,7 @@ internal static class GoToDefinitionHelpers
}
}
return
streamingPresenter
.
TryNavigateToOrPresentItemsAsync
(
return
streamingPresenter
.
TryNavigateToOrPresentItemsAsync
(
project
.
S
olution
.
Workspace
,
title
,
definitions
).
WaitAndGetResult
(
cancellationToken
);
s
olution
.
Workspace
,
title
,
definitions
).
WaitAndGetResult
(
cancellationToken
);
}
}
}
}
}
}
src/EditorFeatures/Core/Implementation/IntelliSense/Helpers.cs
浏览文件 @
bbe1d6b2
...
@@ -168,7 +168,7 @@ private static void NavigateToQuickInfoTarget(string navigationTarget, Document
...
@@ -168,7 +168,7 @@ private static void NavigateToQuickInfoTarget(string navigationTarget, Document
if
(
resolvedSymbolKey
.
GetAnySymbol
()
is
{
}
symbol
)
if
(
resolvedSymbolKey
.
GetAnySymbol
()
is
{
}
symbol
)
{
{
GoToDefinitionHelpers
.
TryGoToDefinition
(
symbol
,
document
.
Project
,
streamingPresenter
,
CancellationToken
.
None
);
GoToDefinitionHelpers
.
TryGoToDefinition
(
symbol
,
document
.
Project
.
Solution
,
streamingPresenter
,
CancellationToken
.
None
);
return
;
return
;
}
}
}
}
...
...
src/EditorFeatures/Core/Implementation/Peek/PeekableItemFactory.cs
浏览文件 @
bbe1d6b2
...
@@ -62,7 +62,7 @@ public PeekableItemFactory(IMetadataAsSourceFileService metadataAsSourceFileServ
...
@@ -62,7 +62,7 @@ public PeekableItemFactory(IMetadataAsSourceFileService metadataAsSourceFileServ
}
}
var
symbolNavigationService
=
solution
.
Workspace
.
Services
.
GetService
<
ISymbolNavigationService
>();
var
symbolNavigationService
=
solution
.
Workspace
.
Services
.
GetService
<
ISymbolNavigationService
>();
var
definitionItem
=
symbol
.
ToNonClassifiedDefinitionItem
(
project
,
includeHiddenLocations
:
true
);
var
definitionItem
=
symbol
.
ToNonClassifiedDefinitionItem
(
solution
,
includeHiddenLocations
:
true
);
if
(
symbolNavigationService
.
WouldNavigateToSymbol
(
if
(
symbolNavigationService
.
WouldNavigateToSymbol
(
definitionItem
,
solution
,
cancellationToken
,
definitionItem
,
solution
,
cancellationToken
,
...
...
src/EditorFeatures/Core/NavigableSymbols/NavigableSymbolService.NavigableSymbol.cs
浏览文件 @
bbe1d6b2
...
@@ -52,7 +52,7 @@ private class NavigableSymbol : INavigableSymbol
...
@@ -52,7 +52,7 @@ private class NavigableSymbol : INavigableSymbol
showProgress
:
false
,
showProgress
:
false
,
action
:
context
=>
GoToDefinitionHelpers
.
TryGoToDefinition
(
action
:
context
=>
GoToDefinitionHelpers
.
TryGoToDefinition
(
_definitions
,
_definitions
,
_document
.
Project
,
_document
.
Project
.
Solution
,
_definitions
[
0
].
NameDisplayParts
.
GetFullText
(),
_definitions
[
0
].
NameDisplayParts
.
GetFullText
(),
_presenter
,
_presenter
,
context
.
CancellationToken
)
context
.
CancellationToken
)
...
...
src/Features/Core/Portable/FindUsages/DefinitionItem.cs
浏览文件 @
bbe1d6b2
...
@@ -213,7 +213,7 @@ internal abstract partial class DefinitionItem
...
@@ -213,7 +213,7 @@ internal abstract partial class DefinitionItem
ImmutableArray
<
string
>
tags
,
ImmutableArray
<
string
>
tags
,
ImmutableArray
<
TaggedText
>
displayParts
,
ImmutableArray
<
TaggedText
>
displayParts
,
ImmutableArray
<
TaggedText
>
nameDisplayParts
,
ImmutableArray
<
TaggedText
>
nameDisplayParts
,
Project
project
,
Solution
solution
,
ISymbol
symbol
,
ISymbol
symbol
,
ImmutableDictionary
<
string
,
string
>
properties
=
null
,
ImmutableDictionary
<
string
,
string
>
properties
=
null
,
bool
displayIfNoReferences
=
true
)
bool
displayIfNoReferences
=
true
)
...
@@ -222,9 +222,12 @@ internal abstract partial class DefinitionItem
...
@@ -222,9 +222,12 @@ internal abstract partial class DefinitionItem
var
symbolKey
=
symbol
.
GetSymbolKey
().
ToString
();
var
symbolKey
=
symbol
.
GetSymbolKey
().
ToString
();
var
projectId
=
solution
.
GetOriginatingProjectId
(
symbol
);
Contract
.
ThrowIfNull
(
projectId
);
properties
=
properties
.
Add
(
MetadataSymbolKey
,
symbolKey
)
properties
=
properties
.
Add
(
MetadataSymbolKey
,
symbolKey
)
.
Add
(
MetadataSymbolOriginatingProjectIdGuid
,
project
.
Id
.
Id
.
ToString
())
.
Add
(
MetadataSymbolOriginatingProjectIdGuid
,
projectId
.
Id
.
ToString
())
.
Add
(
MetadataSymbolOriginatingProjectIdDebugName
,
project
.
Id
.
DebugName
);
.
Add
(
MetadataSymbolOriginatingProjectIdDebugName
,
projectId
.
DebugName
);
var
originationParts
=
GetOriginationParts
(
symbol
);
var
originationParts
=
GetOriginationParts
(
symbol
);
return
new
DefaultDefinitionItem
(
return
new
DefaultDefinitionItem
(
...
...
src/Tools/ExternalAccess/Debugger/DebuggerFindReferencesService.cs
浏览文件 @
bbe1d6b2
...
@@ -39,7 +39,8 @@ public async Task FindSymbolReferencesAsync(ISymbol symbol, Project project, Can
...
@@ -39,7 +39,8 @@ 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
,
context
,
symbol
,
project
.
Solution
,
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/Library/ObjectBrowser/AbstractObjectBrowserLibraryManager.cs
浏览文件 @
bbe1d6b2
...
@@ -553,8 +553,7 @@ private static async Task FindReferencesAsync(IThreadingContext threadingContext
...
@@ -553,8 +553,7 @@ private static async Task FindReferencesAsync(IThreadingContext threadingContext
if
(
symbol
!=
null
)
if
(
symbol
!=
null
)
{
{
await
AbstractFindUsagesService
.
FindSymbolReferencesAsync
(
await
AbstractFindUsagesService
.
FindSymbolReferencesAsync
(
threadingContext
,
threadingContext
,
context
,
symbol
,
project
.
Solution
,
cancellationToken
).
ConfigureAwait
(
false
);
context
,
symbol
,
project
,
cancellationToken
).
ConfigureAwait
(
false
);
}
}
}
}
}
}
...
...
src/VisualStudio/Core/Def/Implementation/Workspace/VisualStudioSymbolNavigationService.cs
浏览文件 @
bbe1d6b2
...
@@ -178,14 +178,14 @@ public bool TryNavigateToSymbol(ISymbol symbol, Project project, OptionSet optio
...
@@ -178,14 +178,14 @@ public bool TryNavigateToSymbol(ISymbol symbol, Project project, OptionSet optio
}
}
public
bool
TrySymbolNavigationNotify
(
ISymbol
symbol
,
Project
project
,
CancellationToken
cancellationToken
)
public
bool
TrySymbolNavigationNotify
(
ISymbol
symbol
,
Project
project
,
CancellationToken
cancellationToken
)
=>
TryNotifyForSpecificSymbol
(
symbol
,
project
,
cancellationToken
);
=>
TryNotifyForSpecificSymbol
(
symbol
,
project
.
Solution
,
cancellationToken
);
private
bool
TryNotifyForSpecificSymbol
(
private
bool
TryNotifyForSpecificSymbol
(
ISymbol
symbol
,
Project
project
,
CancellationToken
cancellationToken
)
ISymbol
symbol
,
Solution
solution
,
CancellationToken
cancellationToken
)
{
{
AssertIsForeground
();
AssertIsForeground
();
var
definitionItem
=
symbol
.
ToNonClassifiedDefinitionItem
(
project
,
includeHiddenLocations
:
true
);
var
definitionItem
=
symbol
.
ToNonClassifiedDefinitionItem
(
solution
,
includeHiddenLocations
:
true
);
definitionItem
.
Properties
.
TryGetValue
(
DefinitionItem
.
RQNameKey1
,
out
var
rqName
);
definitionItem
.
Properties
.
TryGetValue
(
DefinitionItem
.
RQNameKey1
,
out
var
rqName
);
if
(!
TryGetNavigationAPIRequiredArguments
(
if
(!
TryGetNavigationAPIRequiredArguments
(
...
...
src/VisualStudio/Core/Impl/RoslynVisualStudioWorkspace.cs
浏览文件 @
bbe1d6b2
...
@@ -122,7 +122,7 @@ internal override IInvisibleEditor OpenInvisibleEditor(DocumentId documentId)
...
@@ -122,7 +122,7 @@ internal override IInvisibleEditor OpenInvisibleEditor(DocumentId documentId)
}
}
return
GoToDefinitionHelpers
.
TryGoToDefinition
(
return
GoToDefinitionHelpers
.
TryGoToDefinition
(
searchSymbol
,
searchProject
,
searchSymbol
,
searchProject
.
Solution
,
_streamingPresenter
.
Value
,
cancellationToken
);
_streamingPresenter
.
Value
,
cancellationToken
);
}
}
...
...
src/Workspaces/Core/Portable/FindSymbols/FindReferences/BaseTypeFinder.cs
浏览文件 @
bbe1d6b2
...
@@ -15,9 +15,8 @@ public static ImmutableArray<ISymbol> FindBaseTypesAndInterfaces(INamedTypeSymbo
...
@@ -15,9 +15,8 @@ public static ImmutableArray<ISymbol> FindBaseTypesAndInterfaces(INamedTypeSymbo
=>
FindBaseTypes
(
type
).
AddRange
(
type
.
AllInterfaces
).
CastArray
<
ISymbol
>();
=>
FindBaseTypes
(
type
).
AddRange
(
type
.
AllInterfaces
).
CastArray
<
ISymbol
>();
public
static
ImmutableArray
<
ISymbol
>
FindOverriddenAndImplementedMembers
(
public
static
ImmutableArray
<
ISymbol
>
FindOverriddenAndImplementedMembers
(
ISymbol
symbol
,
Project
project
,
CancellationToken
cancellationToken
)
ISymbol
symbol
,
Solution
solution
,
CancellationToken
cancellationToken
)
{
{
var
solution
=
project
.
Solution
;
var
results
=
ArrayBuilder
<
ISymbol
>.
GetInstance
();
var
results
=
ArrayBuilder
<
ISymbol
>.
GetInstance
();
// This is called for all: class, struct or interface member.
// This is called for all: class, struct or interface member.
...
...
src/Workspaces/CoreTest/FindReferencesTests.cs
浏览文件 @
bbe1d6b2
...
@@ -325,7 +325,7 @@ public System.Uri Get()
...
@@ -325,7 +325,7 @@ public System.Uri Get()
var
projectIds
=
new
HashSet
<
ProjectId
>();
var
projectIds
=
new
HashSet
<
ProjectId
>();
foreach
(
var
r
in
references
)
foreach
(
var
r
in
references
)
projectIds
.
Add
(
solution
.
Get
Exact
ProjectId
(
r
.
Definition
));
projectIds
.
Add
(
solution
.
Get
Originating
ProjectId
(
r
.
Definition
));
Assert
.
True
(
projectIds
.
Contains
(
desktopProject
.
Id
));
Assert
.
True
(
projectIds
.
Contains
(
desktopProject
.
Id
));
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录