Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
9fc091e1
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,发现更多精彩内容 >>
提交
9fc091e1
编写于
3月 26, 2020
作者:
C
Cyrus Najmabadi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove unused parameters
上级
1fcb4464
变更
18
隐藏空白更改
内联
并排
Showing
18 changed file
with
79 addition
and
102 deletion
+79
-102
src/Analyzers/CSharp/CodeFixes/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionCodeFixProvider.Rewriter.cs
...ertSwitchStatementToExpressionCodeFixProvider.Rewriter.cs
+2
-2
src/Features/CSharp/Portable/Completion/CompletionProviders/CompletionUtilities.cs
...ble/Completion/CompletionProviders/CompletionUtilities.cs
+3
-7
src/Features/CSharp/Portable/Completion/CompletionProviders/CrefCompletionProvider.cs
.../Completion/CompletionProviders/CrefCompletionProvider.cs
+9
-9
src/Features/CSharp/Portable/Completion/CompletionProviders/DeclarationNameCompletionProvider.DeclarationInfo.cs
...ders/DeclarationNameCompletionProvider.DeclarationInfo.cs
+30
-31
src/Features/CSharp/Portable/Completion/KeywordRecommenders/BaseKeywordRecommender.cs
.../Completion/KeywordRecommenders/BaseKeywordRecommender.cs
+2
-2
src/Features/CSharp/Portable/ConvertLinq/ConvertForEachToLinqQuery/DefaultConverter.cs
...ConvertLinq/ConvertForEachToLinqQuery/DefaultConverter.cs
+1
-2
src/Features/CSharp/Portable/EncapsulateField/CSharpEncapsulateFieldService.cs
...ortable/EncapsulateField/CSharpEncapsulateFieldService.cs
+5
-7
src/Features/CSharp/Portable/GenerateMember/GenerateParameterizedMember/CSharpCommonGenerationServiceMethods.cs
...rameterizedMember/CSharpCommonGenerationServiceMethods.cs
+2
-2
src/Features/CSharp/Portable/GenerateMember/GenerateParameterizedMember/CSharpGenerateConversionService.cs
...ateParameterizedMember/CSharpGenerateConversionService.cs
+2
-6
src/Features/CSharp/Portable/GenerateMember/GenerateParameterizedMember/CSharpGenerateDeconstructMethodService.cs
...meterizedMember/CSharpGenerateDeconstructMethodService.cs
+2
-2
src/Features/CSharp/Portable/GenerateMember/GenerateParameterizedMember/CSharpGenerateMethodService.cs
...enerateParameterizedMember/CSharpGenerateMethodService.cs
+2
-2
src/Features/CSharp/Portable/GenerateType/CSharpGenerateTypeService.cs
...CSharp/Portable/GenerateType/CSharpGenerateTypeService.cs
+1
-1
src/Features/CSharp/Portable/InlineDeclaration/CSharpInlineDeclarationCodeFixProvider.cs
...lineDeclaration/CSharpInlineDeclarationCodeFixProvider.cs
+5
-8
src/Features/CSharp/Portable/SignatureHelp/GenericNameSignatureHelpProvider.cs
...ortable/SignatureHelp/GenericNameSignatureHelpProvider.cs
+3
-4
src/Features/CSharp/Portable/SignatureHelp/GenericNameSignatureHelpProvider_NamedType.cs
...gnatureHelp/GenericNameSignatureHelpProvider_NamedType.cs
+2
-5
src/Features/CSharp/Portable/SignatureHelp/ObjectCreationExpressionSignatureHelpProvider.cs
...tureHelp/ObjectCreationExpressionSignatureHelpProvider.cs
+1
-1
src/Features/CSharp/Portable/SignatureHelp/ObjectCreationExpressionSignatureHelpProvider_DelegateType.cs
...ctCreationExpressionSignatureHelpProvider_DelegateType.cs
+5
-9
src/Features/CSharp/Portable/UseIndexOrRangeOperator/CSharpUseRangeOperatorCodeFixProvider.cs
...xOrRangeOperator/CSharpUseRangeOperatorCodeFixProvider.cs
+2
-2
未找到文件。
src/Analyzers/CSharp/CodeFixes/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionCodeFixProvider.Rewriter.cs
浏览文件 @
9fc091e1
...
@@ -67,7 +67,7 @@ private Rewriter(bool isAllThrowStatements)
...
@@ -67,7 +67,7 @@ private Rewriter(bool isAllThrowStatements)
Debug
.
Assert
(
_assignmentTargetOpt
!=
null
);
Debug
.
Assert
(
_assignmentTargetOpt
!=
null
);
return
generateDeclaration
return
generateDeclaration
?
GenerateVariableDeclaration
(
switchExpression
,
leadingTrivia
,
declaratorToRemoveTypeOpt
)
?
GenerateVariableDeclaration
(
switchExpression
,
declaratorToRemoveTypeOpt
)
:
GenerateAssignment
(
switchExpression
,
nodeToGenerate
,
leadingTrivia
);
:
GenerateAssignment
(
switchExpression
,
nodeToGenerate
,
leadingTrivia
);
}
}
...
@@ -82,7 +82,7 @@ private ExpressionStatementSyntax GenerateAssignment(ExpressionSyntax switchExpr
...
@@ -82,7 +82,7 @@ private ExpressionStatementSyntax GenerateAssignment(ExpressionSyntax switchExpr
.
WithLeadingTrivia
(
leadingTrivia
);
.
WithLeadingTrivia
(
leadingTrivia
);
}
}
private
StatementSyntax
GenerateVariableDeclaration
(
ExpressionSyntax
switchExpression
,
SyntaxTriviaList
leadingTrivia
,
ITypeSymbol
declaratorToRemoveTypeOpt
)
private
StatementSyntax
GenerateVariableDeclaration
(
ExpressionSyntax
switchExpression
,
ITypeSymbol
declaratorToRemoveTypeOpt
)
{
{
Debug
.
Assert
(
_assignmentTargetOpt
is
IdentifierNameSyntax
);
Debug
.
Assert
(
_assignmentTargetOpt
is
IdentifierNameSyntax
);
...
...
src/Features/CSharp/Portable/Completion/CompletionProviders/CompletionUtilities.cs
浏览文件 @
9fc091e1
...
@@ -74,14 +74,10 @@ internal static bool IsTriggerCharacter(SourceText text, int characterPosition,
...
@@ -74,14 +74,10 @@ internal static bool IsTriggerCharacter(SourceText text, int characterPosition,
internal
static
ImmutableHashSet
<
char
>
CommonTriggerCharactersWithArgumentList
{
get
;
}
=
ImmutableHashSet
.
Create
(
'.'
,
'#'
,
'>'
,
':'
,
'('
,
'['
,
' '
);
internal
static
ImmutableHashSet
<
char
>
CommonTriggerCharactersWithArgumentList
{
get
;
}
=
ImmutableHashSet
.
Create
(
'.'
,
'#'
,
'>'
,
':'
,
'('
,
'['
,
' '
);
internal
static
bool
IsTriggerCharacterOrArgumentListCharacter
(
SourceText
text
,
int
characterPosition
,
OptionSet
options
)
internal
static
bool
IsTriggerCharacterOrArgumentListCharacter
(
SourceText
text
,
int
characterPosition
,
OptionSet
options
)
{
=>
IsTriggerCharacter
(
text
,
characterPosition
,
options
)
||
IsArgumentListCharacter
(
text
,
characterPosition
);
return
IsTriggerCharacter
(
text
,
characterPosition
,
options
)
||
IsArgumentListCharacter
(
text
,
characterPosition
,
options
);
}
private
static
bool
IsArgumentListCharacter
(
SourceText
text
,
int
characterPosition
,
OptionSet
options
)
private
static
bool
IsArgumentListCharacter
(
SourceText
text
,
int
characterPosition
)
{
=>
IsArgumentListCharacter
(
text
[
characterPosition
]);
return
IsArgumentListCharacter
(
text
[
characterPosition
]);
}
internal
static
bool
IsArgumentListCharacter
(
char
ch
)
internal
static
bool
IsArgumentListCharacter
(
char
ch
)
{
{
...
...
src/Features/CSharp/Portable/Completion/CompletionProviders/CrefCompletionProvider.cs
浏览文件 @
9fc091e1
...
@@ -98,7 +98,7 @@ public override async Task ProvideCompletionsAsync(CompletionContext context)
...
@@ -98,7 +98,7 @@ public override async Task ProvideCompletionsAsync(CompletionContext context)
var
serializedOptions
=
ImmutableDictionary
<
string
,
string
>.
Empty
.
Add
(
HideAdvancedMembers
,
hideAdvancedMembers
.
ToString
());
var
serializedOptions
=
ImmutableDictionary
<
string
,
string
>.
Empty
.
Add
(
HideAdvancedMembers
,
hideAdvancedMembers
.
ToString
());
var
items
=
CreateCompletionItems
(
document
.
Project
.
Solution
.
Workspace
,
var
items
=
CreateCompletionItems
(
document
.
Project
.
Solution
.
Workspace
,
semanticModel
,
symbols
,
token
,
span
,
position
,
serializedOptions
);
semanticModel
,
symbols
,
token
,
position
,
serializedOptions
);
context
.
AddItems
(
items
);
context
.
AddItems
(
items
);
}
}
...
@@ -270,15 +270,15 @@ private static TextSpan GetCompletionItemSpan(SourceText text, int position)
...
@@ -270,15 +270,15 @@ private static TextSpan GetCompletionItemSpan(SourceText text, int position)
}
}
private
IEnumerable
<
CompletionItem
>
CreateCompletionItems
(
private
IEnumerable
<
CompletionItem
>
CreateCompletionItems
(
Workspace
workspace
,
SemanticModel
semanticModel
,
ImmutableArray
<
ISymbol
>
symbols
,
SyntaxToken
token
,
TextSpan
itemSpan
,
int
position
,
ImmutableDictionary
<
string
,
string
>
options
)
Workspace
workspace
,
SemanticModel
semanticModel
,
ImmutableArray
<
ISymbol
>
symbols
,
SyntaxToken
token
,
int
position
,
ImmutableDictionary
<
string
,
string
>
options
)
{
{
var
builder
=
SharedPools
.
Default
<
StringBuilder
>().
Allocate
();
var
builder
=
SharedPools
.
Default
<
StringBuilder
>().
Allocate
();
try
try
{
{
foreach
(
var
symbol
in
symbols
)
foreach
(
var
symbol
in
symbols
)
{
{
yield
return
CreateItem
(
workspace
,
semanticModel
,
symbol
,
token
,
position
,
builder
,
options
);
yield
return
CreateItem
(
semanticModel
,
symbol
,
token
,
position
,
builder
,
options
);
if
(
TryCreateSpecialTypeItem
(
workspace
,
semanticModel
,
symbol
,
token
,
position
,
builder
,
options
,
out
var
item
))
if
(
TryCreateSpecialTypeItem
(
semanticModel
,
symbol
,
token
,
position
,
builder
,
options
,
out
var
item
))
{
{
yield
return
item
;
yield
return
item
;
}
}
...
@@ -291,7 +291,7 @@ private static TextSpan GetCompletionItemSpan(SourceText text, int position)
...
@@ -291,7 +291,7 @@ private static TextSpan GetCompletionItemSpan(SourceText text, int position)
}
}
private
bool
TryCreateSpecialTypeItem
(
private
bool
TryCreateSpecialTypeItem
(
Workspace
workspace
,
SemanticModel
semanticModel
,
ISymbol
symbol
,
SyntaxToken
token
,
int
position
,
StringBuilder
builder
,
SemanticModel
semanticModel
,
ISymbol
symbol
,
SyntaxToken
token
,
int
position
,
StringBuilder
builder
,
ImmutableDictionary
<
string
,
string
>
options
,
out
CompletionItem
item
)
ImmutableDictionary
<
string
,
string
>
options
,
out
CompletionItem
item
)
{
{
// If the type is a SpecialType, create an additional item using
// If the type is a SpecialType, create an additional item using
...
@@ -299,7 +299,7 @@ private static TextSpan GetCompletionItemSpan(SourceText text, int position)
...
@@ -299,7 +299,7 @@ private static TextSpan GetCompletionItemSpan(SourceText text, int position)
var
typeSymbol
=
symbol
as
ITypeSymbol
;
var
typeSymbol
=
symbol
as
ITypeSymbol
;
if
(
typeSymbol
.
IsSpecialType
())
if
(
typeSymbol
.
IsSpecialType
())
{
{
item
=
CreateItem
(
workspace
,
semanticModel
,
symbol
,
token
,
position
,
builder
,
options
,
CrefFormatForSpecialTypes
);
item
=
CreateItem
(
semanticModel
,
symbol
,
token
,
position
,
builder
,
options
,
CrefFormatForSpecialTypes
);
return
true
;
return
true
;
}
}
...
@@ -308,15 +308,15 @@ private static TextSpan GetCompletionItemSpan(SourceText text, int position)
...
@@ -308,15 +308,15 @@ private static TextSpan GetCompletionItemSpan(SourceText text, int position)
}
}
private
CompletionItem
CreateItem
(
private
CompletionItem
CreateItem
(
Workspace
workspace
,
SemanticModel
semanticModel
,
ISymbol
symbol
,
SyntaxToken
token
,
int
position
,
StringBuilder
builder
,
ImmutableDictionary
<
string
,
string
>
options
)
SemanticModel
semanticModel
,
ISymbol
symbol
,
SyntaxToken
token
,
int
position
,
StringBuilder
builder
,
ImmutableDictionary
<
string
,
string
>
options
)
{
{
// For every symbol, we create an item that uses the regular CrefFormat,
// For every symbol, we create an item that uses the regular CrefFormat,
// which uses intrinsic type keywords
// which uses intrinsic type keywords
return
CreateItem
(
workspace
,
semanticModel
,
symbol
,
token
,
position
,
builder
,
options
,
CrefFormat
);
return
CreateItem
(
semanticModel
,
symbol
,
token
,
position
,
builder
,
options
,
CrefFormat
);
}
}
private
CompletionItem
CreateItem
(
private
CompletionItem
CreateItem
(
Workspace
workspace
,
SemanticModel
semanticModel
,
ISymbol
symbol
,
SyntaxToken
token
,
int
position
,
StringBuilder
builder
,
ImmutableDictionary
<
string
,
string
>
options
,
SemanticModel
semanticModel
,
ISymbol
symbol
,
SyntaxToken
token
,
int
position
,
StringBuilder
builder
,
ImmutableDictionary
<
string
,
string
>
options
,
SymbolDisplayFormat
unqualifiedCrefFormat
)
SymbolDisplayFormat
unqualifiedCrefFormat
)
{
{
builder
.
Clear
();
builder
.
Clear
();
...
...
src/Features/CSharp/Portable/Completion/CompletionProviders/DeclarationNameCompletionProvider.DeclarationInfo.cs
浏览文件 @
9fc091e1
...
@@ -49,21 +49,21 @@ internal static async Task<NameDeclarationInfo> GetDeclarationInfoAsync(Document
...
@@ -49,21 +49,21 @@ internal static async Task<NameDeclarationInfo> GetDeclarationInfoAsync(Document
var
semanticModel
=
await
document
.
GetSemanticModelForSpanAsync
(
new
Text
.
TextSpan
(
token
.
SpanStart
,
0
),
cancellationToken
).
ConfigureAwait
(
false
);
var
semanticModel
=
await
document
.
GetSemanticModelForSpanAsync
(
new
Text
.
TextSpan
(
token
.
SpanStart
,
0
),
cancellationToken
).
ConfigureAwait
(
false
);
var
typeInferenceService
=
document
.
GetLanguageService
<
ITypeInferenceService
>();
var
typeInferenceService
=
document
.
GetLanguageService
<
ITypeInferenceService
>();
if
(
IsTupleTypeElement
(
token
,
semanticModel
,
position
,
cancellationToken
,
out
var
result
)
if
(
IsTupleTypeElement
(
token
,
semanticModel
,
cancellationToken
,
out
var
result
)
||
IsParameterDeclaration
(
token
,
semanticModel
,
position
,
cancellationToken
,
out
result
)
||
IsParameterDeclaration
(
token
,
semanticModel
,
cancellationToken
,
out
result
)
||
IsTypeParameterDeclaration
(
token
,
semanticModel
,
position
,
out
result
)
||
IsTypeParameterDeclaration
(
token
,
out
result
)
||
IsLocalFunctionDeclaration
(
token
,
semanticModel
,
position
,
cancellationToken
,
out
result
)
||
IsLocalFunctionDeclaration
(
token
,
semanticModel
,
cancellationToken
,
out
result
)
||
IsLocalVariableDeclaration
(
token
,
semanticModel
,
position
,
cancellationToken
,
out
result
)
||
IsLocalVariableDeclaration
(
token
,
semanticModel
,
cancellationToken
,
out
result
)
||
IsEmbeddedVariableDeclaration
(
token
,
semanticModel
,
position
,
cancellationToken
,
out
result
)
||
IsEmbeddedVariableDeclaration
(
token
,
semanticModel
,
cancellationToken
,
out
result
)
||
IsForEachVariableDeclaration
(
token
,
semanticModel
,
position
,
cancellationToken
,
out
result
)
||
IsForEachVariableDeclaration
(
token
,
semanticModel
,
cancellationToken
,
out
result
)
||
IsIncompleteMemberDeclaration
(
token
,
semanticModel
,
position
,
cancellationToken
,
out
result
)
||
IsIncompleteMemberDeclaration
(
token
,
semanticModel
,
cancellationToken
,
out
result
)
||
IsFieldDeclaration
(
token
,
semanticModel
,
position
,
cancellationToken
,
out
result
)
||
IsFieldDeclaration
(
token
,
semanticModel
,
cancellationToken
,
out
result
)
||
IsMethodDeclaration
(
token
,
semanticModel
,
position
,
cancellationToken
,
out
result
)
||
IsMethodDeclaration
(
token
,
semanticModel
,
cancellationToken
,
out
result
)
||
IsPropertyDeclaration
(
token
,
semanticModel
,
position
,
cancellationToken
,
out
result
)
||
IsPropertyDeclaration
(
token
,
semanticModel
,
cancellationToken
,
out
result
)
||
IsPossibleOutVariableDeclaration
(
token
,
semanticModel
,
position
,
typeInferenceService
,
cancellationToken
,
out
result
)
||
IsPossibleOutVariableDeclaration
(
token
,
semanticModel
,
typeInferenceService
,
cancellationToken
,
out
result
)
||
IsTupleLiteralElement
(
token
,
semanticModel
,
position
,
cancellationToken
,
out
result
)
||
IsTupleLiteralElement
(
token
,
semanticModel
,
cancellationToken
,
out
result
)
||
IsPossibleVariableOrLocalMethodDeclaration
(
token
,
semanticModel
,
position
,
cancellationToken
,
out
result
)
||
IsPossibleVariableOrLocalMethodDeclaration
(
token
,
semanticModel
,
cancellationToken
,
out
result
)
||
IsPatternMatching
(
token
,
semanticModel
,
position
,
cancellationToken
,
out
result
))
||
IsPatternMatching
(
token
,
semanticModel
,
cancellationToken
,
out
result
))
{
{
return
result
;
return
result
;
}
}
...
@@ -72,7 +72,7 @@ internal static async Task<NameDeclarationInfo> GetDeclarationInfoAsync(Document
...
@@ -72,7 +72,7 @@ internal static async Task<NameDeclarationInfo> GetDeclarationInfoAsync(Document
}
}
private
static
bool
IsTupleTypeElement
(
private
static
bool
IsTupleTypeElement
(
SyntaxToken
token
,
SemanticModel
semanticModel
,
int
position
,
SyntaxToken
token
,
SemanticModel
semanticModel
,
CancellationToken
cancellationToken
,
out
NameDeclarationInfo
result
)
CancellationToken
cancellationToken
,
out
NameDeclarationInfo
result
)
{
{
result
=
IsFollowingTypeOrComma
<
TupleElementSyntax
>(
result
=
IsFollowingTypeOrComma
<
TupleElementSyntax
>(
...
@@ -86,7 +86,7 @@ internal static async Task<NameDeclarationInfo> GetDeclarationInfoAsync(Document
...
@@ -86,7 +86,7 @@ internal static async Task<NameDeclarationInfo> GetDeclarationInfoAsync(Document
}
}
private
static
bool
IsTupleLiteralElement
(
private
static
bool
IsTupleLiteralElement
(
SyntaxToken
token
,
SemanticModel
semanticModel
,
int
position
,
SyntaxToken
token
,
SemanticModel
semanticModel
,
CancellationToken
cancellationToken
,
out
NameDeclarationInfo
result
)
CancellationToken
cancellationToken
,
out
NameDeclarationInfo
result
)
{
{
// Incomplete code like
// Incomplete code like
...
@@ -110,7 +110,7 @@ internal static async Task<NameDeclarationInfo> GetDeclarationInfoAsync(Document
...
@@ -110,7 +110,7 @@ internal static async Task<NameDeclarationInfo> GetDeclarationInfoAsync(Document
return
false
;
return
false
;
}
}
private
static
bool
IsPossibleOutVariableDeclaration
(
SyntaxToken
token
,
SemanticModel
semanticModel
,
int
position
,
private
static
bool
IsPossibleOutVariableDeclaration
(
SyntaxToken
token
,
SemanticModel
semanticModel
,
ITypeInferenceService
typeInferenceService
,
CancellationToken
cancellationToken
,
out
NameDeclarationInfo
result
)
ITypeInferenceService
typeInferenceService
,
CancellationToken
cancellationToken
,
out
NameDeclarationInfo
result
)
{
{
if
(!
token
.
IsKind
(
SyntaxKind
.
IdentifierToken
)
||
!
token
.
Parent
.
IsKind
(
SyntaxKind
.
IdentifierName
))
if
(!
token
.
IsKind
(
SyntaxKind
.
IdentifierToken
)
||
!
token
.
Parent
.
IsKind
(
SyntaxKind
.
IdentifierName
))
...
@@ -146,7 +146,7 @@ internal static async Task<NameDeclarationInfo> GetDeclarationInfoAsync(Document
...
@@ -146,7 +146,7 @@ internal static async Task<NameDeclarationInfo> GetDeclarationInfoAsync(Document
}
}
private
static
bool
IsPossibleVariableOrLocalMethodDeclaration
(
private
static
bool
IsPossibleVariableOrLocalMethodDeclaration
(
SyntaxToken
token
,
SemanticModel
semanticModel
,
int
position
,
SyntaxToken
token
,
SemanticModel
semanticModel
,
CancellationToken
cancellationToken
,
out
NameDeclarationInfo
result
)
CancellationToken
cancellationToken
,
out
NameDeclarationInfo
result
)
{
{
result
=
IsLastTokenOfType
<
ExpressionStatementSyntax
>(
result
=
IsLastTokenOfType
<
ExpressionStatementSyntax
>(
...
@@ -161,7 +161,7 @@ internal static async Task<NameDeclarationInfo> GetDeclarationInfoAsync(Document
...
@@ -161,7 +161,7 @@ internal static async Task<NameDeclarationInfo> GetDeclarationInfoAsync(Document
}
}
private
static
bool
IsPropertyDeclaration
(
SyntaxToken
token
,
SemanticModel
semanticModel
,
private
static
bool
IsPropertyDeclaration
(
SyntaxToken
token
,
SemanticModel
semanticModel
,
int
position
,
CancellationToken
cancellationToken
,
out
NameDeclarationInfo
result
)
CancellationToken
cancellationToken
,
out
NameDeclarationInfo
result
)
{
{
result
=
IsLastTokenOfType
<
PropertyDeclarationSyntax
>(
result
=
IsLastTokenOfType
<
PropertyDeclarationSyntax
>(
token
,
token
,
...
@@ -175,7 +175,7 @@ internal static async Task<NameDeclarationInfo> GetDeclarationInfoAsync(Document
...
@@ -175,7 +175,7 @@ internal static async Task<NameDeclarationInfo> GetDeclarationInfoAsync(Document
}
}
private
static
bool
IsMethodDeclaration
(
SyntaxToken
token
,
SemanticModel
semanticModel
,
private
static
bool
IsMethodDeclaration
(
SyntaxToken
token
,
SemanticModel
semanticModel
,
int
position
,
CancellationToken
cancellationToken
,
out
NameDeclarationInfo
result
)
CancellationToken
cancellationToken
,
out
NameDeclarationInfo
result
)
{
{
result
=
IsLastTokenOfType
<
MethodDeclarationSyntax
>(
result
=
IsLastTokenOfType
<
MethodDeclarationSyntax
>(
token
,
token
,
...
@@ -276,7 +276,7 @@ internal static async Task<NameDeclarationInfo> GetDeclarationInfoAsync(Document
...
@@ -276,7 +276,7 @@ internal static async Task<NameDeclarationInfo> GetDeclarationInfoAsync(Document
}
}
private
static
bool
IsFieldDeclaration
(
SyntaxToken
token
,
SemanticModel
semanticModel
,
private
static
bool
IsFieldDeclaration
(
SyntaxToken
token
,
SemanticModel
semanticModel
,
int
position
,
CancellationToken
cancellationToken
,
out
NameDeclarationInfo
result
)
CancellationToken
cancellationToken
,
out
NameDeclarationInfo
result
)
{
{
result
=
IsFollowingTypeOrComma
<
VariableDeclarationSyntax
>(
token
,
semanticModel
,
result
=
IsFollowingTypeOrComma
<
VariableDeclarationSyntax
>(
token
,
semanticModel
,
v
=>
v
.
Type
,
v
=>
v
.
Type
,
...
@@ -287,7 +287,7 @@ internal static async Task<NameDeclarationInfo> GetDeclarationInfoAsync(Document
...
@@ -287,7 +287,7 @@ internal static async Task<NameDeclarationInfo> GetDeclarationInfoAsync(Document
}
}
private
static
bool
IsIncompleteMemberDeclaration
(
SyntaxToken
token
,
SemanticModel
semanticModel
,
private
static
bool
IsIncompleteMemberDeclaration
(
SyntaxToken
token
,
SemanticModel
semanticModel
,
int
position
,
CancellationToken
cancellationToken
,
out
NameDeclarationInfo
result
)
CancellationToken
cancellationToken
,
out
NameDeclarationInfo
result
)
{
{
result
=
IsLastTokenOfType
<
IncompleteMemberSyntax
>(
token
,
semanticModel
,
result
=
IsLastTokenOfType
<
IncompleteMemberSyntax
>(
token
,
semanticModel
,
i
=>
i
.
Type
,
i
=>
i
.
Type
,
...
@@ -298,7 +298,7 @@ internal static async Task<NameDeclarationInfo> GetDeclarationInfoAsync(Document
...
@@ -298,7 +298,7 @@ internal static async Task<NameDeclarationInfo> GetDeclarationInfoAsync(Document
}
}
private
static
bool
IsLocalFunctionDeclaration
(
SyntaxToken
token
,
SemanticModel
semanticModel
,
private
static
bool
IsLocalFunctionDeclaration
(
SyntaxToken
token
,
SemanticModel
semanticModel
,
int
position
,
CancellationToken
cancellationToken
,
out
NameDeclarationInfo
result
)
CancellationToken
cancellationToken
,
out
NameDeclarationInfo
result
)
{
{
result
=
IsLastTokenOfType
<
LocalFunctionStatementSyntax
>(
token
,
semanticModel
,
result
=
IsLastTokenOfType
<
LocalFunctionStatementSyntax
>(
token
,
semanticModel
,
typeSyntaxGetter
:
f
=>
f
.
ReturnType
,
typeSyntaxGetter
:
f
=>
f
.
ReturnType
,
...
@@ -309,7 +309,7 @@ internal static async Task<NameDeclarationInfo> GetDeclarationInfoAsync(Document
...
@@ -309,7 +309,7 @@ internal static async Task<NameDeclarationInfo> GetDeclarationInfoAsync(Document
}
}
private
static
bool
IsLocalVariableDeclaration
(
SyntaxToken
token
,
SemanticModel
semanticModel
,
private
static
bool
IsLocalVariableDeclaration
(
SyntaxToken
token
,
SemanticModel
semanticModel
,
int
position
,
CancellationToken
cancellationToken
,
out
NameDeclarationInfo
result
)
CancellationToken
cancellationToken
,
out
NameDeclarationInfo
result
)
{
{
// If we only have a type, this can still end up being a local function (depending on the modifiers).
// If we only have a type, this can still end up being a local function (depending on the modifiers).
var
possibleDeclarationComputer
=
token
.
IsKind
(
SyntaxKind
.
CommaToken
)
var
possibleDeclarationComputer
=
token
.
IsKind
(
SyntaxKind
.
CommaToken
)
...
@@ -328,7 +328,7 @@ internal static async Task<NameDeclarationInfo> GetDeclarationInfoAsync(Document
...
@@ -328,7 +328,7 @@ internal static async Task<NameDeclarationInfo> GetDeclarationInfoAsync(Document
}
}
private
static
bool
IsEmbeddedVariableDeclaration
(
SyntaxToken
token
,
SemanticModel
semanticModel
,
private
static
bool
IsEmbeddedVariableDeclaration
(
SyntaxToken
token
,
SemanticModel
semanticModel
,
int
position
,
CancellationToken
cancellationToken
,
out
NameDeclarationInfo
result
)
CancellationToken
cancellationToken
,
out
NameDeclarationInfo
result
)
{
{
result
=
IsFollowingTypeOrComma
<
VariableDeclarationSyntax
>(
token
,
semanticModel
,
result
=
IsFollowingTypeOrComma
<
VariableDeclarationSyntax
>(
token
,
semanticModel
,
typeSyntaxGetter
:
v
=>
v
.
Type
,
typeSyntaxGetter
:
v
=>
v
.
Type
,
...
@@ -341,7 +341,7 @@ internal static async Task<NameDeclarationInfo> GetDeclarationInfoAsync(Document
...
@@ -341,7 +341,7 @@ internal static async Task<NameDeclarationInfo> GetDeclarationInfoAsync(Document
}
}
private
static
bool
IsForEachVariableDeclaration
(
SyntaxToken
token
,
SemanticModel
semanticModel
,
private
static
bool
IsForEachVariableDeclaration
(
SyntaxToken
token
,
SemanticModel
semanticModel
,
int
position
,
CancellationToken
cancellationToken
,
out
NameDeclarationInfo
result
)
CancellationToken
cancellationToken
,
out
NameDeclarationInfo
result
)
{
{
// This is parsed as ForEachVariableStatementSyntax:
// This is parsed as ForEachVariableStatementSyntax:
// foreach (int $$
// foreach (int $$
...
@@ -356,8 +356,7 @@ internal static async Task<NameDeclarationInfo> GetDeclarationInfoAsync(Document
...
@@ -356,8 +356,7 @@ internal static async Task<NameDeclarationInfo> GetDeclarationInfoAsync(Document
return
result
.
Type
!=
null
;
return
result
.
Type
!=
null
;
}
}
private
static
bool
IsTypeParameterDeclaration
(
SyntaxToken
token
,
SemanticModel
semanticModel
,
private
static
bool
IsTypeParameterDeclaration
(
SyntaxToken
token
,
out
NameDeclarationInfo
result
)
int
position
,
out
NameDeclarationInfo
result
)
{
{
if
(
token
.
IsKind
(
SyntaxKind
.
LessThanToken
,
SyntaxKind
.
CommaToken
)
&&
if
(
token
.
IsKind
(
SyntaxKind
.
LessThanToken
,
SyntaxKind
.
CommaToken
)
&&
token
.
Parent
.
IsKind
(
SyntaxKind
.
TypeParameterList
))
token
.
Parent
.
IsKind
(
SyntaxKind
.
TypeParameterList
))
...
@@ -377,7 +376,7 @@ internal static async Task<NameDeclarationInfo> GetDeclarationInfoAsync(Document
...
@@ -377,7 +376,7 @@ internal static async Task<NameDeclarationInfo> GetDeclarationInfoAsync(Document
}
}
private
static
bool
IsParameterDeclaration
(
SyntaxToken
token
,
SemanticModel
semanticModel
,
private
static
bool
IsParameterDeclaration
(
SyntaxToken
token
,
SemanticModel
semanticModel
,
int
position
,
CancellationToken
cancellationToken
,
out
NameDeclarationInfo
result
)
CancellationToken
cancellationToken
,
out
NameDeclarationInfo
result
)
{
{
result
=
IsLastTokenOfType
<
ParameterSyntax
>(
result
=
IsLastTokenOfType
<
ParameterSyntax
>(
token
,
semanticModel
,
token
,
semanticModel
,
...
@@ -389,7 +388,7 @@ internal static async Task<NameDeclarationInfo> GetDeclarationInfoAsync(Document
...
@@ -389,7 +388,7 @@ internal static async Task<NameDeclarationInfo> GetDeclarationInfoAsync(Document
}
}
private
static
bool
IsPatternMatching
(
SyntaxToken
token
,
SemanticModel
semanticModel
,
private
static
bool
IsPatternMatching
(
SyntaxToken
token
,
SemanticModel
semanticModel
,
int
position
,
CancellationToken
cancellationToken
,
out
NameDeclarationInfo
result
)
CancellationToken
cancellationToken
,
out
NameDeclarationInfo
result
)
{
{
result
=
default
;
result
=
default
;
if
(
token
.
Parent
.
IsParentKind
(
SyntaxKind
.
IsExpression
))
if
(
token
.
Parent
.
IsParentKind
(
SyntaxKind
.
IsExpression
))
...
...
src/Features/CSharp/Portable/Completion/KeywordRecommenders/BaseKeywordRecommender.cs
浏览文件 @
9fc091e1
...
@@ -24,7 +24,7 @@ protected override bool IsValidContext(int position, CSharpSyntaxContext context
...
@@ -24,7 +24,7 @@ protected override bool IsValidContext(int position, CSharpSyntaxContext context
if
(
context
.
ContainingTypeDeclaration
!=
null
)
if
(
context
.
ContainingTypeDeclaration
!=
null
)
{
{
return
return
IsConstructorInitializerContext
(
position
,
context
)
||
IsConstructorInitializerContext
(
context
)
||
IsInstanceExpressionOrStatement
(
context
);
IsInstanceExpressionOrStatement
(
context
);
}
}
...
@@ -41,7 +41,7 @@ private static bool IsInstanceExpressionOrStatement(CSharpSyntaxContext context)
...
@@ -41,7 +41,7 @@ private static bool IsInstanceExpressionOrStatement(CSharpSyntaxContext context)
return
false
;
return
false
;
}
}
private
bool
IsConstructorInitializerContext
(
int
position
,
CSharpSyntaxContext
context
)
private
bool
IsConstructorInitializerContext
(
CSharpSyntaxContext
context
)
{
{
// cases:
// cases:
// Goo() : |
// Goo() : |
...
...
src/Features/CSharp/Portable/ConvertLinq/ConvertForEachToLinqQuery/DefaultConverter.cs
浏览文件 @
9fc091e1
...
@@ -37,12 +37,11 @@ public override void Convert(SyntaxEditor editor, bool convertToQuery, Cancellat
...
@@ -37,12 +37,11 @@ public override void Convert(SyntaxEditor editor, bool convertToQuery, Cancellat
editor
.
ReplaceNode
(
editor
.
ReplaceNode
(
ForEachInfo
.
ForEachStatement
,
ForEachInfo
.
ForEachStatement
,
CreateDefaultReplacementStatement
(
ForEachInfo
,
identifiersUsedInStatements
,
block
,
convertToQuery
)
CreateDefaultReplacementStatement
(
identifiersUsedInStatements
,
block
,
convertToQuery
)
.
WithAdditionalAnnotations
(
Formatter
.
Annotation
));
.
WithAdditionalAnnotations
(
Formatter
.
Annotation
));
}
}
private
StatementSyntax
CreateDefaultReplacementStatement
(
private
StatementSyntax
CreateDefaultReplacementStatement
(
ForEachInfo
<
ForEachStatementSyntax
,
StatementSyntax
>
forEachInfo
,
IEnumerable
<
SyntaxToken
>
identifiers
,
IEnumerable
<
SyntaxToken
>
identifiers
,
BlockSyntax
block
,
BlockSyntax
block
,
bool
convertToQuery
)
bool
convertToQuery
)
...
...
src/Features/CSharp/Portable/EncapsulateField/CSharpEncapsulateFieldService.cs
浏览文件 @
9fc091e1
...
@@ -163,12 +163,12 @@ private bool CanEncapsulate(FieldDeclarationSyntax field)
...
@@ -163,12 +163,12 @@ private bool CanEncapsulate(FieldDeclarationSyntax field)
if
(
newPropertyName
==
field
.
Name
)
if
(
newPropertyName
==
field
.
Name
)
{
{
// If we wind up with the field's old name, give the field the unique version of its current name.
// If we wind up with the field's old name, give the field the unique version of its current name.
return
Tuple
.
Create
(
MakeUnique
(
GenerateFieldName
(
field
,
field
.
Name
),
field
.
ContainingType
),
newPropertyName
);
return
Tuple
.
Create
(
MakeUnique
(
GenerateFieldName
(
field
.
Name
),
field
.
ContainingType
),
newPropertyName
);
}
}
// Otherwise, ensure the property's name is unique.
// Otherwise, ensure the property's name is unique.
newPropertyName
=
MakeUnique
(
newPropertyName
,
field
.
ContainingType
);
newPropertyName
=
MakeUnique
(
newPropertyName
,
field
.
ContainingType
);
var
newFieldName
=
GenerateFieldName
(
field
,
newPropertyName
);
var
newFieldName
=
GenerateFieldName
(
newPropertyName
);
// If converting the new property's name into a field name results in the old field name, we're done.
// If converting the new property's name into a field name results in the old field name, we're done.
if
(
newFieldName
==
field
.
Name
)
if
(
newFieldName
==
field
.
Name
)
...
@@ -186,12 +186,10 @@ private bool IsNew(IFieldSymbol field)
...
@@ -186,12 +186,10 @@ private bool IsNew(IFieldSymbol field)
return
field
.
DeclaringSyntaxReferences
.
Any
(
d
=>
d
.
GetSyntax
().
GetAncestor
<
FieldDeclarationSyntax
>().
Modifiers
.
Any
(
SyntaxKind
.
NewKeyword
));
return
field
.
DeclaringSyntaxReferences
.
Any
(
d
=>
d
.
GetSyntax
().
GetAncestor
<
FieldDeclarationSyntax
>().
Modifiers
.
Any
(
SyntaxKind
.
NewKeyword
));
}
}
private
string
GenerateFieldName
(
IFieldSymbol
field
,
string
correspondingPropertyName
)
private
string
GenerateFieldName
(
string
correspondingPropertyName
)
{
=>
char
.
ToLower
(
correspondingPropertyName
[
0
]).
ToString
()
+
correspondingPropertyName
.
Substring
(
1
);
return
char
.
ToLower
(
correspondingPropertyName
[
0
]).
ToString
()
+
correspondingPropertyName
.
Substring
(
1
);
}
protected
string
MakeUnique
(
string
baseName
,
INamedTypeSymbol
containingType
,
bool
considerBaseMembers
=
true
)
protected
string
MakeUnique
(
string
baseName
,
INamedTypeSymbol
containingType
)
{
{
var
containingTypeMemberNames
=
containingType
.
GetAccessibleMembersInThisAndBaseTypes
<
ISymbol
>(
containingType
).
Select
(
m
=>
m
.
Name
);
var
containingTypeMemberNames
=
containingType
.
GetAccessibleMembersInThisAndBaseTypes
<
ISymbol
>(
containingType
).
Select
(
m
=>
m
.
Name
);
return
NameGenerator
.
GenerateUniqueName
(
baseName
,
containingTypeMemberNames
.
ToSet
(),
StringComparer
.
Ordinal
);
return
NameGenerator
.
GenerateUniqueName
(
baseName
,
containingTypeMemberNames
.
ToSet
(),
StringComparer
.
Ordinal
);
...
...
src/Features/CSharp/Portable/GenerateMember/GenerateParameterizedMember/CSharpCommonGenerationServiceMethods.cs
浏览文件 @
9fc091e1
...
@@ -7,12 +7,12 @@ namespace Microsoft.CodeAnalysis.CSharp.GenerateMember.GenerateParameterizedMemb
...
@@ -7,12 +7,12 @@ namespace Microsoft.CodeAnalysis.CSharp.GenerateMember.GenerateParameterizedMemb
{
{
internal
static
class
CSharpCommonGenerationServiceMethods
internal
static
class
CSharpCommonGenerationServiceMethods
{
{
public
static
bool
AreSpecialOptionsActive
(
SemanticModel
semanticModel
)
public
static
bool
AreSpecialOptionsActive
()
{
{
return
false
;
return
false
;
}
}
public
static
bool
IsValidSymbol
(
ISymbol
symbol
,
SemanticModel
semanticModel
)
public
static
bool
IsValidSymbol
()
{
{
return
false
;
return
false
;
}
}
...
...
src/Features/CSharp/Portable/GenerateMember/GenerateParameterizedMember/CSharpGenerateConversionService.cs
浏览文件 @
9fc091e1
...
@@ -51,14 +51,10 @@ protected override bool ContainingTypesOrSelfHasUnsafeKeyword(INamedTypeSymbol c
...
@@ -51,14 +51,10 @@ protected override bool ContainingTypesOrSelfHasUnsafeKeyword(INamedTypeSymbol c
}
}
protected
override
bool
AreSpecialOptionsActive
(
SemanticModel
semanticModel
)
protected
override
bool
AreSpecialOptionsActive
(
SemanticModel
semanticModel
)
{
=>
CSharpCommonGenerationServiceMethods
.
AreSpecialOptionsActive
();
return
CSharpCommonGenerationServiceMethods
.
AreSpecialOptionsActive
(
semanticModel
);
}
protected
override
bool
IsValidSymbol
(
ISymbol
symbol
,
SemanticModel
semanticModel
)
protected
override
bool
IsValidSymbol
(
ISymbol
symbol
,
SemanticModel
semanticModel
)
{
=>
CSharpCommonGenerationServiceMethods
.
IsValidSymbol
();
return
CSharpCommonGenerationServiceMethods
.
IsValidSymbol
(
symbol
,
semanticModel
);
}
protected
override
bool
TryInitializeImplicitConversionState
(
protected
override
bool
TryInitializeImplicitConversionState
(
SemanticDocument
document
,
SemanticDocument
document
,
...
...
src/Features/CSharp/Portable/GenerateMember/GenerateParameterizedMember/CSharpGenerateDeconstructMethodService.cs
浏览文件 @
9fc091e1
...
@@ -27,9 +27,9 @@ protected override AbstractInvocationInfo CreateInvocationMethodInfo(SemanticDoc
...
@@ -27,9 +27,9 @@ protected override AbstractInvocationInfo CreateInvocationMethodInfo(SemanticDoc
=>
new
CSharpGenerateParameterizedMemberService
<
CSharpGenerateDeconstructMethodService
>.
InvocationExpressionInfo
(
document
,
state
);
=>
new
CSharpGenerateParameterizedMemberService
<
CSharpGenerateDeconstructMethodService
>.
InvocationExpressionInfo
(
document
,
state
);
protected
override
bool
AreSpecialOptionsActive
(
SemanticModel
semanticModel
)
protected
override
bool
AreSpecialOptionsActive
(
SemanticModel
semanticModel
)
=>
CSharpCommonGenerationServiceMethods
.
AreSpecialOptionsActive
(
semanticModel
);
=>
CSharpCommonGenerationServiceMethods
.
AreSpecialOptionsActive
();
protected
override
bool
IsValidSymbol
(
ISymbol
symbol
,
SemanticModel
semanticModel
)
protected
override
bool
IsValidSymbol
(
ISymbol
symbol
,
SemanticModel
semanticModel
)
=>
CSharpCommonGenerationServiceMethods
.
IsValidSymbol
(
symbol
,
semanticModel
);
=>
CSharpCommonGenerationServiceMethods
.
IsValidSymbol
();
}
}
}
}
src/Features/CSharp/Portable/GenerateMember/GenerateParameterizedMember/CSharpGenerateMethodService.cs
浏览文件 @
9fc091e1
...
@@ -41,10 +41,10 @@ protected override AbstractInvocationInfo CreateInvocationMethodInfo(SemanticDoc
...
@@ -41,10 +41,10 @@ protected override AbstractInvocationInfo CreateInvocationMethodInfo(SemanticDoc
}
}
protected
override
bool
AreSpecialOptionsActive
(
SemanticModel
semanticModel
)
protected
override
bool
AreSpecialOptionsActive
(
SemanticModel
semanticModel
)
=>
CSharpCommonGenerationServiceMethods
.
AreSpecialOptionsActive
(
semanticModel
);
=>
CSharpCommonGenerationServiceMethods
.
AreSpecialOptionsActive
();
protected
override
bool
IsValidSymbol
(
ISymbol
symbol
,
SemanticModel
semanticModel
)
protected
override
bool
IsValidSymbol
(
ISymbol
symbol
,
SemanticModel
semanticModel
)
=>
CSharpCommonGenerationServiceMethods
.
IsValidSymbol
(
symbol
,
semanticModel
);
=>
CSharpCommonGenerationServiceMethods
.
IsValidSymbol
();
protected
override
bool
TryInitializeExplicitInterfaceState
(
protected
override
bool
TryInitializeExplicitInterfaceState
(
SemanticDocument
document
,
SemanticDocument
document
,
...
...
src/Features/CSharp/Portable/GenerateType/CSharpGenerateTypeService.cs
浏览文件 @
9fc091e1
...
@@ -619,7 +619,7 @@ protected override bool IsConversionImplicit(Compilation compilation, ITypeSymbo
...
@@ -619,7 +619,7 @@ protected override bool IsConversionImplicit(Compilation compilation, ITypeSymbo
afterThisLocation
);
afterThisLocation
);
}
}
private
NamespaceDeclarationSyntax
GetDeclaringNamespace
(
List
<
string
>
containers
,
int
indexDone
,
CompilationUnitSyntax
compilationUnit
)
private
NamespaceDeclarationSyntax
GetDeclaringNamespace
(
List
<
string
>
containers
,
CompilationUnitSyntax
compilationUnit
)
{
{
foreach
(
var
member
in
compilationUnit
.
Members
)
foreach
(
var
member
in
compilationUnit
.
Members
)
{
{
...
...
src/Features/CSharp/Portable/InlineDeclaration/CSharpInlineDeclarationCodeFixProvider.cs
浏览文件 @
9fc091e1
...
@@ -68,7 +68,7 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context)
...
@@ -68,7 +68,7 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context)
// type of the out-var-decl affects overload resolution or generic instantiation).
// type of the out-var-decl affects overload resolution or generic instantiation).
var
originalRoot
=
editor
.
OriginalRoot
;
var
originalRoot
=
editor
.
OriginalRoot
;
var
originalNodes
=
diagnostics
.
SelectAsArray
(
diagnostic
=>
FindDiagnosticNodes
(
d
ocument
,
diagnostic
,
options
,
cancellationToken
));
var
originalNodes
=
diagnostics
.
SelectAsArray
(
diagnostic
=>
FindDiagnosticNodes
(
d
iagnostic
,
cancellationToken
));
await
editor
.
ApplyExpressionLevelSemanticEditsAsync
(
await
editor
.
ApplyExpressionLevelSemanticEditsAsync
(
document
,
document
,
...
@@ -85,13 +85,12 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context)
...
@@ -85,13 +85,12 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context)
(
semanticModel
,
currentRoot
,
t
,
currentNode
)
(
semanticModel
,
currentRoot
,
t
,
currentNode
)
=>
ReplaceIdentifierWithInlineDeclaration
(
=>
ReplaceIdentifierWithInlineDeclaration
(
options
,
semanticModel
,
currentRoot
,
t
.
declarator
,
options
,
semanticModel
,
currentRoot
,
t
.
declarator
,
t
.
identifier
,
t
.
invocationOrCreation
,
currentNode
,
declarationsToRemove
),
t
.
identifier
,
currentNode
,
declarationsToRemove
),
cancellationToken
).
ConfigureAwait
(
false
);
cancellationToken
).
ConfigureAwait
(
false
);
}
}
private
(
VariableDeclaratorSyntax
declarator
,
IdentifierNameSyntax
identifier
,
SyntaxNode
invocationOrCreation
)
FindDiagnosticNodes
(
private
(
VariableDeclaratorSyntax
declarator
,
IdentifierNameSyntax
identifier
,
SyntaxNode
invocationOrCreation
)
FindDiagnosticNodes
(
Document
document
,
Diagnostic
diagnostic
,
Diagnostic
diagnostic
,
CancellationToken
cancellationToken
)
OptionSet
options
,
CancellationToken
cancellationToken
)
{
{
// Recover the nodes we care about.
// Recover the nodes we care about.
var
declaratorLocation
=
diagnostic
.
AdditionalLocations
[
0
];
var
declaratorLocation
=
diagnostic
.
AdditionalLocations
[
0
];
...
@@ -110,8 +109,7 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context)
...
@@ -110,8 +109,7 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context)
private
SyntaxNode
ReplaceIdentifierWithInlineDeclaration
(
private
SyntaxNode
ReplaceIdentifierWithInlineDeclaration
(
OptionSet
options
,
SemanticModel
semanticModel
,
OptionSet
options
,
SemanticModel
semanticModel
,
SyntaxNode
currentRoot
,
VariableDeclaratorSyntax
declarator
,
SyntaxNode
currentRoot
,
VariableDeclaratorSyntax
declarator
,
IdentifierNameSyntax
identifier
,
SyntaxNode
invocationOrCreation
,
IdentifierNameSyntax
identifier
,
SyntaxNode
currentNode
,
HashSet
<
StatementSyntax
>
declarationsToRemove
)
SyntaxNode
currentNode
,
HashSet
<
StatementSyntax
>
declarationsToRemove
)
{
{
declarator
=
currentRoot
.
GetCurrentNode
(
declarator
);
declarator
=
currentRoot
.
GetCurrentNode
(
declarator
);
identifier
=
currentRoot
.
GetCurrentNode
(
identifier
);
identifier
=
currentRoot
.
GetCurrentNode
(
identifier
);
...
@@ -234,7 +232,7 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context)
...
@@ -234,7 +232,7 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context)
sourceText
,
identifier
,
newType
,
singleDeclarator
?
null
:
declarator
);
sourceText
,
identifier
,
newType
,
singleDeclarator
?
null
:
declarator
);
// Check if using out-var changed problem semantics.
// Check if using out-var changed problem semantics.
var
semanticsChanged
=
SemanticsChanged
(
semanticModel
,
current
Root
,
current
Node
,
identifier
,
declarationExpression
);
var
semanticsChanged
=
SemanticsChanged
(
semanticModel
,
currentNode
,
identifier
,
declarationExpression
);
if
(
semanticsChanged
)
if
(
semanticsChanged
)
{
{
// Switching to 'var' changed semantics. Just use the original type of the local.
// Switching to 'var' changed semantics. Just use the original type of the local.
...
@@ -326,7 +324,6 @@ private static IEnumerable<SyntaxTrivia> MassageTrivia(IEnumerable<SyntaxTrivia>
...
@@ -326,7 +324,6 @@ private static IEnumerable<SyntaxTrivia> MassageTrivia(IEnumerable<SyntaxTrivia>
private
bool
SemanticsChanged
(
private
bool
SemanticsChanged
(
SemanticModel
semanticModel
,
SemanticModel
semanticModel
,
SyntaxNode
root
,
SyntaxNode
nodeToReplace
,
SyntaxNode
nodeToReplace
,
IdentifierNameSyntax
identifier
,
IdentifierNameSyntax
identifier
,
DeclarationExpressionSyntax
declarationExpression
)
DeclarationExpressionSyntax
declarationExpression
)
...
...
src/Features/CSharp/Portable/SignatureHelp/GenericNameSignatureHelpProvider.cs
浏览文件 @
9fc091e1
...
@@ -186,7 +186,7 @@ protected virtual TextSpan GetTextSpan(SyntaxToken genericIdentifier, SyntaxToke
...
@@ -186,7 +186,7 @@ protected virtual TextSpan GetTextSpan(SyntaxToken genericIdentifier, SyntaxToke
symbol
.
GetDocumentationPartsFactory
(
semanticModel
,
position
,
documentationCommentFormattingService
),
symbol
.
GetDocumentationPartsFactory
(
semanticModel
,
position
,
documentationCommentFormattingService
),
GetPreambleParts
(
namedType
,
semanticModel
,
position
),
GetPreambleParts
(
namedType
,
semanticModel
,
position
),
GetSeparatorParts
(),
GetSeparatorParts
(),
GetPostambleParts
(
namedType
),
GetPostambleParts
(),
namedType
.
TypeParameters
.
Select
(
p
=>
Convert
(
p
,
semanticModel
,
position
,
documentationCommentFormattingService
,
cancellationToken
)).
ToList
());
namedType
.
TypeParameters
.
Select
(
p
=>
Convert
(
p
,
semanticModel
,
position
,
documentationCommentFormattingService
,
cancellationToken
)).
ToList
());
}
}
else
else
...
@@ -222,14 +222,13 @@ protected virtual TextSpan GetTextSpan(SyntaxToken genericIdentifier, SyntaxToke
...
@@ -222,14 +222,13 @@ protected virtual TextSpan GetTextSpan(SyntaxToken genericIdentifier, SyntaxToke
isOptional
:
false
,
isOptional
:
false
,
documentationFactory
:
parameter
.
GetDocumentationPartsFactory
(
semanticModel
,
position
,
formatter
),
documentationFactory
:
parameter
.
GetDocumentationPartsFactory
(
semanticModel
,
position
,
formatter
),
displayParts
:
parameter
.
ToMinimalDisplayParts
(
semanticModel
,
position
,
s_minimallyQualifiedFormat
),
displayParts
:
parameter
.
ToMinimalDisplayParts
(
semanticModel
,
position
,
s_minimallyQualifiedFormat
),
selectedDisplayParts
:
GetSelectedDisplayParts
(
parameter
,
semanticModel
,
position
,
cancellationToken
));
selectedDisplayParts
:
GetSelectedDisplayParts
(
parameter
,
semanticModel
,
position
));
}
}
private
IList
<
SymbolDisplayPart
>
GetSelectedDisplayParts
(
private
IList
<
SymbolDisplayPart
>
GetSelectedDisplayParts
(
ITypeParameterSymbol
typeParam
,
ITypeParameterSymbol
typeParam
,
SemanticModel
semanticModel
,
SemanticModel
semanticModel
,
int
position
,
int
position
)
CancellationToken
cancellationToken
)
{
{
var
parts
=
new
List
<
SymbolDisplayPart
>();
var
parts
=
new
List
<
SymbolDisplayPart
>();
...
...
src/Features/CSharp/Portable/SignatureHelp/GenericNameSignatureHelpProvider_NamedType.cs
浏览文件 @
9fc091e1
...
@@ -22,10 +22,7 @@ internal partial class GenericNameSignatureHelpProvider
...
@@ -22,10 +22,7 @@ internal partial class GenericNameSignatureHelpProvider
return
result
;
return
result
;
}
}
private
IList
<
SymbolDisplayPart
>
GetPostambleParts
(
INamedTypeSymbol
namedType
)
private
IList
<
SymbolDisplayPart
>
GetPostambleParts
()
{
=>
SpecializedCollections
.
SingletonList
(
Punctuation
(
SyntaxKind
.
GreaterThanToken
));
return
SpecializedCollections
.
SingletonList
(
Punctuation
(
SyntaxKind
.
GreaterThanToken
));
}
}
}
}
}
src/Features/CSharp/Portable/SignatureHelp/ObjectCreationExpressionSignatureHelpProvider.cs
浏览文件 @
9fc091e1
...
@@ -81,7 +81,7 @@ protected override async Task<SignatureHelpItems> GetItemsWorkerAsync(Document d
...
@@ -81,7 +81,7 @@ protected override async Task<SignatureHelpItems> GetItemsWorkerAsync(Document d
var
syntaxFacts
=
document
.
GetLanguageService
<
ISyntaxFactsService
>();
var
syntaxFacts
=
document
.
GetLanguageService
<
ISyntaxFactsService
>();
var
(
items
,
selectedItem
)
=
type
.
TypeKind
==
TypeKind
.
Delegate
var
(
items
,
selectedItem
)
=
type
.
TypeKind
==
TypeKind
.
Delegate
?
GetDelegateTypeConstructors
(
objectCreationExpression
,
semanticModel
,
symbolDisplayService
,
anonymousTypeDisplayService
,
type
,
within
,
cancellationToken
)
?
GetDelegateTypeConstructors
(
objectCreationExpression
,
semanticModel
,
symbolDisplayService
,
anonymousTypeDisplayService
,
type
,
cancellationToken
)
:
GetNormalTypeConstructors
(
document
,
objectCreationExpression
,
semanticModel
,
symbolDisplayService
,
anonymousTypeDisplayService
,
documentationCommentFormattingService
,
type
,
within
,
cancellationToken
);
:
GetNormalTypeConstructors
(
document
,
objectCreationExpression
,
semanticModel
,
symbolDisplayService
,
anonymousTypeDisplayService
,
documentationCommentFormattingService
,
type
,
within
,
cancellationToken
);
return
CreateSignatureHelpItems
(
items
,
textSpan
,
return
CreateSignatureHelpItems
(
items
,
textSpan
,
...
...
src/Features/CSharp/Portable/SignatureHelp/ObjectCreationExpressionSignatureHelpProvider_DelegateType.cs
浏览文件 @
9fc091e1
...
@@ -19,7 +19,6 @@ internal partial class ObjectCreationExpressionSignatureHelpProvider
...
@@ -19,7 +19,6 @@ internal partial class ObjectCreationExpressionSignatureHelpProvider
ISymbolDisplayService
symbolDisplayService
,
ISymbolDisplayService
symbolDisplayService
,
IAnonymousTypeDisplayService
anonymousTypeDisplayService
,
IAnonymousTypeDisplayService
anonymousTypeDisplayService
,
INamedTypeSymbol
delegateType
,
INamedTypeSymbol
delegateType
,
INamedTypeSymbol
containingType
,
CancellationToken
cancellationToken
)
CancellationToken
cancellationToken
)
{
{
var
invokeMethod
=
delegateType
.
DelegateInvokeMethod
;
var
invokeMethod
=
delegateType
.
DelegateInvokeMethod
;
...
@@ -36,8 +35,8 @@ internal partial class ObjectCreationExpressionSignatureHelpProvider
...
@@ -36,8 +35,8 @@ internal partial class ObjectCreationExpressionSignatureHelpProvider
documentationFactory
:
null
,
documentationFactory
:
null
,
prefixParts
:
GetDelegateTypePreambleParts
(
invokeMethod
,
semanticModel
,
position
),
prefixParts
:
GetDelegateTypePreambleParts
(
invokeMethod
,
semanticModel
,
position
),
separatorParts
:
GetSeparatorParts
(),
separatorParts
:
GetSeparatorParts
(),
suffixParts
:
GetDelegateTypePostambleParts
(
invokeMethod
),
suffixParts
:
GetDelegateTypePostambleParts
(),
parameters
:
GetDelegateTypeParameters
(
invokeMethod
,
semanticModel
,
position
,
cancellationToken
));
parameters
:
GetDelegateTypeParameters
(
invokeMethod
,
semanticModel
,
position
));
return
(
SpecializedCollections
.
SingletonList
(
item
),
0
);
return
(
SpecializedCollections
.
SingletonList
(
item
),
0
);
}
}
...
@@ -52,7 +51,7 @@ private IList<SymbolDisplayPart> GetDelegateTypePreambleParts(IMethodSymbol invo
...
@@ -52,7 +51,7 @@ private IList<SymbolDisplayPart> GetDelegateTypePreambleParts(IMethodSymbol invo
return
result
;
return
result
;
}
}
private
IList
<
SignatureHelpSymbolParameter
>
GetDelegateTypeParameters
(
IMethodSymbol
invokeMethod
,
SemanticModel
semanticModel
,
int
position
,
CancellationToken
cancellationToken
)
private
IList
<
SignatureHelpSymbolParameter
>
GetDelegateTypeParameters
(
IMethodSymbol
invokeMethod
,
SemanticModel
semanticModel
,
int
position
)
{
{
const
string
TargetName
=
"target"
;
const
string
TargetName
=
"target"
;
...
@@ -86,10 +85,7 @@ private IList<SignatureHelpSymbolParameter> GetDelegateTypeParameters(IMethodSym
...
@@ -86,10 +85,7 @@ private IList<SignatureHelpSymbolParameter> GetDelegateTypeParameters(IMethodSym
displayParts
:
parts
));
displayParts
:
parts
));
}
}
private
IList
<
SymbolDisplayPart
>
GetDelegateTypePostambleParts
(
IMethodSymbol
invokeMethod
)
private
IList
<
SymbolDisplayPart
>
GetDelegateTypePostambleParts
()
{
=>
SpecializedCollections
.
SingletonList
(
Punctuation
(
SyntaxKind
.
CloseParenToken
));
return
SpecializedCollections
.
SingletonList
(
Punctuation
(
SyntaxKind
.
CloseParenToken
));
}
}
}
}
}
src/Features/CSharp/Portable/UseIndexOrRangeOperator/CSharpUseRangeOperatorCodeFixProvider.cs
浏览文件 @
9fc091e1
...
@@ -77,7 +77,7 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context)
...
@@ -77,7 +77,7 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context)
if
(
resultOpt
!=
null
)
if
(
resultOpt
!=
null
)
{
{
var
result
=
resultOpt
.
Value
;
var
result
=
resultOpt
.
Value
;
var
updatedNode
=
FixOne
(
result
,
cancellationToken
);
var
updatedNode
=
FixOne
(
result
);
if
(
updatedNode
!=
null
)
if
(
updatedNode
!=
null
)
{
{
return
currentRoot
.
ReplaceNode
(
result
.
Invocation
,
updatedNode
);
return
currentRoot
.
ReplaceNode
(
result
.
Invocation
,
updatedNode
);
...
@@ -91,7 +91,7 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context)
...
@@ -91,7 +91,7 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context)
private
static
InvocationExpressionSyntax
GetInvocationExpression
(
Diagnostic
d
,
CancellationToken
cancellationToken
)
private
static
InvocationExpressionSyntax
GetInvocationExpression
(
Diagnostic
d
,
CancellationToken
cancellationToken
)
=>
(
InvocationExpressionSyntax
)
d
.
AdditionalLocations
[
0
].
FindNode
(
getInnermostNodeForTie
:
true
,
cancellationToken
);
=>
(
InvocationExpressionSyntax
)
d
.
AdditionalLocations
[
0
].
FindNode
(
getInnermostNodeForTie
:
true
,
cancellationToken
);
private
ExpressionSyntax
FixOne
(
Result
result
,
CancellationToken
cancellationToken
)
private
ExpressionSyntax
FixOne
(
Result
result
)
{
{
var
invocation
=
result
.
Invocation
;
var
invocation
=
result
.
Invocation
;
var
expression
=
invocation
.
Expression
is
MemberAccessExpressionSyntax
memberAccess
var
expression
=
invocation
.
Expression
is
MemberAccessExpressionSyntax
memberAccess
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录