Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
bcba44a4
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,发现更多精彩内容 >>
提交
bcba44a4
编写于
7月 14, 2019
作者:
P
Petr Houska
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Updated IsOnHeader to follow common pattern.
上级
b216a584
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
19 addition
and
25 deletion
+19
-25
src/Features/CSharp/Portable/GenerateMember/GenerateDefaultConstructors/CSharpGenerateDefaultConstructorsService.cs
...tConstructors/CSharpGenerateDefaultConstructorsService.cs
+1
-1
src/Features/Core/Portable/CodeRefactorings/MoveType/AbstractMoveTypeService.cs
...able/CodeRefactorings/MoveType/AbstractMoveTypeService.cs
+1
-1
src/Features/Core/Portable/GenerateConstructorFromMembers/GenerateConstructorFromMembersCodeRefactoringProvider.cs
.../GenerateConstructorFromMembersCodeRefactoringProvider.cs
+1
-1
src/Features/Core/Portable/GenerateEqualsAndGetHashCodeFromMembers/GenerateEqualsAndGetHashCodeFromMembersCodeRefactoringProvider.cs
...EqualsAndGetHashCodeFromMembersCodeRefactoringProvider.cs
+1
-1
src/Features/Core/Portable/GenerateOverrides/GenerateOverridesCodeRefactoringProvider.cs
...rateOverrides/GenerateOverridesCodeRefactoringProvider.cs
+1
-1
src/Features/VisualBasic/Portable/GenerateMember/GenerateDefaultConstructors/VisualBasicGenerateDefaultConstructorsService.vb
...tructors/VisualBasicGenerateDefaultConstructorsService.vb
+1
-1
src/Workspaces/CSharp/Portable/LanguageServices/CSharpSyntaxFactsService.cs
...arp/Portable/LanguageServices/CSharpSyntaxFactsService.cs
+5
-10
src/Workspaces/Core/Portable/LanguageServices/SyntaxFactsService/ISyntaxFactsService.cs
...anguageServices/SyntaxFactsService/ISyntaxFactsService.cs
+2
-1
src/Workspaces/VisualBasic/Portable/LanguageServices/VisualBasicSyntaxFactsService.vb
...ortable/LanguageServices/VisualBasicSyntaxFactsService.vb
+6
-8
未找到文件。
src/Features/CSharp/Portable/GenerateMember/GenerateDefaultConstructors/CSharpGenerateDefaultConstructorsService.cs
浏览文件 @
bcba44a4
...
...
@@ -31,7 +31,7 @@ public CSharpGenerateDefaultConstructorsService()
// first base-type of a class.
var
syntaxFacts
=
semanticDocument
.
Document
.
GetLanguageService
<
ISyntaxFactsService
>();
if
(
syntaxFacts
.
IsOnTypeHeader
(
semanticDocument
.
Root
,
textSpan
.
Start
))
if
(
syntaxFacts
.
IsOnTypeHeader
(
semanticDocument
.
Root
,
textSpan
.
Start
,
out
_
))
{
classType
=
AbstractGenerateFromMembersCodeRefactoringProvider
.
GetEnclosingNamedType
(
semanticDocument
.
SemanticModel
,
semanticDocument
.
Root
,
textSpan
.
Start
,
cancellationToken
);
...
...
src/Features/Core/Portable/CodeRefactorings/MoveType/AbstractMoveTypeService.cs
浏览文件 @
bcba44a4
...
...
@@ -87,7 +87,7 @@ private async Task<State> CreateStateAsync(Document document, TextSpan textSpan,
}
var
syntaxFacts
=
document
.
GetLanguageService
<
ISyntaxFactsService
>();
var
isOnTypeHeader
=
syntaxFacts
.
IsOnTypeHeader
(
root
,
textSpan
.
Start
);
var
isOnTypeHeader
=
syntaxFacts
.
IsOnTypeHeader
(
root
,
textSpan
.
Start
,
out
_
);
var
semanticDocument
=
await
SemanticDocument
.
CreateAsync
(
document
,
cancellationToken
).
ConfigureAwait
(
false
);
return
State
.
Generate
(
semanticDocument
,
nodeToAnalyze
,
isOnTypeHeader
,
cancellationToken
);
...
...
src/Features/Core/Portable/GenerateConstructorFromMembers/GenerateConstructorFromMembersCodeRefactoringProvider.cs
浏览文件 @
bcba44a4
...
...
@@ -85,7 +85,7 @@ private async Task HandleNonSelectionAsync(CodeRefactoringContext context)
// We offer the refactoring when the user is either on the header of a class/struct,
// or if they're between any members of a class/struct and are on a blank line.
if
(!
syntaxFacts
.
IsOnTypeHeader
(
root
,
textSpan
.
Start
)
&&
if
(!
syntaxFacts
.
IsOnTypeHeader
(
root
,
textSpan
.
Start
,
out
_
)
&&
!
syntaxFacts
.
IsBetweenTypeMembers
(
sourceText
,
root
,
textSpan
.
Start
))
{
return
;
...
...
src/Features/Core/Portable/GenerateEqualsAndGetHashCodeFromMembers/GenerateEqualsAndGetHashCodeFromMembersCodeRefactoringProvider.cs
浏览文件 @
bcba44a4
...
...
@@ -76,7 +76,7 @@ private async Task HandleNonSelectionAsync(CodeRefactoringContext context)
// We offer the refactoring when the user is either on the header of a class/struct,
// or if they're between any members of a class/struct and are on a blank line.
if
(!
syntaxFacts
.
IsOnTypeHeader
(
root
,
textSpan
.
Start
)
&&
if
(!
syntaxFacts
.
IsOnTypeHeader
(
root
,
textSpan
.
Start
,
out
_
)
&&
!
syntaxFacts
.
IsBetweenTypeMembers
(
sourceText
,
root
,
textSpan
.
Start
))
{
return
;
...
...
src/Features/Core/Portable/GenerateOverrides/GenerateOverridesCodeRefactoringProvider.cs
浏览文件 @
bcba44a4
...
...
@@ -39,7 +39,7 @@ public override async Task ComputeRefactoringsAsync(CodeRefactoringContext conte
// We offer the refactoring when the user is either on the header of a class/struct,
// or if they're between any members of a class/struct and are on a blank line.
if
(!
syntaxFacts
.
IsOnTypeHeader
(
root
,
textSpan
.
Start
)
&&
if
(!
syntaxFacts
.
IsOnTypeHeader
(
root
,
textSpan
.
Start
,
out
_
)
&&
!
syntaxFacts
.
IsBetweenTypeMembers
(
sourceText
,
root
,
textSpan
.
Start
))
{
return
;
...
...
src/Features/VisualBasic/Portable/GenerateMember/GenerateDefaultConstructors/VisualBasicGenerateDefaultConstructorsService.vb
浏览文件 @
bcba44a4
...
...
@@ -27,7 +27,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.GenerateMember.GenerateDefaultConst
' first base-type of a class.
Dim
syntaxFacts
=
semanticDocument
.
Document
.
GetLanguageService
(
Of
ISyntaxFactsService
)()
If
syntaxFacts
.
IsOnTypeHeader
(
semanticDocument
.
Root
,
textSpan
.
Start
)
Then
If
syntaxFacts
.
IsOnTypeHeader
(
semanticDocument
.
Root
,
textSpan
.
Start
,
Nothing
)
Then
classType
=
AbstractGenerateFromMembersCodeRefactoringProvider
.
GetEnclosingNamedType
(
semanticDocument
.
SemanticModel
,
semanticDocument
.
Root
,
textSpan
.
Start
,
cancellationToken
)
Return
classType
IsNot
Nothing
AndAlso
classType
.
TypeKind
=
TypeKind
.
Class
...
...
src/Workspaces/CSharp/Portable/LanguageServices/CSharpSyntaxFactsService.cs
浏览文件 @
bcba44a4
...
...
@@ -1770,21 +1770,16 @@ public override SyntaxNode Visit(SyntaxNode node)
}
}
public
bool
IsOnTypeHeader
(
SyntaxNode
root
,
int
position
)
public
bool
IsOnTypeHeader
(
SyntaxNode
root
,
int
position
,
out
SyntaxNode
typeDeclaration
)
{
var
token
=
root
.
FindToken
(
position
);
if
(
token
.
Kind
()
==
SyntaxKind
.
EndOfFileToken
)
{
token
=
token
.
GetPreviousToken
();
}
var
typeDecl
=
token
.
GetAncestor
<
BaseTypeDeclarationSyntax
>();
if
(
typeDecl
==
null
)
var
node
=
TryGetAncestorForLocation
<
BaseTypeDeclarationSyntax
>(
position
,
root
);
typeDeclaration
=
node
;
if
(
node
==
null
)
{
return
false
;
}
return
IsOnHeader
(
position
,
typeDecl
,
typeDecl
.
Identifier
);
return
IsOnHeader
(
position
,
node
,
node
.
Identifier
);
}
public
bool
IsOnPropertyDeclarationHeader
(
SyntaxNode
root
,
int
position
,
out
SyntaxNode
propertyDeclaration
)
...
...
src/Workspaces/Core/Portable/LanguageServices/SyntaxFactsService/ISyntaxFactsService.cs
浏览文件 @
bcba44a4
...
...
@@ -411,7 +411,8 @@ internal interface ISyntaxFactsService : ILanguageService
bool
IsPropertyPatternClause
(
SyntaxNode
node
);
ImmutableArray
<
SyntaxNode
>
GetSelectedFieldsAndProperties
(
SyntaxNode
root
,
TextSpan
textSpan
,
bool
allowPartialSelection
);
bool
IsOnTypeHeader
(
SyntaxNode
root
,
int
position
);
bool
IsOnTypeHeader
(
SyntaxNode
root
,
int
position
,
out
SyntaxNode
typeDeclaration
);
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
浏览文件 @
bcba44a4
...
...
@@ -1721,17 +1721,15 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Return
trivia
.
IsElastic
()
End
Function
Public
Function
IsOnTypeHeader
(
root
As
SyntaxNode
,
position
As
Integer
)
As
Boolean
Implements
ISyntaxFactsService
.
IsOnTypeHeader
Dim
statement
=
root
.
FindToken
(
position
).
GetAncestor
(
Of
TypeStatementSyntax
)
If
statement
Is
Nothing
Then
Public
Function
IsOnTypeHeader
(
root
As
SyntaxNode
,
position
As
Integer
,
ByRef
typeDeclaration
As
SyntaxNode
)
As
Boolean
Implements
ISyntaxFactsService
.
IsOnTypeHeader
Dim
node
=
TryGetAncestorForLocation
(
Of
TypeStatementSyntax
)(
position
,
root
)
typeDeclaration
=
node
If
node
Is
Nothing
Then
Return
Nothing
End
If
Dim
start
=
GetStartOfNodeExcludingAttributes
(
statement
)
Dim
_end
=
If
(
statement
.
TypeParameterList
?
.
GetLastToken
().
FullSpan
.
End
,
statement
.
Identifier
.
FullSpan
.
End
)
Return
position
>=
start
AndAlso
position
<=
_end
Return
IsOnHeader
(
position
,
node
,
If
(
node
.
TypeParameterList
?
.
GetLastToken
(),
node
.
Identifier
))
End
Function
Public
Function
IsOnPropertyDeclarationHeader
(
root
As
SyntaxNode
,
position
As
Integer
,
ByRef
propertyDeclaration
As
SyntaxNode
)
As
Boolean
Implements
ISyntaxFactsService
.
IsOnPropertyDeclarationHeader
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录