Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
eee853f3
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,发现更多精彩内容 >>
提交
eee853f3
编写于
7月 20, 2016
作者:
C
CyrusNajmabadi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Initial implementation of streaming find refs in the FindRefsService.
上级
1867b5e1
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
123 addition
and
11 deletion
+123
-11
src/EditorFeatures/CSharp/FindReferences/CSharpFindReferencesService.cs
...ures/CSharp/FindReferences/CSharpFindReferencesService.cs
+14
-1
src/EditorFeatures/Core/EditorFeatures.csproj
src/EditorFeatures/Core/EditorFeatures.csproj
+2
-1
src/EditorFeatures/Core/Implementation/FindReferences/AbstractFindReferencesService.ProgressAdapter.cs
...ferences/AbstractFindReferencesService.ProgressAdapter.cs
+62
-0
src/EditorFeatures/Core/Implementation/FindReferences/AbstractFindReferencesService.cs
...mentation/FindReferences/AbstractFindReferencesService.cs
+26
-4
src/EditorFeatures/Test/FindReferences/FindReferencesCommandHandlerTests.cs
.../Test/FindReferences/FindReferencesCommandHandlerTests.cs
+6
-4
src/EditorFeatures/VisualBasic/FindReferences/VisualBasicFindReferencesService.vb
...lBasic/FindReferences/VisualBasicFindReferencesService.vb
+13
-1
未找到文件。
src/EditorFeatures/CSharp/FindReferences/CSharpFindReferencesService.cs
浏览文件 @
eee853f3
...
...
@@ -20,4 +20,17 @@ internal class CSharpFindReferencesService : AbstractFindReferencesService
{
}
}
[
ExportLanguageService
(
typeof
(
IStreamingFindReferencesService
),
LanguageNames
.
CSharp
),
Shared
]
internal
class
CSharpStreamingFindReferencesService
:
AbstractFindReferencesService
{
[
ImportingConstructor
]
public
CSharpStreamingFindReferencesService
(
[
ImportMany
]
IEnumerable
<
IReferencedSymbolsPresenter
>
referencedSymbolsPresenters
,
[
ImportMany
]
IEnumerable
<
INavigableItemsPresenter
>
navigableItemsPresenters
,
[
ImportMany
]
IEnumerable
<
IFindReferencesResultProvider
>
externalReferencesProviders
)
:
base
(
referencedSymbolsPresenters
,
navigableItemsPresenters
,
externalReferencesProviders
)
{
}
}
}
\ No newline at end of file
src/EditorFeatures/Core/EditorFeatures.csproj
浏览文件 @
eee853f3
...
...
@@ -267,6 +267,7 @@
<Compile
Include=
"Implementation\Diagnostics\DiagnosticsSuggestionTaggerProvider.cs"
/>
<Compile
Include=
"Implementation\Diagnostics\SuggestionAdornmentManagerProvider.cs"
/>
<Compile
Include=
"Implementation\Diagnostics\SuggestionTag.cs"
/>
<Compile
Include=
"Implementation\FindReferences\AbstractFindReferencesService.ProgressAdapter.cs"
/>
<Compile
Include=
"Implementation\FindReferences\FindReferencesContext.cs"
/>
<Compile
Include=
"Implementation\FindReferences\IFindReferencesNavigableItemResultProvider.cs"
/>
<Compile
Include=
"Implementation\GoToDefinition\INavigableDefinitionProvider.cs"
/>
...
...
src/EditorFeatures/Core/Implementation/FindReferences/AbstractFindReferencesService.ProgressAdapter.cs
0 → 100644
浏览文件 @
eee853f3
using
System
;
using
System.Collections.Concurrent
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
Microsoft.CodeAnalysis.Editor.Navigation
;
using
Microsoft.CodeAnalysis.FindSymbols
;
using
Microsoft.CodeAnalysis.Shared.Utilities
;
namespace
Microsoft.CodeAnalysis.Editor.Implementation.FindReferences
{
internal
abstract
partial
class
AbstractFindReferencesService
{
/// <summary>
/// Forwards IFindReferencesProgress calls to a FindRefrencesContext instance.
/// </summary>
private
class
ProgressAdapter
:
IFindReferencesProgress
{
private
readonly
Solution
_solution
;
private
readonly
FindReferencesContext
_context
;
private
readonly
ConcurrentDictionary
<
ISymbol
,
INavigableItem
>
_symbolToNavigableItem
=
new
ConcurrentDictionary
<
ISymbol
,
INavigableItem
>(
SymbolEquivalenceComparer
.
Instance
);
private
readonly
Func
<
ISymbol
,
INavigableItem
>
_navigableItemFactory
;
public
ProgressAdapter
(
Solution
solution
,
FindReferencesContext
context
)
{
_solution
=
solution
;
_context
=
context
;
_navigableItemFactory
=
s
=>
NavigableItemFactory
.
GetItemFromSymbolLocation
(
solution
,
s
,
s
.
Locations
.
First
());
}
public
void
OnStarted
()
=>
_context
.
OnStarted
();
public
void
OnCompleted
()
=>
_context
.
OnCompleted
();
public
void
ReportProgress
(
int
current
,
int
maximum
)
=>
_context
.
ReportProgress
(
current
,
maximum
);
public
void
OnFindInDocumentStarted
(
Document
document
)
=>
_context
.
OnFindInDocumentStarted
(
document
);
public
void
OnFindInDocumentCompleted
(
Document
document
)
=>
_context
.
OnFindInDocumentCompleted
(
document
);
private
INavigableItem
GetNavigableItem
(
ISymbol
symbol
)
{
return
_symbolToNavigableItem
.
GetOrAdd
(
symbol
,
_navigableItemFactory
);
}
public
void
OnDefinitionFound
(
ISymbol
symbol
)
{
_context
.
OnDefinitionFound
(
GetNavigableItem
(
symbol
));
}
public
void
OnReferenceFound
(
ISymbol
symbol
,
ReferenceLocation
location
)
{
_context
.
OnReferenceFound
(
GetNavigableItem
(
symbol
),
NavigableItemFactory
.
GetItemFromSymbolLocation
(
_solution
,
symbol
,
location
.
Location
));
}
}
}
}
\ No newline at end of file
src/EditorFeatures/Core/Implementation/FindReferences/AbstractFindReferencesService.cs
浏览文件 @
eee853f3
...
...
@@ -14,8 +14,8 @@
namespace
Microsoft.CodeAnalysis.Editor.Implementation.FindReferences
{
internal
abstract
class
AbstractFindReferencesService
:
IFindReferencesService
internal
abstract
partial
class
AbstractFindReferencesService
:
IFindReferencesService
,
IStreamingFindReferencesService
{
private
readonly
IEnumerable
<
IReferencedSymbolsPresenter
>
_referenceSymbolPresenters
;
private
readonly
IEnumerable
<
INavigableItemsPresenter
>
_navigableItemPresenters
;
...
...
@@ -34,6 +34,8 @@ internal abstract class AbstractFindReferencesService :
private
async
Task
<
Tuple
<
ISymbol
,
Solution
>>
GetRelevantSymbolAndSolutionAtPositionAsync
(
Document
document
,
int
position
,
CancellationToken
cancellationToken
)
{
cancellationToken
.
ThrowIfCancellationRequested
();
var
symbol
=
await
SymbolFinder
.
FindSymbolAtPositionAsync
(
document
,
position
,
cancellationToken
:
cancellationToken
).
ConfigureAwait
(
false
);
if
(
symbol
!=
null
)
{
...
...
@@ -184,5 +186,25 @@ private bool TryDisplayReferences(Tuple<IEnumerable<ReferencedSymbol>, Solution>
return
false
;
}
public
async
Task
FindReferencesAsync
(
Document
document
,
int
position
,
FindReferencesContext
context
)
{
var
cancellationToken
=
context
.
CancellationToken
;
cancellationToken
.
ThrowIfCancellationRequested
();
var
symbolAndSolution
=
await
GetRelevantSymbolAndSolutionAtPositionAsync
(
document
,
position
,
cancellationToken
).
ConfigureAwait
(
false
);
var
symbol
=
symbolAndSolution
.
Item1
;
var
solution
=
symbolAndSolution
.
Item2
;
var
result
=
await
SymbolFinder
.
FindReferencesAsync
(
symbol
,
solution
,
progress
:
new
ProgressAdapter
(
solution
,
context
),
documents
:
null
,
cancellationToken
:
cancellationToken
).
ConfigureAwait
(
false
);
}
}
}
\ No newline at end of file
src/EditorFeatures/Test/FindReferences/FindReferencesCommandHandlerTests.cs
浏览文件 @
eee853f3
// 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.Linq
;
using
System.Threading.Tasks
;
using
Microsoft.CodeAnalysis.Editor.Commands
;
using
Microsoft.CodeAnalysis.Editor.Host
;
using
Microsoft.CodeAnalysis.Editor.Implementation.FindReferences
;
using
Microsoft.CodeAnalysis.Editor.Navigation
;
using
Microsoft.CodeAnalysis.Editor.UnitTests.Utilities
;
using
Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces
;
using
Microsoft.CodeAnalysis.FindSymbols
;
using
Microsoft.
VisualStudio.Language.Intellisense
;
using
Microsoft.
CodeAnalysis.Shared.TestHooks
;
using
Microsoft.VisualStudio.Text
;
using
Moq
;
using
Roslyn.Test.Utilities
;
using
Roslyn.Utilities
;
using
Xunit
;
...
...
@@ -29,7 +29,9 @@ public async Task TestFindReferencesSynchronousCall()
var
handler
=
new
FindReferencesCommandHandler
(
TestWaitIndicator
.
Default
,
SpecializedCollections
.
SingletonEnumerable
(
findReferencesPresenter
));
SpecializedCollections
.
SingletonEnumerable
(
findReferencesPresenter
),
SpecializedCollections
.
EmptyEnumerable
<
IAsyncFindReferencesPresenter
>(),
workspace
.
ExportProvider
.
GetExports
<
IAsynchronousOperationListener
,
FeatureMetadata
>());
var
textView
=
workspace
.
Documents
[
0
].
GetTextView
();
textView
.
Caret
.
MoveTo
(
new
SnapshotPoint
(
textView
.
TextSnapshot
,
7
));
...
...
src/EditorFeatures/VisualBasic/FindReferences/VisualBasicFindReferencesService.vb
浏览文件 @
eee853f3
...
...
@@ -17,4 +17,16 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.FindReferences
MyBase
.
New
(
referencedSymbolsPresenters
,
navigableItemsPresenters
,
externalReferencesProviders
)
End
Sub
End
Class
<
ExportLanguageService
(
GetType
(
IStreamingFindReferencesService
),
LanguageNames
.
VisualBasic
),
[
Shared
]
>
Friend
Class
VisualBasicStreamingFindReferencesService
Inherits
AbstractFindReferencesService
<
ImportingConstructor
>
Protected
Sub
New
(
<
ImportMany
>
referencedSymbolsPresenters
As
IEnumerable
(
Of
IReferencedSymbolsPresenter
),
<
ImportMany
>
navigableItemsPresenters
As
IEnumerable
(
Of
INavigableItemsPresenter
),
<
ImportMany
>
externalReferencesProviders
As
IEnumerable
(
Of
IFindReferencesResultProvider
))
MyBase
.
New
(
referencedSymbolsPresenters
,
navigableItemsPresenters
,
externalReferencesProviders
)
End
Sub
End
Class
End
Namespace
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录