Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
58d8babc
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,发现更多精彩内容 >>
提交
58d8babc
编写于
3月 14, 2019
作者:
H
HeeJae Chang
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'partial_load' of
https://github.com/dibarbet/roslyn
into partial_load_hechang
上级
d963e714
45e61aa3
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
78 addition
and
78 deletion
+78
-78
src/EditorFeatures/Core/GoToImplementation/GoToImplementationCommandHandler.cs
...re/GoToImplementation/GoToImplementationCommandHandler.cs
+17
-17
src/EditorFeatures/Core/Implementation/ChangeSignature/AbstractChangeSignatureCommandHandler.cs
.../ChangeSignature/AbstractChangeSignatureCommandHandler.cs
+61
-61
未找到文件。
src/EditorFeatures/Core/GoToImplementation/GoToImplementationCommandHandler.cs
浏览文件 @
58d8babc
...
...
@@ -16,6 +16,7 @@
using
Microsoft.VisualStudio.Commanding
;
using
Microsoft.VisualStudio.Text
;
using
Microsoft.VisualStudio.Utilities
;
using
Roslyn.Utilities
;
using
VSCommanding
=
Microsoft
.
VisualStudio
.
Commanding
;
namespace
Microsoft.CodeAnalysis.Editor.GoToImplementation
...
...
@@ -34,18 +35,13 @@ internal partial class GoToImplementationCommandHandler : VSCommanding.ICommandH
_streamingPresenters
=
streamingPresenters
;
}
private
(
Document
,
IFindUsagesService
)
GetDocumentAndService
(
ITextSnapshot
snapshot
)
{
var
document
=
snapshot
.
GetOpenDocumentInCurrentContextWithChanges
();
return
(
document
,
document
?.
GetLanguageService
<
IFindUsagesService
>());
}
public
string
DisplayName
=>
EditorFeaturesResources
.
Go_To_Implementation
;
public
VSCommanding
.
CommandState
GetCommandState
(
GoToImplementationCommandArgs
args
)
{
// Because this is expensive to compute, we just always say yes as long as the language allows it.
var
(
document
,
findUsagesService
)
=
GetDocumentAndService
(
args
.
SubjectBuffer
.
CurrentSnapshot
);
var
document
=
args
.
SubjectBuffer
.
CurrentSnapshot
.
GetOpenDocumentInCurrentContextWithChanges
();
var
findUsagesService
=
document
?.
GetLanguageService
<
IFindUsagesService
>();
return
findUsagesService
!=
null
?
VSCommanding
.
CommandState
.
Available
:
VSCommanding
.
CommandState
.
Unavailable
;
...
...
@@ -53,18 +49,24 @@ public VSCommanding.CommandState GetCommandState(GoToImplementationCommandArgs a
public
bool
ExecuteCommand
(
GoToImplementationCommandArgs
args
,
CommandExecutionContext
context
)
{
var
(
document
,
findUsagesService
)
=
GetDocumentAndService
(
args
.
SubjectBuffer
.
CurrentSnapshot
);
if
(
findUsagesService
!=
null
)
using
(
context
.
OperationContext
.
AddScope
(
allowCancellation
:
true
,
EditorFeaturesResources
.
Locating_implementations
))
{
var
caret
=
args
.
TextView
.
GetCaretPoint
(
args
.
SubjectBuffer
);
if
(
caret
.
HasValue
)
var
subjectBuffer
=
args
.
SubjectBuffer
;
var
document
=
subjectBuffer
.
CurrentSnapshot
.
GetFullyLoadedOpenDocumentInCurrentContextWithChangesAsync
(
context
.
OperationContext
).
WaitAndGetResult
(
context
.
OperationContext
.
UserCancellationToken
);
var
findUsagesService
=
document
?.
GetLanguageService
<
IFindUsagesService
>();
if
(
findUsagesService
!=
null
)
{
ExecuteCommand
(
document
,
caret
.
Value
,
findUsagesService
,
context
);
return
true
;
var
caret
=
args
.
TextView
.
GetCaretPoint
(
args
.
SubjectBuffer
);
if
(
caret
.
HasValue
)
{
ExecuteCommand
(
document
,
caret
.
Value
,
findUsagesService
,
context
);
return
true
;
}
}
}
return
false
;
return
false
;
}
}
private
void
ExecuteCommand
(
...
...
@@ -80,8 +82,6 @@ public bool ExecuteCommand(GoToImplementationCommandArgs args, CommandExecutionC
string
messageToShow
=
null
;
var
userCancellationToken
=
context
.
OperationContext
.
UserCancellationToken
;
using
(
context
.
OperationContext
.
AddScope
(
allowCancellation
:
true
,
EditorFeaturesResources
.
Locating_implementations
))
using
(
Logger
.
LogBlock
(
FunctionId
.
CommandHandler_GoToImplementation
,
KeyValueLogMessage
.
Create
(
LogType
.
UserAction
),
userCancellationToken
))
{
StreamingGoToImplementation
(
...
...
src/EditorFeatures/Core/Implementation/ChangeSignature/AbstractChangeSignatureCommandHandler.cs
浏览文件 @
58d8babc
...
...
@@ -12,6 +12,7 @@
using
Microsoft.VisualStudio.Text
;
using
Microsoft.VisualStudio.Text.Editor
;
using
Microsoft.VisualStudio.Text.Editor.Commanding.Commands
;
using
Roslyn.Utilities
;
using
VSCommanding
=
Microsoft
.
VisualStudio
.
Commanding
;
namespace
Microsoft.CodeAnalysis.Editor.Implementation.ChangeSignature
...
...
@@ -53,37 +54,36 @@ public bool ExecuteCommand(ReorderParametersCommandArgs args, CommandExecutionCo
private
bool
ExecuteCommand
(
ITextView
textView
,
ITextBuffer
subjectBuffer
,
CommandExecutionContext
context
)
{
var
document
=
subjectBuffer
.
CurrentSnapshot
.
GetOpenDocumentInCurrentContextWithChanges
();
if
(
document
==
null
)
{
return
false
;
}
// TODO: reuse GetCommandState instead
var
workspace
=
document
.
Project
.
Solution
.
Workspace
;
if
(!
workspace
.
CanApplyChange
(
ApplyChangesKind
.
ChangeDocument
))
using
(
context
.
OperationContext
.
AddScope
(
allowCancellation
:
true
,
FeaturesResources
.
Change_signature
))
{
return
false
;
}
var
document
=
subjectBuffer
.
CurrentSnapshot
.
GetFullyLoadedOpenDocumentInCurrentContextWithChangesAsync
(
context
.
OperationContext
).
WaitAndGetResult
(
context
.
OperationContext
.
UserCancellationToken
);
if
(
document
==
null
)
{
return
false
;
}
var
supportsFeatureService
=
document
.
Project
.
Solution
.
Workspace
.
Services
.
GetService
<
IDocumentSupportsFeatureService
>();
if
(!
supportsFeatureService
.
SupportsRefactorings
(
document
))
{
return
false
;
}
// TODO: reuse GetCommandState instead
var
workspace
=
document
.
Project
.
Solution
.
Workspace
;
if
(!
workspace
.
CanApplyChange
(
ApplyChangesKind
.
ChangeDocument
))
{
return
false
;
}
var
caretPoint
=
textView
.
GetCaretPoint
(
subjectBuffer
);
if
(!
caretPoint
.
HasValue
)
{
return
false
;
}
var
supportsFeatureService
=
document
.
Project
.
Solution
.
Workspace
.
Services
.
GetService
<
IDocumentSupportsFeatureService
>(
);
if
(!
supportsFeatureService
.
SupportsRefactorings
(
document
)
)
{
return
false
;
}
ChangeSignatureResult
result
=
null
;
var
caretPoint
=
textView
.
GetCaretPoint
(
subjectBuffer
);
if
(!
caretPoint
.
HasValue
)
{
return
false
;
}
using
(
context
.
OperationContext
.
AddScope
(
allowCancellation
:
true
,
FeaturesResources
.
Change_signature
))
{
var
reorderParametersService
=
document
.
GetLanguageService
<
AbstractChangeSignatureService
>();
result
=
reorderParametersService
.
ChangeSignature
(
var
result
=
reorderParametersService
.
ChangeSignature
(
document
,
caretPoint
.
Value
.
Position
,
(
errorMessage
,
severity
)
=>
...
...
@@ -94,51 +94,51 @@ private bool ExecuteCommand(ITextView textView, ITextBuffer subjectBuffer, Comma
context
.
OperationContext
.
TakeOwnership
();
workspace
.
Services
.
GetService
<
INotificationService
>().
SendNotification
(
errorMessage
,
severity
:
severity
);
},
context
.
OperationContext
.
UserCancellationToken
);
}
context
.
OperationContext
.
UserCancellationToken
);
if
(
result
==
null
||
!
result
.
Succeeded
)
{
return
true
;
}
var
finalSolution
=
result
.
UpdatedSolution
;
if
(
result
==
null
||
!
result
.
Succeeded
)
{
return
true
;
}
var
previewService
=
workspace
.
Services
.
GetService
<
IPreviewDialogService
>();
if
(
previewService
!=
null
&&
result
.
PreviewChanges
)
{
// 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.
context
.
OperationContext
.
TakeOwnership
();
finalSolution
=
previewService
.
PreviewChanges
(
string
.
Format
(
EditorFeaturesResources
.
Preview_Changes_0
,
EditorFeaturesResources
.
Change_Signature
),
"vs.csharp.refactoring.preview"
,
EditorFeaturesResources
.
Change_Signature_colon
,
result
.
Name
,
result
.
Glyph
.
GetValueOrDefault
(),
result
.
UpdatedSolution
,
document
.
Project
.
Solution
);
}
var
finalSolution
=
result
.
UpdatedSolution
;
if
(
finalSolution
==
null
)
{
// User clicked cancel.
return
true
;
}
var
previewService
=
workspace
.
Services
.
GetService
<
IPreviewDialogService
>();
if
(
previewService
!=
null
&&
result
.
PreviewChanges
)
{
// 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.
context
.
OperationContext
.
TakeOwnership
();
finalSolution
=
previewService
.
PreviewChanges
(
string
.
Format
(
EditorFeaturesResources
.
Preview_Changes_0
,
EditorFeaturesResources
.
Change_Signature
),
"vs.csharp.refactoring.preview"
,
EditorFeaturesResources
.
Change_Signature_colon
,
result
.
Name
,
result
.
Glyph
.
GetValueOrDefault
(),
result
.
UpdatedSolution
,
document
.
Project
.
Solution
);
}
using
(
var
workspaceUndoTransaction
=
workspace
.
OpenGlobalUndoTransaction
(
FeaturesResources
.
Change_signature
))
{
if
(!
workspace
.
TryApplyChanges
(
finalSolution
))
if
(
finalSolution
==
null
)
{
//
TODO: handle failure
//
User clicked cancel.
return
true
;
}
workspaceUndoTransaction
.
Commit
();
}
using
(
var
workspaceUndoTransaction
=
workspace
.
OpenGlobalUndoTransaction
(
FeaturesResources
.
Change_signature
))
{
if
(!
workspace
.
TryApplyChanges
(
finalSolution
))
{
// TODO: handle failure
return
true
;
}
workspaceUndoTransaction
.
Commit
();
}
return
true
;
return
true
;
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录