Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
62d25585
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,发现更多精彩内容 >>
提交
62d25585
编写于
7月 22, 2018
作者:
C
Cyrus Najmabadi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Prioritize NavigateTo searches to care most about the current active doc/project.
上级
fcf5fd8a
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
61 addition
and
29 deletion
+61
-29
src/EditorFeatures/Core.Wpf/NavigateTo/NavigateToItemProvider.Searcher.cs
...es/Core.Wpf/NavigateTo/NavigateToItemProvider.Searcher.cs
+30
-8
src/Features/Core/Portable/NavigateTo/AbstractNavigateToSearchService.InProcess.cs
...e/NavigateTo/AbstractNavigateToSearchService.InProcess.cs
+20
-12
src/Features/Core/Portable/NavigateTo/AbstractNavigateToSearchService.Remote.cs
...able/NavigateTo/AbstractNavigateToSearchService.Remote.cs
+2
-2
src/Features/Core/Portable/NavigateTo/AbstractNavigateToSearchService.cs
...re/Portable/NavigateTo/AbstractNavigateToSearchService.cs
+3
-3
src/Features/Core/Portable/NavigateTo/INavigateToSearchService.cs
...ures/Core/Portable/NavigateTo/INavigateToSearchService.cs
+1
-1
src/Features/Core/Portable/NavigateTo/IRemoteNavigateToSearchService.cs
...ore/Portable/NavigateTo/IRemoteNavigateToSearchService.cs
+1
-1
src/Workspaces/Remote/ServiceHub/Services/CodeAnalysisService_NavigateTo.cs
...ote/ServiceHub/Services/CodeAnalysisService_NavigateTo.cs
+4
-2
未找到文件。
src/EditorFeatures/Core.Wpf/NavigateTo/NavigateToItemProvider.Searcher.cs
浏览文件 @
62d25585
...
...
@@ -68,11 +68,33 @@ internal async void Search()
{
_progress
.
AddItems
(
_solution
.
Projects
.
Count
());
// Search each project with an independent threadpool task.
var
searchTasks
=
_solution
.
Projects
.
Select
(
p
=>
Task
.
Run
(()
=>
SearchAsync
(
p
),
_cancellationToken
)).
ToArray
();
var
workspace
=
_solution
.
Workspace
;
var
docTrackingService
=
workspace
.
Services
.
GetService
<
IDocumentTrackingService
>();
var
activeDocIdOpt
=
docTrackingService
?.
GetActiveDocument
();
var
activeDocumentOpt
=
_solution
.
GetDocument
(
activeDocIdOpt
);
await
Task
.
WhenAll
(
searchTasks
).
ConfigureAwait
(
false
);
if
(
activeDocumentOpt
!=
null
)
{
var
activeProject
=
activeDocumentOpt
.
Project
;
// Search the current project first. That way we can deliver
// results that are closer in scope to the user quicker without
// forcing them to do something like NavToInCurrentDoc
await
Task
.
Run
(()
=>
SearchAsync
(
activeProject
,
activeDocumentOpt
),
_cancellationToken
).
ConfigureAwait
(
false
);
var
searchTasks
=
_solution
.
Projects
.
Where
(
p
=>
p
!=
activeProject
)
.
Select
(
p
=>
Task
.
Run
(()
=>
SearchAsync
(
p
,
activeDocumentOpt
:
null
),
_cancellationToken
)).
ToArray
();
await
Task
.
WhenAll
(
searchTasks
).
ConfigureAwait
(
false
);
}
else
{
// Search each project with an independent threadpool task.
var
searchTasks
=
_solution
.
Projects
.
Select
(
p
=>
Task
.
Run
(()
=>
SearchAsync
(
p
,
activeDocumentOpt
:
null
),
_cancellationToken
)).
ToArray
();
await
Task
.
WhenAll
(
searchTasks
).
ConfigureAwait
(
false
);
}
}
}
catch
(
OperationCanceledException
)
...
...
@@ -84,11 +106,11 @@ internal async void Search()
}
}
private
async
Task
SearchAsync
(
Project
project
)
private
async
Task
SearchAsync
(
Project
project
,
Document
activeDocumentOpt
)
{
try
{
await
SearchAsyncWorker
(
project
).
ConfigureAwait
(
false
);
await
SearchAsyncWorker
(
project
,
activeDocumentOpt
).
ConfigureAwait
(
false
);
}
finally
{
...
...
@@ -96,7 +118,7 @@ private async Task SearchAsync(Project project)
}
}
private
async
Task
SearchAsyncWorker
(
Project
project
)
private
async
Task
SearchAsyncWorker
(
Project
project
,
Document
activeDocumentOpt
)
{
if
(
_searchCurrentDocument
&&
_currentDocument
?.
Project
!=
project
)
{
...
...
@@ -113,7 +135,7 @@ private async Task SearchAsyncWorker(Project project)
{
var
searchTask
=
_currentDocument
!=
null
?
service
.
SearchDocumentAsync
(
_currentDocument
,
_searchPattern
,
_kinds
,
_cancellationToken
)
:
service
.
SearchProjectAsync
(
project
,
_searchPattern
,
_kinds
,
_cancellationToken
);
:
service
.
SearchProjectAsync
(
project
,
activeDocumentOpt
,
_searchPattern
,
_kinds
,
_cancellationToken
);
var
results
=
await
searchTask
.
ConfigureAwait
(
false
);
if
(
results
!=
null
)
...
...
src/Features/Core/Portable/NavigateTo/AbstractNavigateToSearchService.InProcess.cs
浏览文件 @
62d25585
...
...
@@ -4,6 +4,7 @@
using
System.Collections.Generic
;
using
System.Collections.Immutable
;
using
System.Diagnostics
;
using
System.Linq
;
using
System.Runtime.CompilerServices
;
using
System.Threading
;
using
System.Threading.Tasks
;
...
...
@@ -23,21 +24,22 @@ internal abstract partial class AbstractNavigateToSearchService
new
ConditionalWeakTable
<
Project
,
Tuple
<
string
,
ImmutableArray
<
SearchResult
>>>();
public
static
Task
<
ImmutableArray
<
INavigateToSearchResult
>>
SearchProjectInCurrentProcessAsync
(
Project
project
,
string
searchPattern
,
IImmutableSet
<
string
>
kinds
,
CancellationToken
cancellationToken
)
Project
project
,
Document
activeDocumentOpt
,
string
searchPattern
,
IImmutableSet
<
string
>
kinds
,
CancellationToken
cancellationToken
)
{
return
FindSearchResultsAsync
(
project
,
searchDocument
:
null
,
pattern
:
searchPattern
,
kinds
,
cancellationToken
:
cancellationToken
);
project
,
activeDocumentOpt
,
searchDocument
:
null
,
pattern
:
searchPattern
,
kinds
,
cancellationToken
:
cancellationToken
);
}
public
static
Task
<
ImmutableArray
<
INavigateToSearchResult
>>
SearchDocumentInCurrentProcessAsync
(
Document
document
,
string
searchPattern
,
IImmutableSet
<
string
>
kinds
,
CancellationToken
cancellationToken
)
{
return
FindSearchResultsAsync
(
document
.
Project
,
document
,
searchPattern
,
kinds
,
cancellationToken
);
document
.
Project
,
activeDocumentOpt
:
null
,
document
,
searchPattern
,
kinds
,
cancellationToken
);
}
private
static
async
Task
<
ImmutableArray
<
INavigateToSearchResult
>>
FindSearchResultsAsync
(
Project
project
,
Document
searchDocument
,
string
pattern
,
IImmutableSet
<
string
>
kinds
,
CancellationToken
cancellationToken
)
Project
project
,
Document
activeDocumentOpt
,
Document
searchDocument
,
string
pattern
,
IImmutableSet
<
string
>
kinds
,
CancellationToken
cancellationToken
)
{
// If the user created a dotted pattern then we'll grab the last part of the name
var
(
patternName
,
patternContainerOpt
)
=
PatternMatcher
.
GetNameAndContainer
(
pattern
);
...
...
@@ -66,8 +68,8 @@ internal abstract partial class AbstractNavigateToSearchService
// scratch.
#if true
var
task
=
searchDocument
!=
null
?
ComputeSearchResultsAsync
(
project
,
searchDocument
,
nameMatcher
,
containerMatcherOpt
,
declaredSymbolInfoKindsSet
,
nameMatches
,
containerMatches
,
cancellationToken
)
:
TryFilterPreviousSearchResultsAsync
(
project
,
searchDocument
,
pattern
,
nameMatcher
,
containerMatcherOpt
,
declaredSymbolInfoKindsSet
,
nameMatches
,
containerMatches
,
cancellationToken
);
?
ComputeSearchResultsAsync
(
project
,
activeDocumentOpt
,
searchDocument
,
nameMatcher
,
containerMatcherOpt
,
declaredSymbolInfoKindsSet
,
nameMatches
,
containerMatches
,
cancellationToken
)
:
TryFilterPreviousSearchResultsAsync
(
project
,
activeDocumentOpt
,
searchDocument
,
pattern
,
nameMatcher
,
containerMatcherOpt
,
declaredSymbolInfoKindsSet
,
nameMatches
,
containerMatches
,
cancellationToken
);
#else
var
task
=
ComputeSearchResultsAsync
(
project
,
searchDocument
,
nameMatcher
,
containerMatcherOpt
,
declaredSymbolInfoKindsSet
,
nameMatches
,
containerMatches
,
cancellationToken
);
#endif
...
...
@@ -84,7 +86,7 @@ internal abstract partial class AbstractNavigateToSearchService
}
private
static
async
Task
<
ImmutableArray
<
SearchResult
>>
TryFilterPreviousSearchResultsAsync
(
Project
project
,
Document
searchDocument
,
string
pattern
,
Project
project
,
Document
activeDocumentOpt
,
Document
searchDocument
,
string
pattern
,
PatternMatcher
nameMatcher
,
PatternMatcher
containerMatcherOpt
,
DeclaredSymbolInfoKindSet
kinds
,
ArrayBuilder
<
PatternMatch
>
nameMatches
,
ArrayBuilder
<
PatternMatch
>
containerMatches
,
...
...
@@ -111,9 +113,8 @@ internal abstract partial class AbstractNavigateToSearchService
// Didn't have previous results. Or it was a very different pattern.
// Can't reuse.
searchResults
=
await
ComputeSearchResultsAsync
(
project
,
searchDocument
,
nameMatcher
,
containerMatcherOpt
,
kinds
,
project
,
activeDocumentOpt
,
searchDocument
,
nameMatcher
,
containerMatcherOpt
,
kinds
,
nameMatches
,
containerMatches
,
cancellationToken
).
ConfigureAwait
(
false
);
}
...
...
@@ -152,14 +153,21 @@ internal abstract partial class AbstractNavigateToSearchService
}
private
static
async
Task
<
ImmutableArray
<
SearchResult
>>
ComputeSearchResultsAsync
(
Project
project
,
Document
searchDocument
,
Project
project
,
Document
activeDocumentOpt
,
Document
searchDocument
,
PatternMatcher
nameMatcher
,
PatternMatcher
containerMatcherOpt
,
DeclaredSymbolInfoKindSet
kinds
,
ArrayBuilder
<
PatternMatch
>
nameMatches
,
ArrayBuilder
<
PatternMatch
>
containerMatches
,
CancellationToken
cancellationToken
)
{
var
result
=
ArrayBuilder
<
SearchResult
>.
GetInstance
();
foreach
(
var
document
in
project
.
Documents
)
// Prioritize the active document if we have one.
var
documents
=
activeDocumentOpt
==
null
?
project
.
Documents
:
project
.
Documents
.
Where
(
d
=>
d
==
activeDocumentOpt
)
.
Concat
(
project
.
Documents
.
Where
(
d
=>
d
!=
activeDocumentOpt
));
foreach
(
var
document
in
documents
)
{
if
(
searchDocument
!=
null
&&
document
!=
searchDocument
)
{
...
...
src/Features/Core/Portable/NavigateTo/AbstractNavigateToSearchService.Remote.cs
浏览文件 @
62d25585
...
...
@@ -25,13 +25,13 @@ internal abstract partial class AbstractNavigateToSearchService
}
private
async
Task
<
ImmutableArray
<
INavigateToSearchResult
>>
SearchProjectInRemoteProcessAsync
(
RemoteHostClient
client
,
Project
project
,
string
searchPattern
,
IImmutableSet
<
string
>
kinds
,
CancellationToken
cancellationToken
)
RemoteHostClient
client
,
Project
project
,
Document
activeDocumentOpt
,
string
searchPattern
,
IImmutableSet
<
string
>
kinds
,
CancellationToken
cancellationToken
)
{
var
solution
=
project
.
Solution
;
var
serializableResults
=
await
client
.
TryRunCodeAnalysisRemoteAsync
<
IList
<
SerializableNavigateToSearchResult
>>(
solution
,
nameof
(
IRemoteNavigateToSearchService
.
SearchProjectAsync
),
new
object
[]
{
project
.
Id
,
searchPattern
,
kinds
.
ToArray
()
},
cancellationToken
).
ConfigureAwait
(
false
);
new
object
[]
{
project
.
Id
,
activeDocumentOpt
?.
Id
,
searchPattern
,
kinds
.
ToArray
()
},
cancellationToken
).
ConfigureAwait
(
false
);
return
serializableResults
.
SelectAsArray
(
r
=>
r
.
Rehydrate
(
solution
));
}
...
...
src/Features/Core/Portable/NavigateTo/AbstractNavigateToSearchService.cs
浏览文件 @
62d25585
...
...
@@ -42,18 +42,18 @@ internal abstract partial class AbstractNavigateToSearchService : INavigateToSea
}
public
async
Task
<
ImmutableArray
<
INavigateToSearchResult
>>
SearchProjectAsync
(
Project
project
,
string
searchPattern
,
IImmutableSet
<
string
>
kinds
,
CancellationToken
cancellationToken
)
Project
project
,
Document
activeDocumentOpt
,
string
searchPattern
,
IImmutableSet
<
string
>
kinds
,
CancellationToken
cancellationToken
)
{
var
client
=
await
TryGetRemoteHostClientAsync
(
project
,
cancellationToken
).
ConfigureAwait
(
false
);
if
(
client
==
null
)
{
return
await
SearchProjectInCurrentProcessAsync
(
project
,
searchPattern
,
kinds
,
cancellationToken
).
ConfigureAwait
(
false
);
project
,
activeDocumentOpt
,
searchPattern
,
kinds
,
cancellationToken
).
ConfigureAwait
(
false
);
}
else
{
return
await
SearchProjectInRemoteProcessAsync
(
client
,
project
,
searchPattern
,
kinds
,
cancellationToken
).
ConfigureAwait
(
false
);
client
,
activeDocumentOpt
,
project
,
searchPattern
,
kinds
,
cancellationToken
).
ConfigureAwait
(
false
);
}
}
}
...
...
src/Features/Core/Portable/NavigateTo/INavigateToSearchService.cs
浏览文件 @
62d25585
...
...
@@ -28,7 +28,7 @@ bool CanFilter
get
;
}
Task
<
ImmutableArray
<
INavigateToSearchResult
>>
SearchProjectAsync
(
Project
project
,
string
searchPattern
,
IImmutableSet
<
string
>
kinds
,
CancellationToken
cancellationToken
);
Task
<
ImmutableArray
<
INavigateToSearchResult
>>
SearchProjectAsync
(
Project
project
,
Document
activeDocumentOpt
,
string
searchPattern
,
IImmutableSet
<
string
>
kinds
,
CancellationToken
cancellationToken
);
Task
<
ImmutableArray
<
INavigateToSearchResult
>>
SearchDocumentAsync
(
Document
document
,
string
searchPattern
,
IImmutableSet
<
string
>
kinds
,
CancellationToken
cancellationToken
);
}
}
src/Features/Core/Portable/NavigateTo/IRemoteNavigateToSearchService.cs
浏览文件 @
62d25585
...
...
@@ -10,6 +10,6 @@ namespace Microsoft.CodeAnalysis.NavigateTo
internal
interface
IRemoteNavigateToSearchService
{
Task
<
IList
<
SerializableNavigateToSearchResult
>>
SearchDocumentAsync
(
DocumentId
documentId
,
string
searchPattern
,
string
[]
kinds
,
CancellationToken
cancellationToken
);
Task
<
IList
<
SerializableNavigateToSearchResult
>>
SearchProjectAsync
(
ProjectId
projectId
,
string
searchPattern
,
string
[]
kinds
,
CancellationToken
cancellationToken
);
Task
<
IList
<
SerializableNavigateToSearchResult
>>
SearchProjectAsync
(
ProjectId
projectId
,
DocumentId
activeDocumentIdOpt
,
string
searchPattern
,
string
[]
kinds
,
CancellationToken
cancellationToken
);
}
}
src/Workspaces/Remote/ServiceHub/Services/CodeAnalysisService_NavigateTo.cs
浏览文件 @
62d25585
...
...
@@ -29,7 +29,7 @@ internal partial class CodeAnalysisService : IRemoteNavigateToSearchService
}
public
Task
<
IList
<
SerializableNavigateToSearchResult
>>
SearchProjectAsync
(
ProjectId
projectId
,
string
searchPattern
,
string
[]
kinds
,
CancellationToken
cancellationToken
)
ProjectId
projectId
,
DocumentId
activeDocIdOpt
,
string
searchPattern
,
string
[]
kinds
,
CancellationToken
cancellationToken
)
{
return
RunServiceAsync
(
async
token
=>
{
...
...
@@ -38,8 +38,10 @@ internal partial class CodeAnalysisService : IRemoteNavigateToSearchService
var
solution
=
await
GetSolutionAsync
(
token
).
ConfigureAwait
(
false
);
var
project
=
solution
.
GetProject
(
projectId
);
var
activeDocumentOpt
=
solution
.
GetDocument
(
activeDocIdOpt
);
var
result
=
await
AbstractNavigateToSearchService
.
SearchProjectInCurrentProcessAsync
(
project
,
searchPattern
,
kinds
.
ToImmutableHashSet
(),
token
).
ConfigureAwait
(
false
);
project
,
activeDocumentOpt
,
searchPattern
,
kinds
.
ToImmutableHashSet
(),
token
).
ConfigureAwait
(
false
);
return
Convert
(
result
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录