Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
193c8215
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,发现更多精彩内容 >>
提交
193c8215
编写于
11月 27, 2016
作者:
C
CyrusNajmabadi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Reduce locations where we wait on getting a Model.
上级
e054d2c3
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
23 addition
and
30 deletion
+23
-30
src/EditorFeatures/Core/Implementation/IntelliSense/Completion/AsyncCompletionService.cs
...ntation/IntelliSense/Completion/AsyncCompletionService.cs
+2
-6
src/EditorFeatures/Core/Implementation/IntelliSense/Completion/Controller_Backspace.cs
...mentation/IntelliSense/Completion/Controller_Backspace.cs
+1
-1
src/EditorFeatures/Core/Implementation/IntelliSense/Completion/Controller_TypeChar.cs
...ementation/IntelliSense/Completion/Controller_TypeChar.cs
+20
-23
未找到文件。
src/EditorFeatures/Core/Implementation/IntelliSense/Completion/AsyncCompletionService.cs
浏览文件 @
193c8215
...
@@ -5,7 +5,6 @@
...
@@ -5,7 +5,6 @@
using
System.Collections.Immutable
;
using
System.Collections.Immutable
;
using
System.ComponentModel.Composition
;
using
System.ComponentModel.Composition
;
using
System.Linq
;
using
System.Linq
;
using
Microsoft.CodeAnalysis.Editor.Host
;
using
Microsoft.CodeAnalysis.Editor.Shared.Extensions
;
using
Microsoft.CodeAnalysis.Editor.Shared.Extensions
;
using
Microsoft.CodeAnalysis.Editor.Shared.Options
;
using
Microsoft.CodeAnalysis.Editor.Shared.Options
;
using
Microsoft.CodeAnalysis.Editor.Shared.Utilities
;
using
Microsoft.CodeAnalysis.Editor.Shared.Utilities
;
...
@@ -36,14 +35,12 @@ internal class AsyncCompletionService : ForegroundThreadAffinitizedObject, IAsyn
...
@@ -36,14 +35,12 @@ internal class AsyncCompletionService : ForegroundThreadAffinitizedObject, IAsyn
IEditorOperationsFactoryService
editorOperationsFactoryService
,
IEditorOperationsFactoryService
editorOperationsFactoryService
,
ITextUndoHistoryRegistry
undoHistoryRegistry
,
ITextUndoHistoryRegistry
undoHistoryRegistry
,
IInlineRenameService
inlineRenameService
,
IInlineRenameService
inlineRenameService
,
IWaitIndicator
waitIndicator
,
[
ImportMany
]
IEnumerable
<
Lazy
<
IAsynchronousOperationListener
,
FeatureMetadata
>>
asyncListeners
,
[
ImportMany
]
IEnumerable
<
Lazy
<
IAsynchronousOperationListener
,
FeatureMetadata
>>
asyncListeners
,
[
ImportMany
]
IEnumerable
<
Lazy
<
IIntelliSensePresenter
<
ICompletionPresenterSession
,
ICompletionSession
>,
OrderableMetadata
>>
completionPresenters
,
[
ImportMany
]
IEnumerable
<
Lazy
<
IIntelliSensePresenter
<
ICompletionPresenterSession
,
ICompletionSession
>,
OrderableMetadata
>>
completionPresenters
,
[
ImportMany
]
IEnumerable
<
Lazy
<
IBraceCompletionSessionProvider
,
BraceCompletionMetadata
>>
autoBraceCompletionChars
)
[
ImportMany
]
IEnumerable
<
Lazy
<
IBraceCompletionSessionProvider
,
BraceCompletionMetadata
>>
autoBraceCompletionChars
)
:
this
(
editorOperationsFactoryService
,
undoHistoryRegistry
,
inlineRenameService
,
waitIndicator
,
:
this
(
editorOperationsFactoryService
,
undoHistoryRegistry
,
inlineRenameService
,
ExtensionOrderer
.
Order
(
completionPresenters
).
Select
(
lazy
=>
lazy
.
Value
).
FirstOrDefault
(),
ExtensionOrderer
.
Order
(
completionPresenters
).
Select
(
lazy
=>
lazy
.
Value
).
FirstOrDefault
(),
asyncListeners
,
asyncListeners
,
autoBraceCompletionChars
)
autoBraceCompletionChars
)
{
{
}
}
...
@@ -51,7 +48,6 @@ internal class AsyncCompletionService : ForegroundThreadAffinitizedObject, IAsyn
...
@@ -51,7 +48,6 @@ internal class AsyncCompletionService : ForegroundThreadAffinitizedObject, IAsyn
IEditorOperationsFactoryService
editorOperationsFactoryService
,
IEditorOperationsFactoryService
editorOperationsFactoryService
,
ITextUndoHistoryRegistry
undoHistoryRegistry
,
ITextUndoHistoryRegistry
undoHistoryRegistry
,
IInlineRenameService
inlineRenameService
,
IInlineRenameService
inlineRenameService
,
IWaitIndicator
waitIndicator
,
IIntelliSensePresenter
<
ICompletionPresenterSession
,
ICompletionSession
>
completionPresenter
,
IIntelliSensePresenter
<
ICompletionPresenterSession
,
ICompletionSession
>
completionPresenter
,
IEnumerable
<
Lazy
<
IAsynchronousOperationListener
,
FeatureMetadata
>>
asyncListeners
,
IEnumerable
<
Lazy
<
IAsynchronousOperationListener
,
FeatureMetadata
>>
asyncListeners
,
IEnumerable
<
Lazy
<
IBraceCompletionSessionProvider
,
BraceCompletionMetadata
>>
autoBraceCompletionChars
)
IEnumerable
<
Lazy
<
IBraceCompletionSessionProvider
,
BraceCompletionMetadata
>>
autoBraceCompletionChars
)
...
...
src/EditorFeatures/Core/Implementation/IntelliSense/Completion/Controller_Backspace.cs
浏览文件 @
193c8215
src/EditorFeatures/Core/Implementation/IntelliSense/Completion/Controller_TypeChar.cs
浏览文件 @
193c8215
...
@@ -96,27 +96,24 @@ void ICommandHandler<TypeCharCommandArgs>.ExecuteCommand(TypeCharCommandArgs arg
...
@@ -96,27 +96,24 @@ void ICommandHandler<TypeCharCommandArgs>.ExecuteCommand(TypeCharCommandArgs arg
// that goes into the other side of the seam, the character may be a commit character.
// that goes into the other side of the seam, the character may be a commit character.
// If it's a commit character, just commit without trying to check caret position,
// If it's a commit character, just commit without trying to check caret position,
// since the caret is no longer in our buffer.
// since the caret is no longer in our buffer.
if
(
isOnSeam
&&
this
.
IsCommitCharacter
(
args
.
TypedCha
r
))
if
(
isOnSeam
&&
this
.
CommitIfCommitCharacter
(
args
.
TypedChar
,
initialTextSnapshot
,
nextHandle
r
))
{
{
this
.
CommitOnTypeChar
(
args
.
TypedChar
,
initialTextSnapshot
,
nextHandler
);
return
;
return
;
}
}
else
if
(
_autoBraceCompletionChars
.
Contains
(
args
.
TypedChar
)
&&
if
(
_autoBraceCompletionChars
.
Contains
(
args
.
TypedChar
)
&&
this
.
SubjectBuffer
.
GetFeatureOnOffOption
(
InternalFeatureOnOffOptions
.
AutomaticPairCompletion
)
&&
this
.
SubjectBuffer
.
GetFeatureOnOffOption
(
InternalFeatureOnOffOptions
.
AutomaticPairCompletion
)
&&
this
.
IsCommitCharacter
(
args
.
TypedCha
r
))
this
.
CommitIfCommitCharacter
(
args
.
TypedChar
,
initialTextSnapshot
,
nextHandle
r
))
{
{
// I don't think there is any better way than this. if typed char is one of auto brace completion char,
// I don't think there is any better way than this. if typed char is one of auto brace completion char,
// we don't do multiple buffer change check
// we don't do multiple buffer change check
this
.
CommitOnTypeChar
(
args
.
TypedChar
,
initialTextSnapshot
,
nextHandler
);
return
;
return
;
}
}
else
{
// If we were computing anything, we stop. We only want to process a typechar
// If we were computing anything, we stop. We only want to process a typechar
// if it was a normal character.
// if it was a normal character.
this
.
StopModelComputation
();
this
.
StopModelComputation
();
}
}
}
return
;
return
;
}
}
...
@@ -214,15 +211,10 @@ void ICommandHandler<TypeCharCommandArgs>.ExecuteCommand(TypeCharCommandArgs arg
...
@@ -214,15 +211,10 @@ void ICommandHandler<TypeCharCommandArgs>.ExecuteCommand(TypeCharCommandArgs arg
// buffer.
// buffer.
// Now, commit if it was a commit character.
// Now, commit if it was a commit character.
if
(
this
.
IsCommitCharacter
(
args
.
TypedChar
))
if
(!
this
.
CommitIfCommitCharacter
(
args
.
TypedChar
,
initialTextSnapshot
,
nextHandler
))
{
// Known to be a commit character for the currently selected item. So just
// commit the session.
this
.
CommitOnTypeChar
(
args
.
TypedChar
,
initialTextSnapshot
,
nextHandler
);
}
else
{
{
// Now dismiss the session.
// Wasn't a filter or commit character. Stop what we're doing as we have
// no idea what this is.
this
.
StopModelComputation
();
this
.
StopModelComputation
();
}
}
...
@@ -298,12 +290,12 @@ private bool IsTextualTriggerCharacter(CompletionService completionService, char
...
@@ -298,12 +290,12 @@ private bool IsTextualTriggerCharacter(CompletionService completionService, char
return
completionService
.
ShouldTriggerCompletion
(
previousPosition
.
Snapshot
.
AsText
(),
caretPosition
,
trigger
,
_roles
,
options
);
return
completionService
.
ShouldTriggerCompletion
(
previousPosition
.
Snapshot
.
AsText
(),
caretPosition
,
trigger
,
_roles
,
options
);
}
}
private
bool
IsCommitCharacter
(
char
ch
)
private
bool
IsCommitCharacter
(
char
ch
,
out
Model
model
)
{
{
AssertIsForeground
();
AssertIsForeground
();
// TODO(cyrusn): Find a way to allow the user to cancel out of this.
// TODO(cyrusn): Find a way to allow the user to cancel out of this.
var
model
=
sessionOpt
.
WaitForModel
();
model
=
sessionOpt
.
WaitForModel
();
if
(
model
==
null
||
model
.
IsSoftSelection
)
if
(
model
==
null
||
model
.
IsSoftSelection
)
{
{
return
false
;
return
false
;
...
@@ -440,14 +432,18 @@ private string GetTextTypedSoFar(Model model, CompletionItem selectedItem)
...
@@ -440,14 +432,18 @@ private string GetTextTypedSoFar(Model model, CompletionItem selectedItem)
return
filterText
;
return
filterText
;
}
}
private
void
CommitOnTypeCha
r
(
private
bool
CommitIfCommitCharacte
r
(
char
ch
,
ITextSnapshot
initialTextSnapshot
,
Action
nextHandler
)
char
ch
,
ITextSnapshot
initialTextSnapshot
,
Action
nextHandler
)
{
{
AssertIsForeground
();
AssertIsForeground
();
// Note: this function is called after the character has already been inserted into the
// Note: this function is called after the character has already been inserted into the
// buffer.
// buffer.
var
model
=
sessionOpt
.
WaitForModel
();
if
(!
IsCommitCharacter
(
ch
,
out
var
model
))
{
return
false
;
}
// We only call CommitOnTypeChar if ch was a commit character. And we only know if ch
// We only call CommitOnTypeChar if ch was a commit character. And we only know if ch
// was commit character if we had a selected item.
// was commit character if we had a selected item.
...
@@ -456,6 +452,7 @@ private string GetTextTypedSoFar(Model model, CompletionItem selectedItem)
...
@@ -456,6 +452,7 @@ private string GetTextTypedSoFar(Model model, CompletionItem selectedItem)
this
.
Commit
(
this
.
Commit
(
model
.
SelectedItem
,
model
,
ch
,
model
.
SelectedItem
,
model
,
ch
,
initialTextSnapshot
,
nextHandler
);
initialTextSnapshot
,
nextHandler
);
return
true
;
}
}
}
}
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录