Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
23732845
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,发现更多精彩内容 >>
提交
23732845
编写于
7月 05, 2018
作者:
S
Sam Harwell
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Implement INavigateToItemProvider2 without requiring breaking API changes
上级
260e8f90
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
135 addition
and
20 deletion
+135
-20
src/EditorFeatures/Core.Wpf/NavigateTo/NavigateToItemProvider.Searcher.cs
...es/Core.Wpf/NavigateTo/NavigateToItemProvider.Searcher.cs
+44
-1
src/EditorFeatures/Core.Wpf/NavigateTo/NavigateToItemProvider.cs
...torFeatures/Core.Wpf/NavigateTo/NavigateToItemProvider.cs
+54
-16
src/Features/CSharp/Portable/NavigateTo/CSharpNavigateToSearchService.cs
...harp/Portable/NavigateTo/CSharpNavigateToSearchService.cs
+1
-1
src/Features/Core/Portable/NavigateTo/AbstractNavigateToSearchService.cs
...re/Portable/NavigateTo/AbstractNavigateToSearchService.cs
+17
-1
src/Features/Core/Portable/NavigateTo/INavigateToSearchService.cs
...ures/Core/Portable/NavigateTo/INavigateToSearchService.cs
+18
-0
src/Features/VisualBasic/Portable/NavigateTo/VisualBasicNavigateToSearchService.vb
...Portable/NavigateTo/VisualBasicNavigateToSearchService.vb
+1
-1
未找到文件。
src/EditorFeatures/Core.Wpf/NavigateTo/NavigateToItemProvider.Searcher.cs
浏览文件 @
23732845
...
...
@@ -2,6 +2,7 @@
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Immutable
;
using
System.Linq
;
using
System.Threading
;
using
System.Threading.Tasks
;
...
...
@@ -108,7 +109,7 @@ private async Task SearchAsyncWorker(Project project)
{
using
(
cacheService
.
EnableCaching
(
project
.
Id
))
{
var
service
=
project
.
LanguageServices
.
GetService
<
INavigateToSearchService
>(
);
var
service
=
TryGetNavigateToSearchService
(
project
);
if
(
service
!=
null
)
{
var
searchTask
=
_currentDocument
!=
null
...
...
@@ -128,6 +129,27 @@ private async Task SearchAsyncWorker(Project project)
}
}
private
static
INavigateToSearchService_RemoveInterfaceAboveAndRenameThisAfterInternalsVisibleToUsersUpdate
TryGetNavigateToSearchService
(
Project
project
)
{
var
service
=
project
.
LanguageServices
.
GetService
<
INavigateToSearchService_RemoveInterfaceAboveAndRenameThisAfterInternalsVisibleToUsersUpdate
>();
if
(
service
!=
null
)
{
return
service
;
}
#pragma warning disable CS0618 // Type or member is obsolete
#pragma warning disable CS0612 // Type or member is obsolete
var
legacyService
=
project
.
LanguageServices
.
GetService
<
INavigateToSearchService
>();
if
(
legacyService
!=
null
)
{
return
new
ShimNavigateToSearchService
(
legacyService
);
}
#pragma warning restore CS0612 // Type or member is obsolete
#pragma warning restore CS0618 // Type or member is obsolete
return
null
;
}
private
void
ReportMatchResult
(
Project
project
,
INavigateToSearchResult
result
)
{
var
matchedSpans
=
result
.
NameMatchSpans
.
SelectAsArray
(
t
=>
t
.
ToSpan
());
...
...
@@ -182,6 +204,27 @@ private static string GetNavigateToLanguage(string languageName)
return
languageName
;
}
}
[
Obsolete
]
private
class
ShimNavigateToSearchService
:
INavigateToSearchService_RemoveInterfaceAboveAndRenameThisAfterInternalsVisibleToUsersUpdate
{
private
readonly
INavigateToSearchService
_navigateToSearchService
;
public
ShimNavigateToSearchService
(
INavigateToSearchService
navigateToSearchService
)
{
_navigateToSearchService
=
navigateToSearchService
;
}
public
IImmutableSet
<
string
>
KindsProvided
=>
ImmutableHashSet
<
string
>.
Empty
;
public
bool
CanFilter
=>
false
;
public
Task
<
ImmutableArray
<
INavigateToSearchResult
>>
SearchDocumentAsync
(
Document
document
,
string
searchPattern
,
ISet
<
string
>
kinds
,
CancellationToken
cancellationToken
)
=>
_navigateToSearchService
.
SearchDocumentAsync
(
document
,
searchPattern
,
cancellationToken
);
public
Task
<
ImmutableArray
<
INavigateToSearchResult
>>
SearchProjectAsync
(
Project
project
,
string
searchPattern
,
ISet
<
string
>
kinds
,
CancellationToken
cancellationToken
)
=>
_navigateToSearchService
.
SearchProjectAsync
(
project
,
searchPattern
,
cancellationToken
);
}
}
}
}
src/EditorFeatures/Core.Wpf/NavigateTo/NavigateToItemProvider.cs
浏览文件 @
23732845
...
...
@@ -2,11 +2,12 @@
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Immutable
;
using
System.Threading
;
using
Microsoft.CodeAnalysis.Shared.TestHooks
;
using
Microsoft.VisualStudio.Language.NavigateTo.Interfaces
;
using
Roslyn.Utilities
;
using
INavigateToSearchService
=
Microsoft
.
CodeAnalysis
.
NavigateTo
.
INavigateToSearchService
;
using
INavigateToSearchService_RemoveInterfaceAboveAndRenameThisAfterInternalsVisibleToUsersUpdate
=
Microsoft
.
CodeAnalysis
.
NavigateTo
.
INavigateToSearchService_RemoveInterfaceAboveAndRenameThisAfterInternalsVisibleToUsersUpdate
;
namespace
Microsoft.CodeAnalysis.Editor.Implementation.NavigateTo
{
...
...
@@ -30,21 +31,58 @@ internal partial class NavigateToItemProvider : INavigateToItemProvider2
_displayFactory
=
new
NavigateToItemDisplayFactory
();
}
public
ISet
<
string
>
KindsProvided
{
get
;
}
=
ImmutableHashSet
.
Create
(
NavigateToItemKind
.
Class
,
NavigateToItemKind
.
Constant
,
NavigateToItemKind
.
Delegate
,
NavigateToItemKind
.
Enum
,
NavigateToItemKind
.
EnumItem
,
NavigateToItemKind
.
Event
,
NavigateToItemKind
.
Field
,
NavigateToItemKind
.
Interface
,
NavigateToItemKind
.
Method
,
NavigateToItemKind
.
Module
,
NavigateToItemKind
.
Property
,
NavigateToItemKind
.
Structure
);
public
bool
CanFilter
=>
true
;
public
ISet
<
string
>
KindsProvided
{
get
{
var
result
=
new
HashSet
<
string
>(
StringComparer
.
Ordinal
);
foreach
(
var
project
in
_workspace
.
CurrentSolution
.
Projects
)
{
var
navigateToSearchService
=
project
.
LanguageServices
.
GetService
<
INavigateToSearchService_RemoveInterfaceAboveAndRenameThisAfterInternalsVisibleToUsersUpdate
>();
if
(
navigateToSearchService
!=
null
)
{
result
.
UnionWith
(
navigateToSearchService
.
KindsProvided
);
continue
;
}
}
return
result
;
}
}
public
bool
CanFilter
{
get
{
foreach
(
var
project
in
_workspace
.
CurrentSolution
.
Projects
)
{
var
navigateToSearchService
=
project
.
LanguageServices
.
GetService
<
INavigateToSearchService_RemoveInterfaceAboveAndRenameThisAfterInternalsVisibleToUsersUpdate
>();
if
(
navigateToSearchService
!=
null
)
{
if
(!
navigateToSearchService
.
CanFilter
)
{
return
false
;
}
continue
;
}
#pragma warning disable CS0618 // Type or member is obsolete
var
legacyNavigateToSearchService
=
project
.
LanguageServices
.
GetService
<
INavigateToSearchService
>();
if
(
legacyNavigateToSearchService
!=
null
)
{
return
false
;
}
#pragma warning restore CS0618 // Type or member is obsolete
// If we reach here, it means the current project does not support Navigate To, which is
// functionally equivalent to supporting filtering.
}
// All projects either support filtering or do not support Navigate To at all
return
true
;
}
}
public
void
StopSearch
()
{
...
...
src/Features/CSharp/Portable/NavigateTo/CSharpNavigateToSearchService.cs
浏览文件 @
23732845
...
...
@@ -6,7 +6,7 @@
namespace
Microsoft.CodeAnalysis.CSharp.NavigateTo
{
[
ExportLanguageService
(
typeof
(
INavigateToSearchService
),
LanguageNames
.
CSharp
),
Shared
]
[
ExportLanguageService
(
typeof
(
INavigateToSearchService
_RemoveInterfaceAboveAndRenameThisAfterInternalsVisibleToUsersUpdate
),
LanguageNames
.
CSharp
),
Shared
]
internal
class
CSharpNavigateToSearchService
:
AbstractNavigateToSearchService
{
}
...
...
src/Features/Core/Portable/NavigateTo/AbstractNavigateToSearchService.cs
浏览文件 @
23732845
...
...
@@ -7,8 +7,24 @@
namespace
Microsoft.CodeAnalysis.NavigateTo
{
internal
abstract
partial
class
AbstractNavigateToSearchService
:
INavigateToSearchService
internal
abstract
partial
class
AbstractNavigateToSearchService
:
INavigateToSearchService
_RemoveInterfaceAboveAndRenameThisAfterInternalsVisibleToUsersUpdate
{
public
IImmutableSet
<
string
>
KindsProvided
{
get
;
}
=
ImmutableHashSet
.
Create
(
NavigateToItemKind
.
Class
,
NavigateToItemKind
.
Constant
,
NavigateToItemKind
.
Delegate
,
NavigateToItemKind
.
Enum
,
NavigateToItemKind
.
EnumItem
,
NavigateToItemKind
.
Event
,
NavigateToItemKind
.
Field
,
NavigateToItemKind
.
Interface
,
NavigateToItemKind
.
Method
,
NavigateToItemKind
.
Module
,
NavigateToItemKind
.
Property
,
NavigateToItemKind
.
Structure
);
public
bool
CanFilter
=>
true
;
public
async
Task
<
ImmutableArray
<
INavigateToSearchResult
>>
SearchDocumentAsync
(
Document
document
,
string
searchPattern
,
ISet
<
string
>
kinds
,
CancellationToken
cancellationToken
)
{
...
...
src/Features/Core/Portable/NavigateTo/INavigateToSearchService.cs
浏览文件 @
23732845
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Immutable
;
using
System.Threading
;
...
...
@@ -8,8 +9,25 @@
namespace
Microsoft.CodeAnalysis.NavigateTo
{
[
Obsolete
(
"Use "
+
nameof
(
INavigateToSearchService_RemoveInterfaceAboveAndRenameThisAfterInternalsVisibleToUsersUpdate
)
+
" instead."
)]
internal
interface
INavigateToSearchService
:
ILanguageService
{
Task
<
ImmutableArray
<
INavigateToSearchResult
>>
SearchProjectAsync
(
Project
project
,
string
searchPattern
,
CancellationToken
cancellationToken
);
Task
<
ImmutableArray
<
INavigateToSearchResult
>>
SearchDocumentAsync
(
Document
document
,
string
searchPattern
,
CancellationToken
cancellationToken
);
}
internal
interface
INavigateToSearchService_RemoveInterfaceAboveAndRenameThisAfterInternalsVisibleToUsersUpdate
:
ILanguageService
{
IImmutableSet
<
string
>
KindsProvided
{
get
;
}
bool
CanFilter
{
get
;
}
Task
<
ImmutableArray
<
INavigateToSearchResult
>>
SearchProjectAsync
(
Project
project
,
string
searchPattern
,
ISet
<
string
>
kinds
,
CancellationToken
cancellationToken
);
Task
<
ImmutableArray
<
INavigateToSearchResult
>>
SearchDocumentAsync
(
Document
document
,
string
searchPattern
,
ISet
<
string
>
kinds
,
CancellationToken
cancellationToken
);
}
...
...
src/Features/VisualBasic/Portable/NavigateTo/VisualBasicNavigateToSearchService.vb
浏览文件 @
23732845
...
...
@@ -5,7 +5,7 @@ Imports Microsoft.CodeAnalysis.Host.Mef
Imports
Microsoft.CodeAnalysis.NavigateTo
Namespace
Microsoft.CodeAnalysis.VisualBasic.NavigateTo
<
ExportLanguageService
(
GetType
(
INavigateToSearchService
),
LanguageNames
.
VisualBasic
),
[
Shared
]
>
<
ExportLanguageService
(
GetType
(
INavigateToSearchService
_RemoveInterfaceAboveAndRenameThisAfterInternalsVisibleToUsersUpdate
),
LanguageNames
.
VisualBasic
),
[
Shared
]
>
Friend
Class
VisualBasicNavigateToSearchService
Inherits
AbstractNavigateToSearchService
End
Class
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录