Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
631e9fa1
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,发现更多精彩内容 >>
提交
631e9fa1
编写于
2月 18, 2016
作者:
R
Ravi Chande
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #8746 from rchande/sighelpperf2
Abort SigHelp if navigation keys before presented
上级
3e2ebf66
13c030dc
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
99 addition
and
2 deletion
+99
-2
src/EditorFeatures/Core/Extensibility/SignatureHelp/ISignatureHelpPresenterSession.cs
...nsibility/SignatureHelp/ISignatureHelpPresenterSession.cs
+2
-0
src/EditorFeatures/Core/Implementation/IntelliSense/SignatureHelp/Controller_NavigationKeys.cs
...n/IntelliSense/SignatureHelp/Controller_NavigationKeys.cs
+9
-0
src/EditorFeatures/Core/Implementation/IntelliSense/SignatureHelp/Presentation/SignatureHelpPresenter.SignatureHelpPresenterSession.cs
...n/SignatureHelpPresenter.SignatureHelpPresenterSession.cs
+2
-0
src/EditorFeatures/Test2/IntelliSense/SignatureHelpControllerTests.vb
...atures/Test2/IntelliSense/SignatureHelpControllerTests.vb
+77
-2
src/EditorFeatures/Test2/IntelliSense/TestSignatureHelpPresenterSession.vb
...s/Test2/IntelliSense/TestSignatureHelpPresenterSession.vb
+9
-0
未找到文件。
src/EditorFeatures/Core/Extensibility/SignatureHelp/ISignatureHelpPresenterSession.cs
浏览文件 @
631e9fa1
...
...
@@ -13,5 +13,7 @@ internal interface ISignatureHelpPresenterSession : IIntelliSensePresenterSessio
void
SelectNextItem
();
event
EventHandler
<
SignatureHelpItemEventArgs
>
ItemSelected
;
bool
EditorSessionIsActive
{
get
;
}
}
}
src/EditorFeatures/Core/Implementation/IntelliSense/SignatureHelp/Controller_NavigationKeys.cs
浏览文件 @
631e9fa1
...
...
@@ -28,6 +28,15 @@ private bool ChangeSelection(Action computationAction)
return
false
;
}
// If we haven't started our editor session yet, just abort.
// The user hasn't seen a SigHelp presentation yet, so they're
// probably not trying to change the currently visible overload.
if
(!
sessionOpt
.
PresenterSession
.
EditorSessionIsActive
)
{
DismissSessionIfActive
();
return
false
;
}
// If we've finished computing the items then use the navigation commands to change the
// selected item. Otherwise, the user was just typing and is now moving through the
// file. In this case stop everything we're doing.
...
...
src/EditorFeatures/Core/Implementation/IntelliSense/SignatureHelp/Presentation/SignatureHelpPresenter.SignatureHelpPresenterSession.cs
浏览文件 @
631e9fa1
...
...
@@ -31,6 +31,8 @@ private class SignatureHelpPresenterSession : ForegroundThreadAffinitizedObject,
private
ISignatureHelpSession
_editorSessionOpt
;
private
bool
_ignoreSelectionStatusChangedEvent
;
public
bool
EditorSessionIsActive
=>
_editorSessionOpt
?.
IsDismissed
==
false
;
public
SignatureHelpPresenterSession
(
ISignatureHelpBroker
sigHelpBroker
,
ITextView
textView
,
...
...
src/EditorFeatures/Test2/IntelliSense/SignatureHelpControllerTests.vb
浏览文件 @
631e9fa1
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports
System.ComponentModel.Composition.Hosting
Imports
System.Runtime.CompilerServices
Imports
System.Threading
Imports
System.Threading.Tasks
Imports
System.Windows.Threading
Imports
Microsoft.CodeAnalysis.Editor.Commands
Imports
Microsoft.CodeAnalysis.Editor.Implementation.IntelliSense
Imports
Microsoft.CodeAnalysis.Editor.Implementation.IntelliSense.SignatureHelp
...
...
@@ -13,7 +13,6 @@ Imports Microsoft.CodeAnalysis.Text
Imports
Microsoft.VisualStudio.Language.Intellisense
Imports
Microsoft.VisualStudio.Text
Imports
Microsoft.VisualStudio.Text.Editor
Imports
Microsoft.VisualStudio.Text.Projection
Imports
Moq
#
Disable
Warning
RS0007
' Avoid zero-length array allocations. This is non-shipping test code.
...
...
@@ -93,6 +92,79 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.IntelliSense
GetMocks
(
controller
).
PresenterSession
.
Verify
(
Sub
(
p
)
p
.
Dismiss
(),
Times
.
Once
)
End
Sub
<
WpfFact
>
<
WorkItem
(
179726
,
"https://devdiv.visualstudio.com/DefaultCollection/DevDiv/_workItems?id=179726&_a=edit"
)
>
Public
Sub
DownKeyShouldNotBlockOnModelComputation
()
Dim
mre
=
New
ManualResetEvent
(
False
)
Dim
controller
=
CreateController
(
items
:
=
CreateItems
(
2
),
waitForPresentation
:
=
False
)
Dim
slowProvider
=
New
Mock
(
Of
ISignatureHelpProvider
)
slowProvider
.
Setup
(
Function
(
p
)
p
.
GetItemsAsync
(
It
.
IsAny
(
Of
Document
),
It
.
IsAny
(
Of
Integer
),
It
.
IsAny
(
Of
SignatureHelpTriggerInfo
),
It
.
IsAny
(
Of
CancellationToken
)))
_
.
Returns
(
Function
()
mre
.
WaitOne
()
Return
Task
.
FromResult
(
New
SignatureHelpItems
(
CreateItems
(
2
),
TextSpan
.
FromBounds
(
0
,
0
),
selectedItem
:
=
0
,
argumentIndex
:
=
0
,
argumentCount
:
=
0
,
argumentName
:
=
Nothing
))
End
Function
)
Dim
handled
=
controller
.
TryHandleDownKey
()
Assert
.
False
(
handled
)
End
Sub
<
WpfFact
>
<
WorkItem
(
179726
,
"https://devdiv.visualstudio.com/DefaultCollection/DevDiv/_workItems?id=179726&_a=edit"
)
>
Public
Sub
UpKeyShouldNotBlockOnModelComputation
()
Dim
mre
=
New
ManualResetEvent
(
False
)
Dim
controller
=
CreateController
(
items
:
=
CreateItems
(
2
),
waitForPresentation
:
=
False
)
Dim
slowProvider
=
New
Mock
(
Of
ISignatureHelpProvider
)
slowProvider
.
Setup
(
Function
(
p
)
p
.
GetItemsAsync
(
It
.
IsAny
(
Of
Document
),
It
.
IsAny
(
Of
Integer
),
It
.
IsAny
(
Of
SignatureHelpTriggerInfo
),
It
.
IsAny
(
Of
CancellationToken
)))
_
.
Returns
(
Function
()
mre
.
WaitOne
()
Return
Task
.
FromResult
(
New
SignatureHelpItems
(
CreateItems
(
2
),
TextSpan
.
FromBounds
(
0
,
0
),
selectedItem
:
=
0
,
argumentIndex
:
=
0
,
argumentCount
:
=
0
,
argumentName
:
=
Nothing
))
End
Function
)
Dim
handled
=
controller
.
TryHandleUpKey
()
Assert
.
False
(
handled
)
End
Sub
<
WpfFact
>
<
WorkItem
(
179726
,
"https://devdiv.visualstudio.com/DefaultCollection/DevDiv/_workItems?id=179726&_a=edit"
)
>
Public
Async
Function
UpKeyShouldBlockOnRecomputationAfterPresentation
()
As
Task
Dim
dispatcher
=
System
.
Windows
.
Threading
.
Dispatcher
.
CurrentDispatcher
Dim
worker
=
Async
Function
()
Dim
slowProvider
=
New
Mock
(
Of
ISignatureHelpProvider
)
slowProvider
.
Setup
(
Function
(
p
)
p
.
GetItemsAsync
(
It
.
IsAny
(
Of
Document
),
It
.
IsAny
(
Of
Integer
),
It
.
IsAny
(
Of
SignatureHelpTriggerInfo
),
It
.
IsAny
(
Of
CancellationToken
)))
_
.
Returns
(
Task
.
FromResult
(
New
SignatureHelpItems
(
CreateItems
(
2
),
TextSpan
.
FromBounds
(
0
,
0
),
selectedItem
:
=
0
,
argumentIndex
:
=
0
,
argumentCount
:
=
0
,
argumentName
:
=
Nothing
)))
Dim
controller
=
dispatcher
.
Invoke
(
Function
()
CreateController
(
provider
:
=
slowProvider
.
Object
,
waitForPresentation
:
=
True
))
' Update session so that providers are requeried.
' SlowProvider now blocks on the checkpoint's task.
Dim
checkpoint
=
New
Checkpoint
()
slowProvider
.
Setup
(
Function
(
p
)
p
.
GetItemsAsync
(
It
.
IsAny
(
Of
Document
),
It
.
IsAny
(
Of
Integer
),
It
.
IsAny
(
Of
SignatureHelpTriggerInfo
),
It
.
IsAny
(
Of
CancellationToken
)))
_
.
Returns
(
Function
()
checkpoint
.
Task
.
Wait
()
Return
Task
.
FromResult
(
New
SignatureHelpItems
(
CreateItems
(
2
),
TextSpan
.
FromBounds
(
0
,
2
),
selectedItem
:
=
0
,
argumentIndex
:
=
0
,
argumentCount
:
=
0
,
argumentName
:
=
Nothing
))
End
Function
)
dispatcher
.
Invoke
(
Sub
()
DirectCast
(
controller
,
ICommandHandler
(
Of
TypeCharCommandArgs
)).
ExecuteCommand
(
New
TypeCharCommandArgs
(
CreateMock
(
Of
ITextView
),
CreateMock
(
Of
ITextBuffer
),
" "
c
),
Sub
()
GetMocks
(
controller
).
Buffer
.
Insert
(
0
,
" "
)))
Dim
handled
=
dispatcher
.
InvokeAsync
(
Function
()
controller
.
TryHandleUpKey
())
' Send the controller an up key, which should block on the computation
checkpoint
.
Release
()
' Allow slowprovider to finish
Await
handled
.
Task
.
ConfigureAwait
(
False
)
' We expect 2 calls to the presenter (because we had an existing presentation session when we started the second computation).
Assert
.
True
(
handled
.
Result
)
GetMocks
(
controller
).
PresenterSession
.
Verify
(
Sub
(
p
)
p
.
PresentItems
(
It
.
IsAny
(
Of
ITrackingSpan
),
It
.
IsAny
(
Of
IList
(
Of
SignatureHelpItem
)),
It
.
IsAny
(
Of
SignatureHelpItem
),
It
.
IsAny
(
Of
Integer
?
)),
Times
.
Exactly
(
2
))
End
Function
Await
worker
().
ConfigureAwait
(
False
)
End
Function
<
WpfFact
>
Public
Sub
DownKeyShouldNavigateWhenThereAreMultipleItems
()
Dim
controller
=
CreateController
(
items
:
=
CreateItems
(
2
),
waitForPresentation
:
=
True
)
...
...
@@ -195,6 +267,9 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.IntelliSense
Dim
presenter
=
New
Mock
(
Of
IIntelliSensePresenter
(
Of
ISignatureHelpPresenterSession
,
ISignatureHelpSession
))
With
{.
DefaultValue
=
DefaultValue
.
Mock
}
presenterSession
=
If
(
presenterSession
,
New
Mock
(
Of
ISignatureHelpPresenterSession
)
With
{.
DefaultValue
=
DefaultValue
.
Mock
})
presenter
.
Setup
(
Function
(
p
)
p
.
CreateSession
(
It
.
IsAny
(
Of
ITextView
),
It
.
IsAny
(
Of
ITextBuffer
),
It
.
IsAny
(
Of
ISignatureHelpSession
))).
Returns
(
presenterSession
.
Object
)
presenterSession
.
Setup
(
Sub
(
p
)
p
.
PresentItems
(
It
.
IsAny
(
Of
ITrackingSpan
),
It
.
IsAny
(
Of
IList
(
Of
SignatureHelpItem
)),
It
.
IsAny
(
Of
SignatureHelpItem
),
It
.
IsAny
(
Of
Integer
?
)))
_
.
Callback
(
Sub
()
presenterSession
.
SetupGet
(
Function
(
p
)
p
.
EditorSessionIsActive
).
Returns
(
True
))
Dim
controller
=
New
Controller
(
view
.
Object
,
...
...
src/EditorFeatures/Test2/IntelliSense/TestSignatureHelpPresenterSession.vb
浏览文件 @
631e9fa1
...
...
@@ -13,6 +13,13 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.IntelliSense
Public
SignatureHelpItems
As
IList
(
Of
SignatureHelpItem
)
Public
SelectedItem
As
SignatureHelpItem
Public
SelectedParameter
As
Integer
?
Private
presented
As
Boolean
=
False
Public
ReadOnly
Property
EditorSessionIsActive
As
Boolean
Implements
ISignatureHelpPresenterSession
.
EditorSessionIsActive
Get
Return
presented
End
Get
End
Property
Public
Event
Dismissed
As
EventHandler
(
Of
EventArgs
)
Implements
ISignatureHelpPresenterSession
.
Dismissed
Public
Event
ItemSelected
As
EventHandler
(
Of
SignatureHelpItemEventArgs
)
Implements
ISignatureHelpPresenterSession
.
ItemSelected
...
...
@@ -30,10 +37,12 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.IntelliSense
Me
.
SignatureHelpItems
=
signatureHelpItems
Me
.
SelectedItem
=
selectedItem
Me
.
SelectedParameter
=
selectedParameter
Me
.
presented
=
True
End
Sub
Public
Sub
Dismiss
()
Implements
ISignatureHelpPresenterSession
.
Dismiss
_testState
.
CurrentSignatureHelpPresenterSession
=
Nothing
Me
.
presented
=
False
End
Sub
Public
Sub
SetSelectedItem
(
item
As
SignatureHelpItem
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录