Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
d685a3ca
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,发现更多精彩内容 >>
提交
d685a3ca
编写于
2月 22, 2017
作者:
C
CyrusNajmabadi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Improve things for VB as well.
上级
3e61a560
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
160 addition
and
27 deletion
+160
-27
src/EditorFeatures/CSharpTest/ChangeSignature/ChangeSignatureTests.cs
...atures/CSharpTest/ChangeSignature/ChangeSignatureTests.cs
+15
-0
src/EditorFeatures/VisualBasicTest/BasicEditorServicesTest.vbproj
...orFeatures/VisualBasicTest/BasicEditorServicesTest.vbproj
+1
-0
src/EditorFeatures/VisualBasicTest/ChangeSignature/ChangeSignatureTests.vb
...s/VisualBasicTest/ChangeSignature/ChangeSignatureTests.vb
+80
-0
src/Features/Core/Portable/ChangeSignature/AbstractChangeSignatureCodeRefactoringProvider.cs
...gnature/AbstractChangeSignatureCodeRefactoringProvider.cs
+6
-3
src/Features/VisualBasic/Portable/ChangeSignature/VisualBasicChangeSignatureService.vb
...able/ChangeSignature/VisualBasicChangeSignatureService.vb
+58
-24
未找到文件。
src/EditorFeatures/CSharpTest/ChangeSignature/ChangeSignatureTests.cs
浏览文件 @
d685a3ca
...
...
@@ -186,5 +186,20 @@ void Foo(int a, int b)
await
TestChangeSignatureViaCodeActionAsync
(
markup
,
expectedCodeAction
:
false
);
}
[
WorkItem
(
17309
,
"https://github.com/dotnet/roslyn/issues/17309"
)]
[
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
ChangeSignature
)]
public
async
Task
TestNotInConstraints
()
{
var
markup
=
@"
class Ext
{
void Foo<T>(int a, int b) where [||]T : class
{
};
}"
;
await
TestChangeSignatureViaCodeActionAsync
(
markup
,
expectedCodeAction
:
false
);
}
}
}
\ No newline at end of file
src/EditorFeatures/VisualBasicTest/BasicEditorServicesTest.vbproj
浏览文件 @
d685a3ca
...
...
@@ -166,6 +166,7 @@
<Compile
Include=
"BraceMatching\BraceHighlightingTests.vb"
/>
<Compile
Include=
"BraceMatching\VisualBasicBraceMatcherTests.vb"
/>
<Compile
Include=
"CaseCorrecting\CaseCorrectionServiceTests.vb"
/>
<Compile
Include=
"ChangeSignature\ChangeSignatureTests.vb"
/>
<Compile
Include=
"ChangeSignature\ChangeSignature_CheckAllSignatureChanges.vb"
/>
<Compile
Include=
"ChangeSignature\ChangeSignature_Delegates.vb"
/>
<Compile
Include=
"ChangeSignature\ChangeSignature_Formatting.vb"
/>
...
...
src/EditorFeatures/VisualBasicTest/ChangeSignature/ChangeSignatureTests.vb
0 → 100644
浏览文件 @
d685a3ca
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports
Microsoft.CodeAnalysis.Editor.UnitTests.ChangeSignature
Imports
Microsoft.CodeAnalysis.Editor.UnitTests.Extensions
Namespace
Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.ChangeSignature
Partial
Public
Class
ChangeSignatureTests
Inherits
AbstractChangeSignatureTests
<
WorkItem
(
17309
,
"https://github.com/dotnet/roslyn/issues/17309"
)
>
<
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
ChangeSignature
)
>
Public
Async
Function
TestNotInLeadingWhitespace
()
As
Task
Dim
markup
=
"
class C
[||]
sub Foo(i as integer, j as integer)
end sub
end class
"
Await
TestChangeSignatureViaCodeActionAsync
(
markup
,
expectedCodeAction
:
=
False
)
End
Function
<
WorkItem
(
17309
,
"https://github.com/dotnet/roslyn/issues/17309"
)
>
<
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
ChangeSignature
)
>
Public
Async
Function
TestNotInLeadingTrivia1
()
As
Task
Dim
markup
=
"
class C
' [||]
sub Foo(i as integer, j as integer)
end sub
end class
"
Await
TestChangeSignatureViaCodeActionAsync
(
markup
,
expectedCodeAction
:
=
False
)
End
Function
<
WorkItem
(
17309
,
"https://github.com/dotnet/roslyn/issues/17309"
)
>
<
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
ChangeSignature
)
>
Public
Async
Function
TestNotInLeadingTrivia2
()
As
Task
Dim
markup
=
"
class C
[||] '
sub Foo(i as integer, j as integer)
end sub
end class
"
Await
TestChangeSignatureViaCodeActionAsync
(
markup
,
expectedCodeAction
:
=
False
)
End
Function
<
WorkItem
(
17309
,
"https://github.com/dotnet/roslyn/issues/17309"
)
>
<
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
ChangeSignature
)
>
Public
Async
Function
TestNotInLeadingAttributes1
()
As
Task
Dim
markup
=
"
class C
[||]<X>
sub Foo(i as integer, j as integer)
end sub
end class
"
Await
TestChangeSignatureViaCodeActionAsync
(
markup
,
expectedCodeAction
:
=
False
)
End
Function
<
WorkItem
(
17309
,
"https://github.com/dotnet/roslyn/issues/17309"
)
>
<
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
ChangeSignature
)
>
Public
Async
Function
TestNotInLeadingAttributes2
()
As
Task
Dim
markup
=
"
class C
<X>[||]
sub Foo(i as integer, j as integer)
end sub
end class
"
Await
TestChangeSignatureViaCodeActionAsync
(
markup
,
expectedCodeAction
:
=
False
)
End
Function
End
Class
End
Namespace
\ No newline at end of file
src/Features/Core/Portable/ChangeSignature/AbstractChangeSignatureCodeRefactoringProvider.cs
浏览文件 @
d685a3ca
...
...
@@ -12,10 +12,13 @@ namespace Microsoft.CodeAnalysis.ChangeSignature
internal
class
ChangeSignatureCodeRefactoringProvider
:
CodeRefactoringProvider
{
public
sealed
override
async
Task
ComputeRefactoringsAsync
(
CodeRefactoringContext
context
)
{
if
(
context
.
Span
.
IsEmpty
)
{
var
service
=
context
.
Document
.
GetLanguageService
<
AbstractChangeSignatureService
>();
var
actions
=
await
service
.
GetChangeSignatureCodeActionAsync
(
context
.
Document
,
context
.
Span
,
context
.
CancellationToken
).
ConfigureAwait
(
false
);
context
.
RegisterRefactorings
(
actions
);
}
}
}
}
\ No newline at end of file
src/Features/VisualBasic/Portable/ChangeSignature/VisualBasicChangeSignatureService.vb
浏览文件 @
d685a3ca
...
...
@@ -29,8 +29,58 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ChangeSignature
Return
Nothing
End
If
Dim
semanticModel
=
document
.
GetSemanticModelAsync
(
cancellationToken
).
WaitAndGetResult
(
cancellationToken
)
' Don't show change-signature in the random whitespace/trivia for code.
If
Not
matchingNode
.
Span
.
IntersectsWith
(
position
)
Then
Return
Nothing
End
If
Dim
semanticModel
=
Await
document
.
GetSemanticModelAsync
(
cancellationToken
).
ConfigureAwait
(
False
)
Dim
symbol
=
TryGetDeclaredSymbol
(
semanticModel
,
matchingNode
,
token
,
cancellationToken
)
If
symbol
IsNot
Nothing
Then
Return
If
(
restrictToDeclarations
AndAlso
Not
IsInSymbolHeader
(
matchingNode
,
position
),
Nothing
,
symbol
)
End
If
If
matchingNode
.
Kind
()
=
SyntaxKind
.
ObjectCreationExpression
Then
Dim
objectCreation
=
DirectCast
(
matchingNode
,
ObjectCreationExpressionSyntax
)
If
token
.
Parent
.
AncestorsAndSelf
().
Any
(
Function
(
a
)
a
Is
objectCreation
.
Type
)
Then
Dim
typeSymbol
=
semanticModel
.
GetSymbolInfo
(
objectCreation
.
Type
).
Symbol
If
typeSymbol
IsNot
Nothing
AndAlso
typeSymbol
.
IsKind
(
SymbolKind
.
NamedType
)
AndAlso
DirectCast
(
typeSymbol
,
ITypeSymbol
).
TypeKind
=
TypeKind
.
Delegate
Then
Return
typeSymbol
End
If
End
If
End
If
Dim
symbolInfo
=
semanticModel
.
GetSymbolInfo
(
matchingNode
,
cancellationToken
)
Return
If
(
symbolInfo
.
Symbol
,
symbolInfo
.
CandidateSymbols
.
FirstOrDefault
())
End
Function
Private
Function
IsInSymbolHeader
(
matchingNode
As
SyntaxNode
,
position
As
Integer
)
As
Boolean
' Caret has to be after the attributes if the symbol has any.
Dim
lastAttributes
=
matchingNode
.
ChildNodes
().
LastOrDefault
(
Function
(
n
)
TypeOf
n
Is
AttributeListSyntax
)
Dim
start
=
If
(
lastAttributes
?
.
GetLastToken
().
GetNextToken
().
SpanStart
,
matchingNode
.
SpanStart
)
If
position
<
start
Then
Return
False
End
If
' If the symbol has a parameter list, then the caret shouldn't be past the end of it.
Dim
parameterList
=
matchingNode
.
ChildNodes
().
LastOrDefault
(
Function
(
n
)
TypeOf
n
Is
ParameterListSyntax
)
If
parameterList
IsNot
Nothing
Then
Return
position
<=
parameterList
.
FullSpan
.
End
End
If
' Case we haven't handled yet. Just assume we're in the header.
Return
True
End
Function
Private
Function
TryGetDeclaredSymbol
(
semanticModel
As
SemanticModel
,
matchingNode
As
SyntaxNode
,
token
As
SyntaxToken
,
cancellationToken
As
CancellationToken
)
As
ISymbol
Select
Case
matchingNode
.
Kind
()
Case
SyntaxKind
.
PropertyBlock
Dim
parameterList
=
DirectCast
(
matchingNode
,
PropertyBlockSyntax
).
PropertyStatement
.
ParameterList
...
...
@@ -48,33 +98,17 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ChangeSignature
Return
semanticModel
.
GetDeclaredSymbol
(
DirectCast
(
matchingNode
,
MethodBlockSyntax
).
BlockStatement
,
cancellationToken
)
Case
SyntaxKind
.
ConstructorBlock
Return
semanticModel
.
GetDeclaredSymbol
(
DirectCast
(
matchingNode
,
ConstructorBlockSyntax
).
BlockStatement
,
cancellationToken
)
Case
SyntaxKind
.
ObjectCreationExpression
Dim
objectCreation
=
DirectCast
(
matchingNode
,
ObjectCreationExpressionSyntax
)
If
token
.
Parent
.
AncestorsAndSelf
().
Any
(
Function
(
a
)
a
Is
objectCreation
.
Type
)
Then
Dim
typeSymbol
=
semanticModel
.
GetSymbolInfo
(
objectCreation
.
Type
).
Symbol
If
typeSymbol
IsNot
Nothing
AndAlso
typeSymbol
.
IsKind
(
SymbolKind
.
NamedType
)
AndAlso
DirectCast
(
typeSymbol
,
ITypeSymbol
).
TypeKind
=
TypeKind
.
Delegate
Then
Return
typeSymbol
End
If
End
If
End
Select
Dim
symbol
=
semanticModel
.
GetDeclaredSymbol
(
matchingNode
,
cancellationToken
)
If
symbol
IsNot
Nothing
Then
Return
symbol
End
If
Dim
symbolInfo
=
semanticModel
.
GetSymbolInfo
(
matchingNode
,
cancellationToken
)
Return
If
(
symbolInfo
.
Symbol
,
symbolInfo
.
CandidateSymbols
.
FirstOrDefault
())
Return
semanticModel
.
GetDeclaredSymbol
(
matchingNode
,
cancellationToken
)
End
Function
Private
_nonDeclarationKinds
As
ImmutableArray
(
Of
SyntaxKind
)
=
New
List
(
Of
SyntaxKind
)
From
{
Private
Shared
ReadOnly
_nonDeclarationKinds
As
ImmutableArray
(
Of
SyntaxKind
)
=
ImmutableArray
.
Create
(
SyntaxKind
.
SubBlock
,
SyntaxKind
.
FunctionBlock
,
SyntaxKind
.
PropertyBlock
,
SyntaxKind
.
EventBlock
,
SyntaxKind
.
ConstructorBlock
}.
ToImmutableArray
()
SyntaxKind
.
ConstructorBlock
)
Private
_invokableAncestorKinds
As
ImmutableArray
(
Of
SyntaxKind
)
=
New
List
(
Of
SyntaxKind
)
From
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录