Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
150b9bde
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,发现更多精彩内容 >>
提交
150b9bde
编写于
3月 20, 2019
作者:
D
David Barbet
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Reorder workspace/document/service checks in command handler to be more performant
上级
00b38c25
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
62 addition
and
49 deletion
+62
-49
src/EditorFeatures/Core/GoToImplementation/GoToImplementationCommandHandler.cs
...re/GoToImplementation/GoToImplementationCommandHandler.cs
+13
-5
src/EditorFeatures/Core/Implementation/ChangeSignature/AbstractChangeSignatureCommandHandler.cs
.../ChangeSignature/AbstractChangeSignatureCommandHandler.cs
+9
-6
src/EditorFeatures/Core/Implementation/ExtractInterface/AbstractExtractInterfaceCommandHandler.cs
...xtractInterface/AbstractExtractInterfaceCommandHandler.cs
+12
-8
src/EditorFeatures/Core/Implementation/ExtractMethod/AbstractExtractMethodCommandHandler.cs
...tion/ExtractMethod/AbstractExtractMethodCommandHandler.cs
+14
-8
src/EditorFeatures/Core/Implementation/Organizing/OrganizeDocumentCommandHandler.cs
...plementation/Organizing/OrganizeDocumentCommandHandler.cs
+11
-15
src/VisualStudio/Core/Def/Implementation/CallHierarchy/CallHierarchyCommandHandler.cs
...plementation/CallHierarchy/CallHierarchyCommandHandler.cs
+3
-7
未找到文件。
src/EditorFeatures/Core/GoToImplementation/GoToImplementationCommandHandler.cs
浏览文件 @
150b9bde
...
...
@@ -52,16 +52,24 @@ public bool ExecuteCommand(GoToImplementationCommandArgs args, CommandExecutionC
using
(
context
.
OperationContext
.
AddScope
(
allowCancellation
:
true
,
EditorFeaturesResources
.
Locating_implementations
))
{
var
subjectBuffer
=
args
.
SubjectBuffer
;
var
document
=
subjectBuffer
.
CurrentSnapshot
.
GetFullyLoadedOpenDocumentInCurrentContextWithChangesAsync
(
context
.
OperationContext
).
WaitAndGetResult
(
context
.
OperationContext
.
UserCancellationToken
);
var
findUsagesService
=
document
?.
GetLanguageService
<
IFindUsagesService
>();
if
(!
Workspace
.
TryGetWorkspace
(
subjectBuffer
.
AsTextContainer
(),
out
var
workspace
))
{
return
false
;
}
var
findUsagesService
=
workspace
.
Services
.
GetLanguageServices
(
args
.
SubjectBuffer
)?.
GetService
<
IFindUsagesService
>();
if
(
findUsagesService
!=
null
)
{
var
caret
=
args
.
TextView
.
GetCaretPoint
(
args
.
SubjectBuffer
);
if
(
caret
.
HasValue
)
{
ExecuteCommand
(
document
,
caret
.
Value
,
findUsagesService
,
context
);
return
true
;
var
document
=
subjectBuffer
.
CurrentSnapshot
.
GetFullyLoadedOpenDocumentInCurrentContextWithChangesAsync
(
context
.
OperationContext
).
WaitAndGetResult
(
context
.
OperationContext
.
UserCancellationToken
);
if
(
document
!=
null
)
{
ExecuteCommand
(
document
,
caret
.
Value
,
findUsagesService
,
context
);
return
true
;
}
}
}
...
...
src/EditorFeatures/Core/Implementation/ChangeSignature/AbstractChangeSignatureCommandHandler.cs
浏览文件 @
150b9bde
...
...
@@ -56,21 +56,17 @@ private bool ExecuteCommand(ITextView textView, ITextBuffer subjectBuffer, Comma
{
using
(
context
.
OperationContext
.
AddScope
(
allowCancellation
:
true
,
FeaturesResources
.
Change_signature
))
{
var
document
=
subjectBuffer
.
CurrentSnapshot
.
GetFullyLoadedOpenDocumentInCurrentContextWithChangesAsync
(
context
.
OperationContext
).
WaitAndGetResult
(
context
.
OperationContext
.
UserCancellationToken
);
if
(
document
==
null
)
if
(!
Workspace
.
TryGetWorkspace
(
subjectBuffer
.
AsTextContainer
(),
out
var
workspace
))
{
return
false
;
}
// TODO: reuse GetCommandState instead
var
workspace
=
document
.
Project
.
Solution
.
Workspace
;
if
(!
workspace
.
CanApplyChange
(
ApplyChangesKind
.
ChangeDocument
))
{
return
false
;
}
var
supportsFeatureService
=
document
.
Project
.
Solution
.
W
orkspace
.
Services
.
GetService
<
ITextBufferSupportsFeatureService
>();
var
supportsFeatureService
=
w
orkspace
.
Services
.
GetService
<
ITextBufferSupportsFeatureService
>();
if
(!
supportsFeatureService
.
SupportsRefactorings
(
subjectBuffer
))
{
return
false
;
...
...
@@ -82,6 +78,13 @@ private bool ExecuteCommand(ITextView textView, ITextBuffer subjectBuffer, Comma
return
false
;
}
var
document
=
subjectBuffer
.
CurrentSnapshot
.
GetFullyLoadedOpenDocumentInCurrentContextWithChangesAsync
(
context
.
OperationContext
).
WaitAndGetResult
(
context
.
OperationContext
.
UserCancellationToken
);
if
(
document
==
null
)
{
return
false
;
}
var
reorderParametersService
=
document
.
GetLanguageService
<
AbstractChangeSignatureService
>();
var
result
=
reorderParametersService
.
ChangeSignature
(
document
,
...
...
src/EditorFeatures/Core/Implementation/ExtractInterface/AbstractExtractInterfaceCommandHandler.cs
浏览文件 @
150b9bde
...
...
@@ -50,33 +50,37 @@ public bool ExecuteCommand(ExtractInterfaceCommandArgs args, CommandExecutionCon
{
using
(
context
.
OperationContext
.
AddScope
(
allowCancellation
:
true
,
EditorFeaturesResources
.
Extract_Interface
))
{
var
document
=
args
.
SubjectBuffer
.
CurrentSnapshot
.
GetFullyLoadedOpenDocumentInCurrentContextWithChangesAsync
(
context
.
OperationContext
).
WaitAndGetResult
(
context
.
OperationContext
.
UserCancellationToken
);
if
(
document
==
null
)
var
subjectBuffer
=
args
.
SubjectBuffer
;
if
(!
Workspace
.
TryGetWorkspace
(
subjectBuffer
.
AsTextContainer
(),
out
var
workspace
))
{
return
false
;
}
var
workspace
=
document
.
Project
.
Solution
.
Workspace
;
if
(!
workspace
.
CanApplyChange
(
ApplyChangesKind
.
AddDocument
)
||
!
workspace
.
CanApplyChange
(
ApplyChangesKind
.
ChangeDocument
))
{
return
false
;
}
var
supportsFeatureService
=
document
.
Project
.
Solution
.
W
orkspace
.
Services
.
GetService
<
ITextBufferSupportsFeatureService
>();
if
(!
supportsFeatureService
.
SupportsRefactorings
(
args
.
S
ubjectBuffer
))
var
supportsFeatureService
=
w
orkspace
.
Services
.
GetService
<
ITextBufferSupportsFeatureService
>();
if
(!
supportsFeatureService
.
SupportsRefactorings
(
s
ubjectBuffer
))
{
return
false
;
}
var
caretPoint
=
args
.
TextView
.
GetCaretPoint
(
args
.
S
ubjectBuffer
);
var
caretPoint
=
args
.
TextView
.
GetCaretPoint
(
s
ubjectBuffer
);
if
(!
caretPoint
.
HasValue
)
{
return
false
;
}
var
document
=
subjectBuffer
.
CurrentSnapshot
.
GetFullyLoadedOpenDocumentInCurrentContextWithChangesAsync
(
context
.
OperationContext
).
WaitAndGetResult
(
context
.
OperationContext
.
UserCancellationToken
);
if
(
document
==
null
)
{
return
false
;
}
// We are about to show a modal UI dialog so we should take over the command execution
// wait context. That means the command system won't attempt to show its own wait dialog
// and also will take it into consideration when measuring command handling duration.
...
...
src/EditorFeatures/Core/Implementation/ExtractMethod/AbstractExtractMethodCommandHandler.cs
浏览文件 @
150b9bde
...
...
@@ -72,23 +72,29 @@ public VSCommanding.CommandState GetCommandState(ExtractMethodCommandArgs args)
public
bool
ExecuteCommand
(
ExtractMethodCommandArgs
args
,
CommandExecutionContext
context
)
{
var
document
=
args
.
SubjectBuffer
.
CurrentSnapshot
.
GetOpenDocumentInCurrentContextWithChanges
();
if
(
document
==
null
)
// Finish any rename that had been started. We'll do this here before we enter the
// wait indicator for Extract Method
if
(
_renameService
.
ActiveSession
!=
null
)
{
_renameService
.
ActiveSession
.
Commit
();
}
var
subjectBuffer
=
args
.
SubjectBuffer
;
if
(!
Workspace
.
TryGetWorkspace
(
subjectBuffer
.
AsTextContainer
(),
out
var
workspace
))
{
return
false
;
}
var
supportsFeatureService
=
document
.
Project
.
Solution
.
W
orkspace
.
Services
.
GetService
<
ITextBufferSupportsFeatureService
>();
if
(!
supportsFeatureService
.
SupportsRefactorings
(
args
.
S
ubjectBuffer
))
var
supportsFeatureService
=
w
orkspace
.
Services
.
GetService
<
ITextBufferSupportsFeatureService
>();
if
(!
supportsFeatureService
.
SupportsRefactorings
(
s
ubjectBuffer
))
{
return
false
;
}
// Finish any rename that had been started. We'll do this here before we enter the
// wait indicator for Extract Method
if
(
_renameService
.
ActiveSession
!=
null
)
var
document
=
subjectBuffer
.
CurrentSnapshot
.
GetOpenDocumentInCurrentContextWithChanges
();
if
(
document
==
null
)
{
_renameService
.
ActiveSession
.
Commit
()
;
return
false
;
}
using
(
context
.
OperationContext
.
AddScope
(
allowCancellation
:
true
,
EditorFeaturesResources
.
Applying_Extract_Method_refactoring
))
...
...
src/EditorFeatures/Core/Implementation/Organizing/OrganizeDocumentCommandHandler.cs
浏览文件 @
150b9bde
...
...
@@ -40,7 +40,17 @@ public bool ExecuteCommand(OrganizeDocumentCommandArgs args, CommandExecutionCon
{
using
(
context
.
OperationContext
.
AddScope
(
allowCancellation
:
true
,
EditorFeaturesResources
.
Organizing_document
))
{
this
.
Organize
(
args
.
SubjectBuffer
,
context
.
OperationContext
);
var
cancellationToken
=
context
.
OperationContext
.
UserCancellationToken
;
var
document
=
args
.
SubjectBuffer
.
CurrentSnapshot
.
GetFullyLoadedOpenDocumentInCurrentContextWithChangesAsync
(
context
.
OperationContext
)
.
WaitAndGetResult
(
cancellationToken
);
if
(
document
!=
null
)
{
var
newDocument
=
OrganizingService
.
OrganizeAsync
(
document
,
cancellationToken
:
cancellationToken
).
WaitAndGetResult
(
cancellationToken
);
if
(
document
!=
newDocument
)
{
ApplyTextChange
(
document
,
newDocument
);
}
}
}
return
true
;
...
...
@@ -99,20 +109,6 @@ public bool ExecuteCommand(SortAndRemoveUnnecessaryImportsCommandArgs args, Comm
return
true
;
}
private
void
Organize
(
ITextBuffer
subjectBuffer
,
IUIThreadOperationContext
operationContext
)
{
var
cancellationToken
=
operationContext
.
UserCancellationToken
;
var
document
=
subjectBuffer
.
CurrentSnapshot
.
GetFullyLoadedOpenDocumentInCurrentContextWithChangesAsync
(
operationContext
).
WaitAndGetResult
(
cancellationToken
);
if
(
document
!=
null
)
{
var
newDocument
=
OrganizingService
.
OrganizeAsync
(
document
,
cancellationToken
:
cancellationToken
).
WaitAndGetResult
(
cancellationToken
);
if
(
document
!=
newDocument
)
{
ApplyTextChange
(
document
,
newDocument
);
}
}
}
private
void
SortAndRemoveUnusedImports
(
ITextBuffer
subjectBuffer
,
IUIThreadOperationContext
operationContext
)
{
var
cancellationToken
=
operationContext
.
UserCancellationToken
;
...
...
src/VisualStudio/Core/Def/Implementation/CallHierarchy/CallHierarchyCommandHandler.cs
浏览文件 @
150b9bde
...
...
@@ -36,12 +36,6 @@ public CallHierarchyCommandHandler([ImportMany] IEnumerable<ICallHierarchyPresen
}
public
bool
ExecuteCommand
(
ViewCallHierarchyCommandArgs
args
,
CommandExecutionContext
context
)
{
AddRootNode
(
args
,
context
);
return
true
;
}
private
void
AddRootNode
(
ViewCallHierarchyCommandArgs
args
,
CommandExecutionContext
context
)
{
using
(
var
waitScope
=
context
.
OperationContext
.
AddScope
(
allowCancellation
:
true
,
EditorFeaturesResources
.
Computing_Call_Hierarchy_Information
))
{
...
...
@@ -50,7 +44,7 @@ private void AddRootNode(ViewCallHierarchyCommandArgs args, CommandExecutionCont
context
.
OperationContext
).
WaitAndGetResult
(
cancellationToken
);
if
(
document
==
null
)
{
return
;
return
true
;
}
var
workspace
=
document
.
Project
.
Solution
.
Workspace
;
...
...
@@ -85,6 +79,8 @@ private void AddRootNode(ViewCallHierarchyCommandArgs args, CommandExecutionCont
notificationService
.
SendNotification
(
EditorFeaturesResources
.
Cursor_must_be_on_a_member_name
,
severity
:
NotificationSeverity
.
Information
);
}
}
return
true
;
}
public
VSCommanding
.
CommandState
GetCommandState
(
ViewCallHierarchyCommandArgs
args
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录