Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
c9a92456
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,发现更多精彩内容 >>
提交
c9a92456
编写于
3月 21, 2019
作者:
D
David Barbet
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
address feedback
上级
f798663c
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
41 addition
and
100 deletion
+41
-100
src/EditorFeatures/Core.Wpf/InlineRename/CommandHandlers/RenameCommandHandler_RenameHandler.cs
...ame/CommandHandlers/RenameCommandHandler_RenameHandler.cs
+1
-1
src/EditorFeatures/Core.Wpf/InlineRename/InlineRenameSession.cs
...itorFeatures/Core.Wpf/InlineRename/InlineRenameSession.cs
+1
-1
src/EditorFeatures/Core.Wpf/Suggestions/SuggestedActionsSource.cs
...orFeatures/Core.Wpf/Suggestions/SuggestedActionsSource.cs
+2
-6
src/EditorFeatures/Core/CommandHandlers/GoToAdjacentMemberCommandHandler.cs
.../Core/CommandHandlers/GoToAdjacentMemberCommandHandler.cs
+2
-15
src/EditorFeatures/Core/Implementation/ChangeSignature/AbstractChangeSignatureCommandHandler.cs
.../ChangeSignature/AbstractChangeSignatureCommandHandler.cs
+7
-16
src/EditorFeatures/Core/Implementation/EncapsulateField/AbstractEncapsulateFieldCommandHandler.cs
...ncapsulateField/AbstractEncapsulateFieldCommandHandler.cs
+2
-4
src/EditorFeatures/Core/Implementation/ExtractInterface/AbstractExtractInterfaceCommandHandler.cs
...xtractInterface/AbstractExtractInterfaceCommandHandler.cs
+7
-18
src/EditorFeatures/Core/Implementation/ExtractMethod/AbstractExtractMethodCommandHandler.cs
...tion/ExtractMethod/AbstractExtractMethodCommandHandler.cs
+1
-1
src/EditorFeatures/Core/Implementation/Organizing/OrganizeDocumentCommandHandler.cs
...plementation/Organizing/OrganizeDocumentCommandHandler.cs
+1
-1
src/EditorFeatures/Core/Shared/Extensions/ITextBufferExtensions.cs
...rFeatures/Core/Shared/Extensions/ITextBufferExtensions.cs
+17
-37
未找到文件。
src/EditorFeatures/Core.Wpf/InlineRename/CommandHandlers/RenameCommandHandler_RenameHandler.cs
浏览文件 @
c9a92456
...
...
@@ -26,7 +26,7 @@ public VSCommanding.CommandState GetCommandState(RenameCommandArgs args)
if
(!
args
.
SubjectBuffer
.
TryGetOwningWorkspace
(
out
var
workspace
)
||
!
workspace
.
CanApplyChange
(
ApplyChangesKind
.
ChangeDocument
)
||
!
args
.
SubjectBuffer
.
SupportsRename
(
workspace
))
!
args
.
SubjectBuffer
.
SupportsRename
())
{
return
VSCommanding
.
CommandState
.
Unspecified
;
}
...
...
src/EditorFeatures/Core.Wpf/InlineRename/InlineRenameSession.cs
浏览文件 @
c9a92456
...
...
@@ -245,7 +245,7 @@ private bool TryPopulateOpenTextBufferManagerForBuffer(ITextBuffer buffer)
}
}
if
(!
_openTextBuffers
.
ContainsKey
(
buffer
)
&&
buffer
.
SupportsRename
(
_workspace
))
if
(!
_openTextBuffers
.
ContainsKey
(
buffer
)
&&
buffer
.
SupportsRename
())
{
_openTextBuffers
[
buffer
]
=
new
OpenTextBufferManager
(
this
,
buffer
,
_workspace
,
_textBufferFactoryService
);
return
true
;
...
...
src/EditorFeatures/Core.Wpf/Suggestions/SuggestedActionsSource.cs
浏览文件 @
c9a92456
...
...
@@ -790,10 +790,8 @@ private static SuggestedActionSetPriority GetSuggestedActionSetPriority(CodeActi
SnapshotSpan
range
,
CancellationToken
cancellationToken
)
{
var
workspace
=
document
.
Project
.
Solution
.
Workspace
;
if
(
provider
.
_codeFixService
!=
null
&&
_subjectBuffer
.
SupportsCodeFixes
(
workspace
))
_subjectBuffer
.
SupportsCodeFixes
())
{
var
result
=
await
provider
.
_codeFixService
.
GetMostSevereFixableDiagnosticAsync
(
document
,
range
.
Span
.
ToTextSpan
(),
cancellationToken
).
ConfigureAwait
(
false
);
...
...
@@ -828,11 +826,9 @@ private static SuggestedActionSetPriority GetSuggestedActionSetPriority(CodeActi
return
null
;
}
var
workspace
=
document
.
Project
.
Solution
.
Workspace
;
if
(
document
.
Project
.
Solution
.
Options
.
GetOption
(
EditorComponentOnOffOptions
.
CodeRefactorings
)
&&
provider
.
_codeRefactoringService
!=
null
&&
_subjectBuffer
.
SupportsRefactorings
(
workspace
))
_subjectBuffer
.
SupportsRefactorings
())
{
if
(
await
provider
.
_codeRefactoringService
.
HasRefactoringsAsync
(
document
,
selection
.
Value
,
cancellationToken
).
ConfigureAwait
(
false
))
...
...
src/EditorFeatures/Core/CommandHandlers/GoToAdjacentMemberCommandHandler.cs
浏览文件 @
c9a92456
...
...
@@ -75,21 +75,8 @@ private VSCommanding.CommandState GetCommandStateImpl(EditorCommandArgs args)
return
VSCommanding
.
CommandState
.
Available
;
}
private
static
bool
IsAvailable
(
SnapshotPoint
?
caretPoint
,
ITextBuffer
subjectBuffer
)
{
if
(!
caretPoint
.
HasValue
)
{
return
false
;
}
if
(!
subjectBuffer
.
TryGetOwningWorkspace
(
out
var
workspace
)
||
!
subjectBuffer
.
SupportsNavigationToAnyPosition
(
workspace
))
{
return
false
;
}
return
true
;
}
private
static
bool
IsAvailable
(
SnapshotPoint
?
caretPoint
,
ITextBuffer
subjectBuffer
)
=>
caretPoint
.
HasValue
&&
subjectBuffer
.
SupportsNavigationToAnyPosition
();
private
bool
ExecuteCommandImpl
(
EditorCommandArgs
args
,
bool
gotoNextMember
,
CommandExecutionContext
context
)
{
...
...
src/EditorFeatures/Core/Implementation/ChangeSignature/AbstractChangeSignatureCommandHandler.cs
浏览文件 @
c9a92456
...
...
@@ -28,10 +28,8 @@ public VSCommanding.CommandState GetCommandState(ReorderParametersCommandArgs ar
public
VSCommanding
.
CommandState
GetCommandState
(
RemoveParametersCommandArgs
args
)
=>
GetCommandState
(
args
.
SubjectBuffer
);
private
static
VSCommanding
.
CommandState
GetCommandState
(
ITextBuffer
subjectBuffer
)
{
return
IsAvailable
(
subjectBuffer
)
?
VSCommanding
.
CommandState
.
Available
:
VSCommanding
.
CommandState
.
Unspecified
;
}
private
static
VSCommanding
.
CommandState
GetCommandState
(
ITextBuffer
subjectBuffer
)
=>
IsAvailable
(
subjectBuffer
,
out
_
)
?
VSCommanding
.
CommandState
.
Available
:
VSCommanding
.
CommandState
.
Unspecified
;
public
bool
ExecuteCommand
(
RemoveParametersCommandArgs
args
,
CommandExecutionContext
context
)
=>
ExecuteCommand
(
args
.
TextView
,
args
.
SubjectBuffer
,
context
);
...
...
@@ -39,23 +37,16 @@ public bool ExecuteCommand(RemoveParametersCommandArgs args, CommandExecutionCon
public
bool
ExecuteCommand
(
ReorderParametersCommandArgs
args
,
CommandExecutionContext
context
)
=>
ExecuteCommand
(
args
.
TextView
,
args
.
SubjectBuffer
,
context
);
private
static
bool
IsAvailable
(
ITextBuffer
subjectBuffer
)
{
if
(!
subjectBuffer
.
TryGetOwningWorkspace
(
out
var
workspace
)
||
!
workspace
.
CanApplyChange
(
ApplyChangesKind
.
ChangeDocument
)
||
!
subjectBuffer
.
SupportsRefactorings
(
workspace
))
{
return
false
;
}
return
true
;
}
private
static
bool
IsAvailable
(
ITextBuffer
subjectBuffer
,
out
Workspace
workspace
)
=>
subjectBuffer
.
TryGetOwningWorkspace
(
out
workspace
)
&&
workspace
.
CanApplyChange
(
ApplyChangesKind
.
ChangeDocument
)
&&
subjectBuffer
.
SupportsRefactorings
();
private
bool
ExecuteCommand
(
ITextView
textView
,
ITextBuffer
subjectBuffer
,
CommandExecutionContext
context
)
{
using
(
context
.
OperationContext
.
AddScope
(
allowCancellation
:
true
,
FeaturesResources
.
Change_signature
))
{
if
(
IsAvailable
(
subjectBuffer
))
if
(
!
IsAvailable
(
subjectBuffer
,
out
var
workspace
))
{
return
false
;
}
...
...
src/EditorFeatures/Core/Implementation/EncapsulateField/AbstractEncapsulateFieldCommandHandler.cs
浏览文件 @
c9a92456
...
...
@@ -117,9 +117,7 @@ private bool Execute(EncapsulateFieldCommandArgs args, IUIThreadOperationScope w
}
}
public
VSCommanding
.
CommandState
GetCommandState
(
EncapsulateFieldCommandArgs
args
)
{
return
args
.
SubjectBuffer
.
SupportsRefactorings
()
?
VSCommanding
.
CommandState
.
Available
:
VSCommanding
.
CommandState
.
Unspecified
;
}
public
VSCommanding
.
CommandState
GetCommandState
(
EncapsulateFieldCommandArgs
args
)
=>
args
.
SubjectBuffer
.
SupportsRefactorings
()
?
VSCommanding
.
CommandState
.
Available
:
VSCommanding
.
CommandState
.
Unspecified
;
}
}
src/EditorFeatures/Core/Implementation/ExtractInterface/AbstractExtractInterfaceCommandHandler.cs
浏览文件 @
c9a92456
...
...
@@ -28,10 +28,8 @@ protected AbstractExtractInterfaceCommandHandler(IThreadingContext threadingCont
public
string
DisplayName
=>
EditorFeaturesResources
.
Extract_Interface
;
public
VSCommanding
.
CommandState
GetCommandState
(
ExtractInterfaceCommandArgs
args
)
{
return
IsAvailable
(
args
.
SubjectBuffer
,
out
var
_
)
?
VSCommanding
.
CommandState
.
Available
:
VSCommanding
.
CommandState
.
Unspecified
;
}
public
VSCommanding
.
CommandState
GetCommandState
(
ExtractInterfaceCommandArgs
args
)
=>
IsAvailable
(
args
.
SubjectBuffer
,
out
var
_
)
?
VSCommanding
.
CommandState
.
Available
:
VSCommanding
.
CommandState
.
Unspecified
;
public
bool
ExecuteCommand
(
ExtractInterfaceCommandArgs
args
,
CommandExecutionContext
context
)
{
...
...
@@ -86,19 +84,10 @@ public bool ExecuteCommand(ExtractInterfaceCommandArgs args, CommandExecutionCon
}
}
private
static
bool
IsAvailable
(
ITextBuffer
subjectBuffer
,
out
Workspace
workspace
)
{
if
(!
subjectBuffer
.
TryGetOwningWorkspace
(
out
var
retrievedWorkspace
)
||
!
retrievedWorkspace
.
CanApplyChange
(
ApplyChangesKind
.
AddDocument
)
||
!
retrievedWorkspace
.
CanApplyChange
(
ApplyChangesKind
.
ChangeDocument
)
||
!
subjectBuffer
.
SupportsRefactorings
(
retrievedWorkspace
))
{
workspace
=
retrievedWorkspace
;
return
false
;
}
workspace
=
retrievedWorkspace
;
return
true
;
}
private
static
bool
IsAvailable
(
ITextBuffer
subjectBuffer
,
out
Workspace
workspace
)
=>
subjectBuffer
.
TryGetOwningWorkspace
(
out
workspace
)
&&
workspace
.
CanApplyChange
(
ApplyChangesKind
.
AddDocument
)
&&
workspace
.
CanApplyChange
(
ApplyChangesKind
.
ChangeDocument
)
&&
subjectBuffer
.
SupportsRefactorings
();
}
}
src/EditorFeatures/Core/Implementation/ExtractMethod/AbstractExtractMethodCommandHandler.cs
浏览文件 @
c9a92456
...
...
@@ -52,7 +52,7 @@ public VSCommanding.CommandState GetCommandState(ExtractMethodCommandArgs args)
if
(!
args
.
SubjectBuffer
.
TryGetOwningWorkspace
(
out
var
workspace
)
||
!
workspace
.
CanApplyChange
(
ApplyChangesKind
.
ChangeDocument
)
||
!
args
.
SubjectBuffer
.
SupportsRefactorings
(
workspace
))
!
args
.
SubjectBuffer
.
SupportsRefactorings
())
{
return
VSCommanding
.
CommandState
.
Unspecified
;
}
...
...
src/EditorFeatures/Core/Implementation/Organizing/OrganizeDocumentCommandHandler.cs
浏览文件 @
c9a92456
...
...
@@ -90,7 +90,7 @@ private bool IsCommandSupported(EditorCommandArgs args, out Workspace workspace)
return
false
;
}
return
args
.
SubjectBuffer
.
SupportsRefactorings
(
workspace
);
return
args
.
SubjectBuffer
.
SupportsRefactorings
();
}
return
false
;
...
...
src/EditorFeatures/Core/Shared/Extensions/ITextBufferExtensions.cs
浏览文件 @
c9a92456
...
...
@@ -44,61 +44,41 @@ internal static bool GetFeatureOnOffOption(this ITextBuffer buffer, PerLanguageO
}
}
internal
static
bool
TryGetOwningWorkspace
(
this
ITextBuffer
buffer
,
out
Workspace
workspace
)
{
workspace
=
null
;
if
(
Workspace
.
TryGetWorkspace
(
buffer
.
AsTextContainer
(),
out
var
retrievedWorkspace
))
{
workspace
=
retrievedWorkspace
;
}
return
workspace
!=
null
;
}
/// <summary>
/// Checks if the buffer supports refactorings.
/// Additionally retrieves the workspace for the buffer.
/// </summary>
internal
static
bool
SupportsRefactorings
(
this
ITextBuffer
buffer
)
{
return
buffer
.
TryGetOwningWorkspace
(
out
var
workspace
)
&&
buffer
.
SupportsRefactorings
(
workspace
);
}
internal
static
bool
TryGetOwningWorkspace
(
this
ITextBuffer
buffer
,
out
Workspace
workspace
)
=>
Workspace
.
TryGetWorkspace
(
buffer
.
AsTextContainer
(),
out
workspace
);
/// <summary>
/// Checks if a buffer supports refactorings.
/// </summary>
internal
static
bool
SupportsRefactorings
(
this
ITextBuffer
buffer
,
Workspace
workspace
)
{
return
TryGetSupportsFeatureService
(
workspace
,
out
var
service
)
&&
service
.
SupportsRefactorings
(
buffer
);
}
internal
static
bool
SupportsRefactorings
(
this
ITextBuffer
buffer
)
=>
TryGetSupportsFeatureService
(
buffer
,
out
var
service
)
&&
service
.
SupportsRefactorings
(
buffer
);
/// <summary>
/// Checks if a buffer supports rename.
/// </summary>
internal
static
bool
SupportsRename
(
this
ITextBuffer
buffer
,
Workspace
workspace
)
{
return
TryGetSupportsFeatureService
(
workspace
,
out
var
service
)
&&
service
.
SupportsRename
(
buffer
);
}
internal
static
bool
SupportsRename
(
this
ITextBuffer
buffer
)
=>
TryGetSupportsFeatureService
(
buffer
,
out
var
service
)
&&
service
.
SupportsRename
(
buffer
);
/// <summary>
/// Checks if a buffer supports code fixes.
/// </summary>
internal
static
bool
SupportsCodeFixes
(
this
ITextBuffer
buffer
,
Workspace
workspace
)
{
return
TryGetSupportsFeatureService
(
workspace
,
out
var
service
)
&&
service
.
SupportsCodeFixes
(
buffer
);
}
internal
static
bool
SupportsCodeFixes
(
this
ITextBuffer
buffer
)
=>
TryGetSupportsFeatureService
(
buffer
,
out
var
service
)
&&
service
.
SupportsCodeFixes
(
buffer
);
/// <summary>
/// Checks if a buffer supports navigation.
/// </summary>
internal
static
bool
SupportsNavigationToAnyPosition
(
this
ITextBuffer
buffer
,
Workspace
workspace
)
{
return
TryGetSupportsFeatureService
(
workspace
,
out
var
service
)
&&
service
.
SupportsNavigationToAnyPosition
(
buffer
);
}
internal
static
bool
SupportsNavigationToAnyPosition
(
this
ITextBuffer
buffer
)
=>
TryGetSupportsFeatureService
(
buffer
,
out
var
service
)
&&
service
.
SupportsNavigationToAnyPosition
(
buffer
);
private
static
bool
TryGetSupportsFeatureService
(
Workspace
workspace
,
out
ITextBufferSupportsFeatureService
service
)
private
static
bool
TryGetSupportsFeatureService
(
ITextBuffer
buffer
,
out
ITextBufferSupportsFeatureService
service
)
{
service
=
workspace
.
Services
.
GetService
<
ITextBufferSupportsFeatureService
>();
service
=
null
;
if
(
buffer
.
TryGetOwningWorkspace
(
out
var
workspace
))
{
service
=
workspace
.
Services
.
GetService
<
ITextBufferSupportsFeatureService
>();
}
return
service
!=
null
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录