Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
c91d10a1
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,发现更多精彩内容 >>
提交
c91d10a1
编写于
7月 14, 2019
作者:
P
Petr Houska
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
PR feedback cleanup.
上级
c465bfeb
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
30 addition
and
32 deletion
+30
-32
src/Features/Core/Portable/IntroduceUsingStatement/AbstractIntroduceUsingStatementCodeRefactoringProvider.cs
...AbstractIntroduceUsingStatementCodeRefactoringProvider.cs
+0
-5
src/Workspaces/CSharp/Portable/LanguageServices/CSharpSyntaxFactsService.cs
...arp/Portable/LanguageServices/CSharpSyntaxFactsService.cs
+2
-2
src/Workspaces/Core/Portable/LanguageServices/SyntaxFactsService/AbstractSyntaxFactsService.cs
...Services/SyntaxFactsService/AbstractSyntaxFactsService.cs
+24
-18
src/Workspaces/Core/Portable/LanguageServices/SyntaxFactsService/ISyntaxFactsService.cs
...anguageServices/SyntaxFactsService/ISyntaxFactsService.cs
+0
-1
src/Workspaces/VisualBasic/Portable/LanguageServices/VisualBasicSyntaxFactsService.vb
...ortable/LanguageServices/VisualBasicSyntaxFactsService.vb
+4
-6
未找到文件。
src/Features/Core/Portable/IntroduceUsingStatement/AbstractIntroduceUsingStatementCodeRefactoringProvider.cs
浏览文件 @
c91d10a1
...
...
@@ -50,11 +50,6 @@ private async Task<(TLocalDeclarationSyntax, ILocalSymbol)> FindDisposableLocalD
var
refactoringHelperService
=
document
.
GetLanguageService
<
IRefactoringHelpersService
>();
var
declarationSyntax
=
await
refactoringHelperService
.
TryGetSelectedNodeAsync
<
TLocalDeclarationSyntax
>(
document
,
selection
,
cancellationToken
).
ConfigureAwait
(
false
);
if
(
declarationSyntax
==
null
)
{
return
default
;
}
if
(
declarationSyntax
is
null
||
!
CanRefactorToContainBlockStatements
(
declarationSyntax
.
Parent
))
{
return
default
;
...
...
src/Workspaces/CSharp/Portable/LanguageServices/CSharpSyntaxFactsService.cs
浏览文件 @
c91d10a1
...
...
@@ -1846,8 +1846,8 @@ public bool IsOnLocalDeclarationHeader(SyntaxNode root, int position, out Syntax
var
initializersExpressions
=
node
.
Declaration
.
Variables
.
Where
(
v
=>
v
.
Initializer
!=
null
)
.
Select
(
initializedV
=>
initializedV
.
Initializer
.
Value
).
ToImmutableArray
<
SyntaxNode
>(
);
return
Is
InHeader
(
position
,
node
,
node
,
initializersExpressions
);
.
Select
AsArray
(
initializedV
=>
initializedV
.
Initializer
.
Value
);
return
Is
OnHeader
(
position
,
node
,
node
,
holes
:
initializersExpressions
);
}
public
bool
IsBetweenTypeMembers
(
SourceText
sourceText
,
SyntaxNode
root
,
int
position
)
...
...
src/Workspaces/Core/Portable/LanguageServices/SyntaxFactsService/AbstractSyntaxFactsService.cs
浏览文件 @
c91d10a1
...
...
@@ -489,24 +489,25 @@ private bool SpansPreprocessorDirective(SyntaxTriviaList list)
=>
list
.
Any
(
t
=>
IsPreprocessorDirective
(
t
));
public
bool
IsOnHeader
(
int
position
,
SyntaxNode
ownerOfHeader
,
SyntaxNodeOrToken
lastTokenOrNodeOfHeader
)
{
var
start
=
GetStartOfNodeExcludingAttributes
(
ownerOfHeader
);
var
end
=
lastTokenOrNodeOfHeader
.
FullSpan
.
End
;
return
start
<=
position
&&
position
<=
end
;
}
=>
IsOnHeader
(
position
,
ownerOfHeader
,
lastTokenOrNodeOfHeader
,
ImmutableArray
<
SyntaxNode
>.
Empty
);
public
bool
IsInHeader
(
int
position
,
SyntaxNode
ownerOfHeader
,
SyntaxNodeOrToken
lastTokenOrNodeOfHeader
,
ImmutableArray
<
SyntaxNode
>
holes
)
public
bool
IsOnHeader
<
THoleSyntax
>(
int
position
,
SyntaxNode
ownerOfHeader
,
SyntaxNodeOrToken
lastTokenOrNodeOfHeader
,
ImmutableArray
<
THoleSyntax
>
holes
)
where
THoleSyntax
:
SyntaxNode
{
var
inHeader
=
IsOnHeader
(
position
,
ownerOfHeader
,
lastTokenOrNodeOfHeader
);
if
(!
inHeader
)
var
headerSpan
=
TextSpan
.
FromBounds
(
start
:
GetStartOfNodeExcludingAttributes
(
ownerOfHeader
),
end
:
lastTokenOrNodeOfHeader
.
FullSpan
.
End
);
// Is in header check is inclusive, being on the end edge of an header still counts
if
(!
headerSpan
.
IntersectsWith
(
position
))
{
return
false
;
}
// Holes are exclusive: to return false it needs to be _inside_ a hole not only on the edge
// -> to be consistent with other 'being on the edge' of Tokens/Nodes.
if
(
holes
.
Any
(
h
=>
(
h
.
Span
.
Start
<
position
&&
position
<
h
.
Span
.
End
)))
// Holes are exclusive:
// To be consistent with other 'being on the edge' of Tokens/Nodes a position is
// in a hole (not in a header) only if it's inside _inside_ a hole, not only on the edge.
if
(
holes
.
Any
(
h
=>
h
.
Span
.
Contains
(
position
)
&&
position
>
h
.
Span
.
Start
))
{
return
false
;
}
...
...
@@ -520,15 +521,20 @@ public bool IsInHeader(int position, SyntaxNode ownerOfHeader, SyntaxNodeOrToken
/// </summary>
protected
static
TNode
TryGetAncestorForLocation
<
TNode
>(
int
position
,
SyntaxNode
root
)
where
TNode
:
SyntaxNode
{
var
token
=
root
.
FindToken
(
position
);
var
node
=
token
.
GetAncestor
<
TNode
>();
if
(
node
==
null
&&
token
.
FullSpan
.
Start
==
position
)
var
tokenToRightOrIn
=
root
.
FindToken
(
position
);
var
nodeToRightOrIn
=
tokenToRightOrIn
.
GetAncestor
<
TNode
>();
if
(
nodeToRightOrIn
!=
null
)
{
return
nodeToRightOrIn
;
}
// not at the beginning of a Token -> no (different) token to the left
if
(
tokenToRightOrIn
.
FullSpan
.
Start
!=
position
)
{
token
=
token
.
GetPreviousToken
();
node
=
token
.
GetAncestor
<
TNode
>();
return
null
;
}
return
node
;
return
tokenToRightOrIn
.
GetPreviousToken
().
GetAncestor
<
TNode
>()
;
}
protected
int
GetStartOfNodeExcludingAttributes
(
SyntaxNode
node
)
...
...
src/Workspaces/Core/Portable/LanguageServices/SyntaxFactsService/ISyntaxFactsService.cs
浏览文件 @
c91d10a1
...
...
@@ -412,7 +412,6 @@ internal interface ISyntaxFactsService : ILanguageService
ImmutableArray
<
SyntaxNode
>
GetSelectedFieldsAndProperties
(
SyntaxNode
root
,
TextSpan
textSpan
,
bool
allowPartialSelection
);
bool
IsOnTypeHeader
(
SyntaxNode
root
,
int
position
);
bool
IsOnHeader
(
int
position
,
SyntaxNode
ownerOfHeader
,
SyntaxNodeOrToken
lastTokenOrNodeOfHeader
);
bool
IsOnPropertyDeclarationHeader
(
SyntaxNode
root
,
int
position
,
out
SyntaxNode
propertyDeclaration
);
bool
IsOnParameterHeader
(
SyntaxNode
root
,
int
position
,
out
SyntaxNode
parameter
);
bool
IsOnMethodHeader
(
SyntaxNode
root
,
int
position
,
out
SyntaxNode
method
);
...
...
src/Workspaces/VisualBasic/Portable/LanguageServices/VisualBasicSyntaxFactsService.vb
浏览文件 @
c91d10a1
...
...
@@ -1734,10 +1734,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Return
position
>=
start
AndAlso
position
<=
_end
End
Function
Private
Function
ISyntaxFactsService_IsInHeader
(
position
As
Integer
,
ownerOfHeader
As
SyntaxNode
,
lastTokenOrNodeOfHeader
As
SyntaxNodeOrToken
)
As
Boolean
Implements
ISyntaxFactsService
.
IsOnHeader
Return
IsOnHeader
(
position
,
ownerOfHeader
,
lastTokenOrNodeOfHeader
)
End
Function
Public
Function
IsOnPropertyDeclarationHeader
(
root
As
SyntaxNode
,
position
As
Integer
,
ByRef
propertyDeclaration
As
SyntaxNode
)
As
Boolean
Implements
ISyntaxFactsService
.
IsOnPropertyDeclarationHeader
Dim
node
=
TryGetAncestorForLocation
(
Of
PropertyStatementSyntax
)(
position
,
root
)
propertyDeclaration
=
node
...
...
@@ -1796,8 +1792,10 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Return
False
End
If
Dim
initializersExpressions
=
node
.
Declarators
.
Where
(
Function
(
d
)
d
.
Initializer
IsNot
Nothing
).
[
Select
]
(
Function
(
initializedd
)
initializedd
.
Initializer
.
Value
).
Cast
(
Of
SyntaxNode
).
ToImmutableArray
()
Return
IsInHeader
(
position
,
node
,
node
,
initializersExpressions
)
Dim
initializersExpressions
=
node
.
Declarators
.
Where
(
Function
(
d
)
d
.
Initializer
IsNot
Nothing
).
SelectAsArray
(
Function
(
initialized
)
initialized
.
Initializer
.
Value
)
Return
IsOnHeader
(
position
,
node
,
node
,
initializersExpressions
)
End
Function
Public
Function
IsBetweenTypeMembers
(
sourceText
As
SourceText
,
root
As
SyntaxNode
,
position
As
Integer
)
As
Boolean
Implements
ISyntaxFactsService
.
IsBetweenTypeMembers
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录