Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
95721089
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,发现更多精彩内容 >>
提交
95721089
编写于
7月 18, 2019
作者:
P
Petr Houska
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Cleanup + adding `OverlapsHiddenPosition` to ref. helper service.
上级
c93525af
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
11 addition
and
16 deletion
+11
-16
src/Features/Core/Portable/CodeRefactorings/AbstractRefactoringHelpersService.cs
...ble/CodeRefactorings/AbstractRefactoringHelpersService.cs
+10
-9
src/Features/Core/Portable/CodeRefactorings/AddAwait/AbstractAddAwaitCodeRefactoringProvider.cs
...rings/AddAwait/AbstractAddAwaitCodeRefactoringProvider.cs
+0
-5
src/Features/Core/Portable/InvertIf/AbstractInvertIfCodeRefactoringProvider.cs
...table/InvertIf/AbstractInvertIfCodeRefactoringProvider.cs
+1
-2
未找到文件。
src/Features/Core/Portable/CodeRefactorings/AbstractRefactoringHelpersService.cs
浏览文件 @
95721089
...
...
@@ -77,8 +77,7 @@ internal abstract class AbstractRefactoringHelpersService : IRefactoringHelpersS
var
prevNode
=
selectionNode
;
do
{
var
acceptedNode
=
ExtractNodesSimple
(
selectionNode
,
syntaxFacts
).
OfType
<
TSyntaxNode
>().
FirstOrDefault
(
predicate
);
if
(
acceptedNode
!=
null
)
if
(
TryGetAcceptedNode
(
ExtractNodesSimple
(
selectionNode
,
syntaxFacts
),
predicate
,
out
var
acceptedNode
,
cancellationToken
))
{
// For selections we need to handle an edge case where only AttributeLists are within selection (e.g. `Func([|[in][out]|] arg1);`).
// In that case the smallest encompassing node is still the whole argument node but it's hard to justify showing refactorings for it
...
...
@@ -182,8 +181,7 @@ internal abstract class AbstractRefactoringHelpersService : IRefactoringHelpersS
// First check if we're in a header of some higher-level node what would pass predicate & if we are -> return it
// We can't check any sooner because the code above (that figures out tokenToLeft, ...) can change current
// `location`.
var
acceptedHeaderNode
=
ExtractNodesIfInHeader
(
root
,
location
,
syntaxFacts
).
OfType
<
TSyntaxNode
>().
FirstOrDefault
(
predicate
);
if
(
acceptedHeaderNode
!=
null
)
if
(
TryGetAcceptedNode
(
ExtractNodesIfInHeader
(
root
,
location
,
syntaxFacts
),
predicate
,
out
var
acceptedHeaderNode
,
cancellationToken
))
{
return
acceptedHeaderNode
;
}
...
...
@@ -197,8 +195,7 @@ internal abstract class AbstractRefactoringHelpersService : IRefactoringHelpersS
// Consider either a Node that is:
// - Parent of touched Token (location can be within)
// - Ancestor Node of such Token as long as their span starts on location (it's still on the edge)
var
acceptedNode
=
ExtractNodesSimple
(
rightNode
,
syntaxFacts
).
OfType
<
TSyntaxNode
>().
FirstOrDefault
(
predicate
);
if
(
acceptedNode
!=
null
)
if
(
TryGetAcceptedNode
(
ExtractNodesSimple
(
rightNode
,
syntaxFacts
),
predicate
,
out
var
acceptedNode
,
cancellationToken
))
{
return
acceptedNode
;
}
...
...
@@ -235,8 +232,7 @@ internal abstract class AbstractRefactoringHelpersService : IRefactoringHelpersS
{
// Consider either a Node that is:
// - Ancestor Node of such Token as long as their span ends on location (it's still on the edge)
var
acceptedNode
=
ExtractNodesSimple
(
leftNode
,
syntaxFacts
).
OfType
<
TSyntaxNode
>().
FirstOrDefault
(
predicate
);
if
(
acceptedNode
!=
null
)
if
(
TryGetAcceptedNode
(
ExtractNodesSimple
(
leftNode
,
syntaxFacts
),
predicate
,
out
var
acceptedNode
,
cancellationToken
))
{
return
acceptedNode
;
}
...
...
@@ -251,8 +247,13 @@ internal abstract class AbstractRefactoringHelpersService : IRefactoringHelpersS
}
// nothing found -> return null
return
null
;
static
bool
TryGetAcceptedNode
(
IEnumerable
<
SyntaxNode
>
extractedNodes
,
Func
<
TSyntaxNode
,
bool
>
predicate
,
out
TSyntaxNode
acceptedNode
,
CancellationToken
cancellationToken
)
{
acceptedNode
=
extractedNodes
.
OfType
<
TSyntaxNode
>().
FirstOrDefault
(
predicate
);
return
acceptedNode
!=
null
&&
!
acceptedNode
.
OverlapsHiddenPosition
(
cancellationToken
);
}
}
private
static
TextSpan
GetSpanWithoutAttributes
(
SyntaxNode
node
,
SyntaxNode
root
,
ISyntaxFactsService
syntaxFacts
)
...
...
src/Features/Core/Portable/CodeRefactorings/AddAwait/AbstractAddAwaitCodeRefactoringProvider.cs
浏览文件 @
95721089
...
...
@@ -49,11 +49,6 @@ public sealed override async Task ComputeRefactoringsAsync(CodeRefactoringContex
var
root
=
await
document
.
GetSyntaxRootAsync
(
cancellationToken
).
ConfigureAwait
(
false
);
var
token
=
root
.
FindTokenOnLeftOfPosition
(
textSpan
.
Start
);
if
(
awaitable
.
OverlapsHiddenPosition
(
cancellationToken
))
{
return
;
}
context
.
RegisterRefactoring
(
new
MyCodeAction
(
GetTitle
(),
...
...
src/Features/Core/Portable/InvertIf/AbstractInvertIfCodeRefactoringProvider.cs
浏览文件 @
95721089
...
...
@@ -41,8 +41,7 @@ public sealed override async Task ComputeRefactoringsAsync(CodeRefactoringContex
var
root
=
await
document
.
GetSyntaxRootAsync
(
cancellationToken
).
ConfigureAwait
(
false
);
var
ifNode
=
await
context
.
TryGetSelectedNodeAsync
<
TIfStatementSyntax
>().
ConfigureAwait
(
false
);
if
(
ifNode
==
null
||
ifNode
.
OverlapsHiddenPosition
(
cancellationToken
))
if
(
ifNode
==
null
)
{
return
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录