Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
ffc6153a
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,发现更多精彩内容 >>
提交
ffc6153a
编写于
1月 15, 2020
作者:
I
Ivan Basov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
merge conflict resolution
上级
82394f4f
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
97 addition
and
43 deletion
+97
-43
src/Compilers/Core/Portable/InternalUtilities/FatalError.cs
src/Compilers/Core/Portable/InternalUtilities/FatalError.cs
+1
-1
src/EditorFeatures/VisualBasicTest/ChangeSignature/AddParameterTests.Delegates.vb
...lBasicTest/ChangeSignature/AddParameterTests.Delegates.vb
+1
-1
src/EditorFeatures/VisualBasicTest/ChangeSignature/AddParameterTests.vb
...ures/VisualBasicTest/ChangeSignature/AddParameterTests.vb
+1
-1
src/EditorFeatures/VisualBasicTest/ChangeSignature/ChangeSignature_Delegates.vb
...ualBasicTest/ChangeSignature/ChangeSignature_Delegates.vb
+1
-1
src/Features/CSharp/Portable/ChangeSignature/CSharpChangeSignatureService.cs
.../Portable/ChangeSignature/CSharpChangeSignatureService.cs
+17
-17
src/Features/Core/Portable/ChangeSignature/AbstractChangeSignatureService.cs
...ortable/ChangeSignature/AbstractChangeSignatureService.cs
+4
-8
src/Features/VisualBasic/Portable/ChangeSignature/VisualBasicChangeSignatureService.vb
...able/ChangeSignature/VisualBasicChangeSignatureService.vb
+71
-9
src/VisualStudio/Core/Def/Implementation/IntellisenseControls/IntellisenseTextBoxWorkspace.cs
...tion/IntellisenseControls/IntellisenseTextBoxWorkspace.cs
+1
-1
src/VisualStudio/Core/Def/ServicesVSResources.resx
src/VisualStudio/Core/Def/ServicesVSResources.resx
+0
-4
未找到文件。
src/Compilers/Core/Portable/InternalUtilities/FatalError.cs
浏览文件 @
ffc6153a
...
...
@@ -208,7 +208,7 @@ private static void Report(Exception exception, Action<Exception>? handler)
exception
.
Data
[
s_reportedMarker
]
=
s_reportedMarker
;
}
handler
.
Invoke
(
exception
);
handler
.
Invoke
(
exception
);
}
}
}
src/EditorFeatures/VisualBasicTest/ChangeSignature/AddParameterTests.Delegates.vb
浏览文件 @
ffc6153a
...
...
@@ -386,7 +386,7 @@ End Class
Await
TestChangeSignatureViaCommandAsync
(
LanguageNames
.
VisualBasic
,
markup
,
updatedSignature
:
=
updatedSignature
,
expectedUpdatedInvocationDocumentCode
:
=
expectedUpdatedCode
)
End
Function
<
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
ChangeSignature
)
>
<
WpfFact
(
Skip
:
=
"TODO"
)
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
ChangeSignature
)
>
Public
Async
Function
TestAddParameter_Delegates_Relaxation_ParameterlessFunctionToFunction
()
As
Task
Dim
markup
=
<
Text
><
!
[
CDATA
[
Delegate
Function
$$
MyFunc
(
x
As
Integer
,
y
As
String
,
z
As
Boolean
)
As
Integer
...
...
src/EditorFeatures/VisualBasicTest/ChangeSignature/AddParameterTests.vb
浏览文件 @
ffc6153a
...
...
@@ -92,7 +92,7 @@ End Module
Await
TestChangeSignatureViaCommandAsync
(
LanguageNames
.
VisualBasic
,
markup
,
updatedSignature
:
=
permutation
,
expectedUpdatedInvocationDocumentCode
:
=
updatedCode
)
End
Function
<
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
ChangeSignature
)
>
<
WpfFact
(
Skip
:
=
"TODO"
)
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
ChangeSignature
)
>
Public
Async
Function
TestAddParameterToParameterlessMethod
()
As
Task
Dim
markup
=
<
Text
><
!
[
CDATA
[
...
...
src/EditorFeatures/VisualBasicTest/ChangeSignature/ChangeSignature_Delegates.vb
浏览文件 @
ffc6153a
...
...
@@ -369,7 +369,7 @@ End Class
Await
TestChangeSignatureViaCommandAsync
(
LanguageNames
.
VisualBasic
,
markup
,
updatedSignature
:
=
updatedSignature
,
expectedUpdatedInvocationDocumentCode
:
=
expectedUpdatedCode
)
End
Function
<
WpfFact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
ChangeSignature
)
>
<
WpfFact
(
Skip
:
=
"TODO"
)
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
ChangeSignature
)
>
Public
Async
Function
TestChangeSignature_Delegates_Relaxation_ParameterlessFunctionToFunction
()
As
Task
Dim
markup
=
<
Text
><
!
[
CDATA
[
Delegate
Function
$$
MyFunc
(
x
As
Integer
,
y
As
String
,
z
As
Boolean
)
As
Integer
...
...
src/Features/CSharp/Portable/ChangeSignature/CSharpChangeSignatureService.cs
浏览文件 @
ffc6153a
...
...
@@ -817,27 +817,27 @@ private List<SyntaxTrivia> GetPermutedTrivia(Document document, CSharpSyntaxNode
var
convertedMethodGroups
=
nodes
.
WhereAsArray
(
n
=>
{
if
(!
n
.
IsKind
(
SyntaxKind
.
IdentifierName
)
||
!
semanticModel
.
GetMemberGroup
(
n
,
cancellationToken
).
Any
())
{
if
(!
n
.
IsKind
(
SyntaxKind
.
IdentifierName
)
||
!
semanticModel
.
GetMemberGroup
(
n
,
cancellationToken
).
Any
())
{
return
false
;
}
return
false
;
}
ISymbol
convertedType
=
semanticModel
.
GetTypeInfo
(
n
,
cancellationToken
).
ConvertedType
;
ISymbol
convertedType
=
semanticModel
.
GetTypeInfo
(
n
,
cancellationToken
).
ConvertedType
;
if
(
convertedType
!=
null
)
{
convertedType
=
convertedType
.
OriginalDefinition
;
}
if
(
convertedType
!=
null
)
{
convertedType
=
convertedType
.
OriginalDefinition
;
}
if
(
convertedType
!=
null
)
{
convertedType
=
SymbolFinder
.
FindSourceDefinitionAsync
(
convertedType
,
document
.
Project
.
Solution
,
cancellationToken
).
WaitAndGetResult_CanCallOnBackground
(
cancellationToken
)
??
convertedType
;
}
if
(
convertedType
!=
null
)
{
convertedType
=
SymbolFinder
.
FindSourceDefinitionAsync
(
convertedType
,
document
.
Project
.
Solution
,
cancellationToken
).
WaitAndGetResult_CanCallOnBackground
(
cancellationToken
)
??
convertedType
;
}
return
Equals
(
convertedType
,
symbol
.
ContainingType
);
})
return
Equals
(
convertedType
,
symbol
.
ContainingType
);
})
.
SelectAsArray
(
n
=>
semanticModel
.
GetSymbolInfo
(
n
,
cancellationToken
).
Symbol
);
return
convertedMethodGroups
.
SelectAsArray
(
symbolAndProjectId
.
WithSymbol
);
...
...
@@ -845,7 +845,7 @@ private List<SyntaxTrivia> GetPermutedTrivia(Document document, CSharpSyntaxNode
protected
override
IEnumerable
<
AbstractFormattingRule
>
GetFormattingRules
(
Document
document
)
{
return
SpecializedCollections
.
SingletonEnumerable
(
new
ChangeSignatureFormattingRule
())
.
Concat
(
Formatter
.
GetDefaultFormattingRules
(
document
));
return
new
[]
{
new
ChangeSignatureFormattingRule
()
}
.
Concat
(
Formatter
.
GetDefaultFormattingRules
(
document
));
}
protected
override
SyntaxToken
CreateSeparatorSyntaxToken
()
...
...
src/Features/Core/Portable/ChangeSignature/AbstractChangeSignatureService.cs
浏览文件 @
ffc6153a
...
...
@@ -332,9 +332,9 @@ internal ChangeSignatureOptionsResult GetChangeSignatureOptions(ChangeSignatureA
var
nodes
=
nodesToUpdate
[
docId
];
var
newRoot
=
root
.
ReplaceNodes
(
nodes
,
(
originalNode
,
potentiallyUpdatedNode
)
=>
{
return
updater
.
ChangeSignature
(
doc
,
definitionToUse
[
originalNode
],
potentiallyUpdatedNode
,
originalNode
,
CreateCompensatingSignatureChange
(
definitionToUse
[
originalNode
],
options
.
UpdatedSignature
),
cancellationToken
);
});
{
return
updater
.
ChangeSignature
(
doc
,
definitionToUse
[
originalNode
],
potentiallyUpdatedNode
,
originalNode
,
CreateCompensatingSignatureChange
(
definitionToUse
[
originalNode
],
options
.
UpdatedSignature
),
cancellationToken
);
});
var
annotatedNodes
=
newRoot
.
GetAnnotatedNodes
<
SyntaxNode
>(
syntaxAnnotation
:
changeSignatureFormattingAnnotation
);
...
...
@@ -653,11 +653,7 @@ protected static int GetParameterIndex<TNode>(SeparatedSyntaxList<TNode> paramet
protected
List
<
SyntaxToken
>
GetSeparators
<
T
>(
SeparatedSyntaxList
<
T
>
arguments
,
int
numSeparatorsToSkip
=
0
)
where
T
:
SyntaxNode
{
var
separators
=
new
List
<
SyntaxToken
>();
if
(
numSeparatorsToSkip
<
0
)
{
numSeparatorsToSkip
=
0
;
}
for
(
int
i
=
0
;
i
<
arguments
.
SeparatorCount
-
numSeparatorsToSkip
;
i
++)
{
if
(
i
>=
arguments
.
SeparatorCount
)
...
...
src/Features/VisualBasic/Portable/ChangeSignature/VisualBasicChangeSignatureService.vb
浏览文件 @
ffc6153a
...
...
@@ -529,17 +529,80 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ChangeSignature
Return
permutedParams
End
Function
Private
Shared
Function
GetSeparators
(
Of
T
As
SyntaxNode
)(
ByVal
arguments
As
SeparatedSyntaxList
(
Of
T
),
ByVal
Optional
numSeparatorsToSkip
As
Integer
=
0
)
As
List
(
Of
SyntaxToken
)
Dim
separators
=
New
List
(
Of
SyntaxToken
)()
Private
Function
GetPermutedTrivia
(
document
As
Document
,
node
As
VisualBasicSyntaxNode
,
permutedParamNodes
As
List
(
Of
XmlElementSyntax
))
As
List
(
Of
SyntaxTrivia
)
Dim
updatedLeadingTrivia
=
New
List
(
Of
SyntaxTrivia
)()
Dim
index
=
0
For
i
=
0
To
arguments
.
SeparatorCount
-
numSeparatorsToSkip
-
1
If
i
>=
arguments
.
SeparatorCount
Then
separators
.
Add
(
SyntaxFactory
.
Token
(
SyntaxKind
.
CommaToken
))
Else
separators
.
Add
(
arguments
.
GetSeparator
(
i
))
Dim
lastWhiteSpaceTrivia
As
SyntaxTrivia
=
Nothing
Dim
lastDocumentationCommentTriviaSyntax
=
node
.
GetLeadingTrivia
().
LastOrDefault
(
Function
(
t
)
t
.
HasStructure
AndAlso
t
.
GetStructure
().
IsKind
(
SyntaxKind
.
DocumentationCommentTrivia
))
Dim
documentationCommeStructuredTrivia
As
DocumentationCommentTriviaSyntax
=
DirectCast
(
lastDocumentationCommentTriviaSyntax
.
GetStructure
(),
DocumentationCommentTriviaSyntax
)
For
Each
trivia
In
node
.
GetLeadingTrivia
()
If
Not
trivia
.
HasStructure
Then
If
trivia
.
IsKind
(
SyntaxKind
.
WhitespaceTrivia
)
Then
lastWhiteSpaceTrivia
=
trivia
End
If
updatedLeadingTrivia
.
Add
(
trivia
)
Continue
For
End
If
Dim
structuredTrivia
=
TryCast
(
trivia
.
GetStructure
(),
DocumentationCommentTriviaSyntax
)
If
structuredTrivia
Is
Nothing
Then
updatedLeadingTrivia
.
Add
(
trivia
)
Continue
For
End
If
Dim
updatedNodeList
=
New
List
(
Of
XmlNodeSyntax
)()
For
Each
content
In
structuredTrivia
.
Content
If
Not
content
.
IsKind
(
SyntaxKind
.
XmlElement
)
Then
updatedNodeList
.
Add
(
content
)
Continue
For
End
If
Dim
xmlElement
=
DirectCast
(
content
,
XmlElementSyntax
)
If
xmlElement
.
StartTag
.
Name
.
ToString
()
<>
DocumentationCommentXmlNames
.
ParameterElementName
Then
updatedNodeList
.
Add
(
content
)
Continue
For
End
If
' Found a param tag, so insert the next one from the reordered list.
If
index
<
permutedParamNodes
.
Count
Then
updatedNodeList
.
Add
(
permutedParamNodes
(
index
).
WithLeadingTrivia
(
content
.
GetLeadingTrivia
()).
WithTrailingTrivia
(
content
.
GetTrailingTrivia
()))
index
+=
1
Else
' Inspecting a param element that we are deleting but not replacing.
End
If
Next
Dim
newDocComments
=
SyntaxFactory
.
DocumentationCommentTrivia
(
SyntaxFactory
.
List
(
updatedNodeList
.
AsEnumerable
()))
newDocComments
=
newDocComments
.
WithLeadingTrivia
(
structuredTrivia
.
GetLeadingTrivia
()).
WithTrailingTrivia
(
structuredTrivia
.
GetTrailingTrivia
())
Dim
newTrivia
=
SyntaxFactory
.
Trivia
(
newDocComments
)
updatedLeadingTrivia
.
Add
(
newTrivia
)
Next
Dim
extraNodeList
=
New
List
(
Of
XmlNodeSyntax
)()
While
(
index
<
permutedParamNodes
.
Count
)
extraNodeList
.
Add
(
permutedParamNodes
(
index
))
index
+=
1
End
While
If
extraNodeList
.
Any
()
Then
Dim
extraDocComments
=
SyntaxFactory
.
DocumentationCommentTrivia
(
SyntaxFactory
.
List
(
extraNodeList
.
AsEnumerable
()))
extraDocComments
=
extraDocComments
.
WithLeadingTrivia
(
SyntaxFactory
.
DocumentationCommentExteriorTrivia
(
"''' "
)).
WithTrailingTrivia
(
node
.
GetTrailingTrivia
()).
WithTrailingTrivia
(
SyntaxFactory
.
EndOfLine
(
document
.
Project
.
Solution
.
Workspace
.
Options
.
GetOption
(
FormattingOptions
.
NewLine
,
LanguageNames
.
CSharp
)),
lastWhiteSpaceTrivia
)
Dim
newTrivia
=
SyntaxFactory
.
Trivia
(
extraDocComments
)
updatedLeadingTrivia
.
Add
(
newTrivia
)
End
If
Return
updatedLeadingTrivia
End
Function
...
...
@@ -599,8 +662,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ChangeSignature
End
Function
Protected
Overrides
Function
GetFormattingRules
(
document
As
Document
)
As
IEnumerable
(
Of
AbstractFormattingRule
)
Return
SpecializedCollections
.
SingletonEnumerable
(
Of
AbstractFormattingRule
)(
New
ChangeSignatureFormattingRule
()).
Concat
(
Formatter
.
GetDefaultFormattingRules
(
document
))
Return
SpecializedCollections
.
SingletonEnumerable
(
Of
AbstractFormattingRule
)(
New
ChangeSignatureFormattingRule
()).
Concat
(
Formatter
.
GetDefaultFormattingRules
(
document
))
End
Function
Protected
Overrides
Function
CreateSeparatorSyntaxToken
()
As
SyntaxToken
...
...
src/VisualStudio/Core/Def/Implementation/IntellisenseControls/IntellisenseTextBoxWorkspace.cs
浏览文件 @
ffc6153a
...
...
@@ -22,7 +22,7 @@ public IntellisenseTextBoxWorkspace(Solution solution, Project project, string d
ChangeSignatureDocumentId
=
DocumentId
.
CreateNewId
(
project
.
Id
);
this
.
SetCurrentSolution
(
solution
.
AddDocument
(
ChangeSignatureDocumentId
,
Guid
.
NewGuid
().
ToString
(),
documentText
));
Options
=
Options
.
WithChangedOption
(
EditorCompletionOptions
.
UseSuggestionMode
,
true
);
this
.
TryApplyChanges
(
this
.
CurrentSolution
.
WithOptions
(
Options
.
WithChangedOption
(
EditorCompletionOptions
.
UseSuggestionMode
,
true
))
);
}
public
Document
ChangeSignatureDocument
=>
this
.
CurrentSolution
.
GetDocument
(
this
.
ChangeSignatureDocumentId
);
...
...
src/VisualStudio/Core/Def/ServicesVSResources.resx
浏览文件 @
ffc6153a
...
...
@@ -1398,10 +1398,6 @@ I agree to all of the foregoing:</value>
<data
name=
"Type_Name"
xml:space=
"preserve"
>
<value>
Type name:
</value>
</data>
<data
name=
"Live_Share_CSharp_Visual_Basic_Language_Server_Client"
xml:space=
"preserve"
>
<value>
Live Share C#/Visual Basic Language Server Client
</value>
<comment>
'Live Share' is a product name and does not need to be localized.
</comment>
</data>
<data
name=
"You_must_change_the_signature"
xml:space=
"preserve"
>
<value>
You must change the signature
</value>
<comment>
"signature" here means the definition of a method
</comment>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录