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)
Debug
.
Assert
(
_assignmentTargetOpt
!=
null
);
return
generateDeclaration
?
GenerateVariableDeclaration
(
switchExpression
,
leadingTrivia
,
declaratorToRemoveTypeOpt
)
?
GenerateVariableDeclaration
(
switchExpression
,
declaratorToRemoveTypeOpt
)
:
GenerateAssignment
(
switchExpression
,
nodeToGenerate
,
leadingTrivia
);
}
...
...
@@ -82,7 +82,7 @@ private ExpressionStatementSyntax GenerateAssignment(ExpressionSyntax switchExpr
.
WithLeadingTrivia
(
leadingTrivia
);
}
private
StatementSyntax
GenerateVariableDeclaration
(
ExpressionSyntax
switchExpression
,
SyntaxTriviaList
leadingTrivia
,
ITypeSymbol
declaratorToRemoveTypeOpt
)
private
StatementSyntax
GenerateVariableDeclaration
(
ExpressionSyntax
switchExpression
,
ITypeSymbol
declaratorToRemoveTypeOpt
)
{
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,
internal
static
ImmutableHashSet
<
char
>
CommonTriggerCharactersWithArgumentList
{
get
;
}
=
ImmutableHashSet
.
Create
(
'.'
,
'#'
,
'>'
,
':'
,
'('
,
'['
,
' '
);
internal
static
bool
IsTriggerCharacterOrArgumentListCharacter
(
SourceText
text
,
int
characterPosition
,
OptionSet
options
)
{
return
IsTriggerCharacter
(
text
,
characterPosition
,
options
)
||
IsArgumentListCharacter
(
text
,
characterPosition
,
options
);
}
=>
IsTriggerCharacter
(
text
,
characterPosition
,
options
)
||
IsArgumentListCharacter
(
text
,
characterPosition
);
private
static
bool
IsArgumentListCharacter
(
SourceText
text
,
int
characterPosition
,
OptionSet
options
)
{
return
IsArgumentListCharacter
(
text
[
characterPosition
]);
}
private
static
bool
IsArgumentListCharacter
(
SourceText
text
,
int
characterPosition
)
=>
IsArgumentListCharacter
(
text
[
characterPosition
]);
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)
var
serializedOptions
=
ImmutableDictionary
<
string
,
string
>.
Empty
.
Add
(
HideAdvancedMembers
,
hideAdvancedMembers
.
ToString
());
var
items
=
CreateCompletionItems
(
document
.
Project
.
Solution
.
Workspace
,
semanticModel
,
symbols
,
token
,
span
,
position
,
serializedOptions
);
semanticModel
,
symbols
,
token
,
position
,
serializedOptions
);
context
.
AddItems
(
items
);
}
...
...
@@ -270,15 +270,15 @@ private static TextSpan GetCompletionItemSpan(SourceText text, int position)
}
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
();
try
{
foreach
(
var
symbol
in
symbols
)
{
yield
return
CreateItem
(
workspace
,
semanticModel
,
symbol
,
token
,
position
,
builder
,
options
);
if
(
TryCreateSpecialTypeItem
(
workspace
,
semanticModel
,
symbol
,
token
,
position
,
builder
,
options
,
out
var
item
))
yield
return
CreateItem
(
semanticModel
,
symbol
,
token
,
position
,
builder
,
options
);
if
(
TryCreateSpecialTypeItem
(
semanticModel
,
symbol
,
token
,
position
,
builder
,
options
,
out
var
item
))
{
yield
return
item
;
}
...
...
@@ -291,7 +291,7 @@ private static TextSpan GetCompletionItemSpan(SourceText text, int position)
}
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
)
{
// If the type is a SpecialType, create an additional item using
...
...
@@ -299,7 +299,7 @@ private static TextSpan GetCompletionItemSpan(SourceText text, int position)
var
typeSymbol
=
symbol
as
ITypeSymbol
;
if
(
typeSymbol
.
IsSpecialType
())
{
item
=
CreateItem
(
workspace
,
semanticModel
,
symbol
,
token
,
position
,
builder
,
options
,
CrefFormatForSpecialTypes
);
item
=
CreateItem
(
semanticModel
,
symbol
,
token
,
position
,
builder
,
options
,
CrefFormatForSpecialTypes
);
return
true
;
}
...
...
@@ -308,15 +308,15 @@ private static TextSpan GetCompletionItemSpan(SourceText text, int position)
}
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,
// 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
(
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
)
{
builder
.
Clear
();
...
...
src/Features/CSharp/Portable/Completion/CompletionProviders/DeclarationNameCompletionProvider.DeclarationInfo.cs
浏览文件 @
9fc091e1
...
...
@@ -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
typeInferenceService
=
document
.
GetLanguageService
<
ITypeInferenceService
>();
if
(
IsTupleTypeElement
(
token
,
semanticModel
,
position
,
cancellationToken
,
out
var
result
)
||
IsParameterDeclaration
(
token
,
semanticModel
,
position
,
cancellationToken
,
out
result
)
||
IsTypeParameterDeclaration
(
token
,
semanticModel
,
position
,
out
result
)
||
IsLocalFunctionDeclaration
(
token
,
semanticModel
,
position
,
cancellationToken
,
out
result
)
||
IsLocalVariableDeclaration
(
token
,
semanticModel
,
position
,
cancellationToken
,
out
result
)
||
IsEmbeddedVariableDeclaration
(
token
,
semanticModel
,
position
,
cancellationToken
,
out
result
)
||
IsForEachVariableDeclaration
(
token
,
semanticModel
,
position
,
cancellationToken
,
out
result
)
||
IsIncompleteMemberDeclaration
(
token
,
semanticModel
,
position
,
cancellationToken
,
out
result
)
||
IsFieldDeclaration
(
token
,
semanticModel
,
position
,
cancellationToken
,
out
result
)
||
IsMethodDeclaration
(
token
,
semanticModel
,
position
,
cancellationToken
,
out
result
)
||
IsPropertyDeclaration
(
token
,
semanticModel
,
position
,
cancellationToken
,
out
result
)
||
IsPossibleOutVariableDeclaration
(
token
,
semanticModel
,
position
,
typeInferenceService
,
cancellationToken
,
out
result
)
||
IsTupleLiteralElement
(
token
,
semanticModel
,
position
,
cancellationToken
,
out
result
)
||
IsPossibleVariableOrLocalMethodDeclaration
(
token
,
semanticModel
,
position
,
cancellationToken
,
out
result
)
||
IsPatternMatching
(
token
,
semanticModel
,
position
,
cancellationToken
,
out
result
))
if
(
IsTupleTypeElement
(
token
,
semanticModel
,
cancellationToken
,
out
var
result
)
||
IsParameterDeclaration
(
token
,
semanticModel
,
cancellationToken
,
out
result
)
||
IsTypeParameterDeclaration
(
token
,
out
result
)
||
IsLocalFunctionDeclaration
(
token
,
semanticModel
,
cancellationToken
,
out
result
)
||
IsLocalVariableDeclaration
(
token
,
semanticModel
,
cancellationToken
,
out
result
)
||
IsEmbeddedVariableDeclaration
(
token
,
semanticModel
,
cancellationToken
,
out
result
)
||
IsForEachVariableDeclaration
(
token
,
semanticModel
,
cancellationToken
,
out
result
)
||
IsIncompleteMemberDeclaration
(
token
,
semanticModel
,
cancellationToken
,
out
result
)
||
IsFieldDeclaration
(
token
,
semanticModel
,
cancellationToken
,
out
result
)
||
IsMethodDeclaration
(
token
,
semanticModel
,
cancellationToken
,
out
result
)
||
IsPropertyDeclaration
(
token
,
semanticModel
,
cancellationToken
,
out
result
)
||
IsPossibleOutVariableDeclaration
(
token
,
semanticModel
,
typeInferenceService
,
cancellationToken
,
out
result
)
||
IsTupleLiteralElement
(
token
,
semanticModel
,
cancellationToken
,
out
result
)
||
IsPossibleVariableOrLocalMethodDeclaration
(
token
,
semanticModel
,
cancellationToken
,
out
result
)
||
IsPatternMatching
(
token
,
semanticModel
,
cancellationToken
,
out
result
))
{
return
result
;
}
...
...
@@ -72,7 +72,7 @@ internal static async Task<NameDeclarationInfo> GetDeclarationInfoAsync(Document
}
private
static
bool
IsTupleTypeElement
(
SyntaxToken
token
,
SemanticModel
semanticModel
,
int
position
,
SyntaxToken
token
,
SemanticModel
semanticModel
,
CancellationToken
cancellationToken
,
out
NameDeclarationInfo
result
)
{
result
=
IsFollowingTypeOrComma
<
TupleElementSyntax
>(
...
...
@@ -86,7 +86,7 @@ internal static async Task<NameDeclarationInfo> GetDeclarationInfoAsync(Document
}
private
static
bool
IsTupleLiteralElement
(
SyntaxToken
token
,
SemanticModel
semanticModel
,
int
position
,
SyntaxToken
token
,
SemanticModel
semanticModel
,
CancellationToken
cancellationToken
,
out
NameDeclarationInfo
result
)
{
// Incomplete code like
...
...
@@ -110,7 +110,7 @@ internal static async Task<NameDeclarationInfo> GetDeclarationInfoAsync(Document
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
)
{
if
(!
token
.
IsKind
(
SyntaxKind
.
IdentifierToken
)
||
!
token
.
Parent
.
IsKind
(
SyntaxKind
.
IdentifierName
))
...
...
@@ -146,7 +146,7 @@ internal static async Task<NameDeclarationInfo> GetDeclarationInfoAsync(Document
}
private
static
bool
IsPossibleVariableOrLocalMethodDeclaration
(
SyntaxToken
token
,
SemanticModel
semanticModel
,
int
position
,
SyntaxToken
token
,
SemanticModel
semanticModel
,
CancellationToken
cancellationToken
,
out
NameDeclarationInfo
result
)
{
result
=
IsLastTokenOfType
<
ExpressionStatementSyntax
>(
...
...
@@ -161,7 +161,7 @@ internal static async Task<NameDeclarationInfo> GetDeclarationInfoAsync(Document
}
private
static
bool
IsPropertyDeclaration
(
SyntaxToken
token
,
SemanticModel
semanticModel
,
int
position
,
CancellationToken
cancellationToken
,
out
NameDeclarationInfo
result
)
CancellationToken
cancellationToken
,
out
NameDeclarationInfo
result
)
{
result
=
IsLastTokenOfType
<
PropertyDeclarationSyntax
>(
token
,
...
...
@@ -175,7 +175,7 @@ internal static async Task<NameDeclarationInfo> GetDeclarationInfoAsync(Document
}
private
static
bool
IsMethodDeclaration
(
SyntaxToken
token
,
SemanticModel
semanticModel
,
int
position
,
CancellationToken
cancellationToken
,
out
NameDeclarationInfo
result
)
CancellationToken
cancellationToken
,
out
NameDeclarationInfo
result
)
{
result
=
IsLastTokenOfType
<
MethodDeclarationSyntax
>(
token
,
...
...
@@ -276,7 +276,7 @@ internal static async Task<NameDeclarationInfo> GetDeclarationInfoAsync(Document
}
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
,
v
=>
v
.
Type
,
...
...
@@ -287,7 +287,7 @@ internal static async Task<NameDeclarationInfo> GetDeclarationInfoAsync(Document
}
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
,
i
=>
i
.
Type
,
...
...
@@ -298,7 +298,7 @@ internal static async Task<NameDeclarationInfo> GetDeclarationInfoAsync(Document
}
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
,
typeSyntaxGetter
:
f
=>
f
.
ReturnType
,
...
...
@@ -309,7 +309,7 @@ internal static async Task<NameDeclarationInfo> GetDeclarationInfoAsync(Document
}
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).
var
possibleDeclarationComputer
=
token
.
IsKind
(
SyntaxKind
.
CommaToken
)
...
...
@@ -328,7 +328,7 @@ internal static async Task<NameDeclarationInfo> GetDeclarationInfoAsync(Document
}
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
,
typeSyntaxGetter
:
v
=>
v
.
Type
,
...
...
@@ -341,7 +341,7 @@ internal static async Task<NameDeclarationInfo> GetDeclarationInfoAsync(Document
}
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:
// foreach (int $$
...
...
@@ -356,8 +356,7 @@ internal static async Task<NameDeclarationInfo> GetDeclarationInfoAsync(Document
return
result
.
Type
!=
null
;
}
private
static
bool
IsTypeParameterDeclaration
(
SyntaxToken
token
,
SemanticModel
semanticModel
,
int
position
,
out
NameDeclarationInfo
result
)
private
static
bool
IsTypeParameterDeclaration
(
SyntaxToken
token
,
out
NameDeclarationInfo
result
)
{
if
(
token
.
IsKind
(
SyntaxKind
.
LessThanToken
,
SyntaxKind
.
CommaToken
)
&&
token
.
Parent
.
IsKind
(
SyntaxKind
.
TypeParameterList
))
...
...
@@ -377,7 +376,7 @@ internal static async Task<NameDeclarationInfo> GetDeclarationInfoAsync(Document
}
private
static
bool
IsParameterDeclaration
(
SyntaxToken
token
,
SemanticModel
semanticModel
,
int
position
,
CancellationToken
cancellationToken
,
out
NameDeclarationInfo
result
)
CancellationToken
cancellationToken
,
out
NameDeclarationInfo
result
)
{
result
=
IsLastTokenOfType
<
ParameterSyntax
>(
token
,
semanticModel
,
...
...
@@ -389,7 +388,7 @@ internal static async Task<NameDeclarationInfo> GetDeclarationInfoAsync(Document
}
private
static
bool
IsPatternMatching
(
SyntaxToken
token
,
SemanticModel
semanticModel
,
int
position
,
CancellationToken
cancellationToken
,
out
NameDeclarationInfo
result
)
CancellationToken
cancellationToken
,
out
NameDeclarationInfo
result
)
{
result
=
default
;
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
if
(
context
.
ContainingTypeDeclaration
!=
null
)
{
return
IsConstructorInitializerContext
(
position
,
context
)
||
IsConstructorInitializerContext
(
context
)
||
IsInstanceExpressionOrStatement
(
context
);
}
...
...
@@ -41,7 +41,7 @@ private static bool IsInstanceExpressionOrStatement(CSharpSyntaxContext context)
return
false
;
}
private
bool
IsConstructorInitializerContext
(
int
position
,
CSharpSyntaxContext
context
)
private
bool
IsConstructorInitializerContext
(
CSharpSyntaxContext
context
)
{
// cases:
// Goo() : |
...
...
src/Features/CSharp/Portable/ConvertLinq/ConvertForEachToLinqQuery/DefaultConverter.cs
浏览文件 @
9fc091e1
...
...
@@ -37,12 +37,11 @@ public override void Convert(SyntaxEditor editor, bool convertToQuery, Cancellat
editor
.
ReplaceNode
(
ForEachInfo
.
ForEachStatement
,
CreateDefaultReplacementStatement
(
ForEachInfo
,
identifiersUsedInStatements
,
block
,
convertToQuery
)
CreateDefaultReplacementStatement
(
identifiersUsedInStatements
,
block
,
convertToQuery
)
.
WithAdditionalAnnotations
(
Formatter
.
Annotation
));
}
private
StatementSyntax
CreateDefaultReplacementStatement
(
ForEachInfo
<
ForEachStatementSyntax
,
StatementSyntax
>
forEachInfo
,
IEnumerable
<
SyntaxToken
>
identifiers
,
BlockSyntax
block
,
bool
convertToQuery
)
...
...
src/Features/CSharp/Portable/EncapsulateField/CSharpEncapsulateFieldService.cs
浏览文件 @
9fc091e1
...
...
@@ -163,12 +163,12 @@ private bool CanEncapsulate(FieldDeclarationSyntax field)
if
(
newPropertyName
==
field
.
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.
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
(
newFieldName
==
field
.
Name
)
...
...
@@ -186,12 +186,10 @@ private bool IsNew(IFieldSymbol field)
return
field
.
DeclaringSyntaxReferences
.
Any
(
d
=>
d
.
GetSyntax
().
GetAncestor
<
FieldDeclarationSyntax
>().
Modifiers
.
Any
(
SyntaxKind
.
NewKeyword
));
}
private
string
GenerateFieldName
(
IFieldSymbol
field
,
string
correspondingPropertyName
)
{
return
char
.
ToLower
(
correspondingPropertyName
[
0
]).
ToString
()
+
correspondingPropertyName
.
Substring
(
1
);
}
private
string
GenerateFieldName
(
string
correspondingPropertyName
)
=>
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
);
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
{
internal
static
class
CSharpCommonGenerationServiceMethods
{
public
static
bool
AreSpecialOptionsActive
(
SemanticModel
semanticModel
)
public
static
bool
AreSpecialOptionsActive
()
{
return
false
;
}
public
static
bool
IsValidSymbol
(
ISymbol
symbol
,
SemanticModel
semanticModel
)
public
static
bool
IsValidSymbol
()
{
return
false
;
}
...
...
src/Features/CSharp/Portable/GenerateMember/GenerateParameterizedMember/CSharpGenerateConversionService.cs
浏览文件 @
9fc091e1
...
...
@@ -51,14 +51,10 @@ protected override bool ContainingTypesOrSelfHasUnsafeKeyword(INamedTypeSymbol c
}
protected
override
bool
AreSpecialOptionsActive
(
SemanticModel
semanticModel
)
{
return
CSharpCommonGenerationServiceMethods
.
AreSpecialOptionsActive
(
semanticModel
);
}
=>
CSharpCommonGenerationServiceMethods
.
AreSpecialOptionsActive
();
protected
override
bool
IsValidSymbol
(
ISymbol
symbol
,
SemanticModel
semanticModel
)
{
return
CSharpCommonGenerationServiceMethods
.
IsValidSymbol
(
symbol
,
semanticModel
);
}
=>
CSharpCommonGenerationServiceMethods
.
IsValidSymbol
();
protected
override
bool
TryInitializeImplicitConversionState
(
SemanticDocument
document
,
...
...
src/Features/CSharp/Portable/GenerateMember/GenerateParameterizedMember/CSharpGenerateDeconstructMethodService.cs
浏览文件 @
9fc091e1
...
...
@@ -27,9 +27,9 @@ protected override AbstractInvocationInfo CreateInvocationMethodInfo(SemanticDoc
=>
new
CSharpGenerateParameterizedMemberService
<
CSharpGenerateDeconstructMethodService
>.
InvocationExpressionInfo
(
document
,
state
);
protected
override
bool
AreSpecialOptionsActive
(
SemanticModel
semanticModel
)
=>
CSharpCommonGenerationServiceMethods
.
AreSpecialOptionsActive
(
semanticModel
);
=>
CSharpCommonGenerationServiceMethods
.
AreSpecialOptionsActive
();
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
}
protected
override
bool
AreSpecialOptionsActive
(
SemanticModel
semanticModel
)
=>
CSharpCommonGenerationServiceMethods
.
AreSpecialOptionsActive
(
semanticModel
);
=>
CSharpCommonGenerationServiceMethods
.
AreSpecialOptionsActive
();
protected
override
bool
IsValidSymbol
(
ISymbol
symbol
,
SemanticModel
semanticModel
)
=>
CSharpCommonGenerationServiceMethods
.
IsValidSymbol
(
symbol
,
semanticModel
);
=>
CSharpCommonGenerationServiceMethods
.
IsValidSymbol
();
protected
override
bool
TryInitializeExplicitInterfaceState
(
SemanticDocument
document
,
...
...
src/Features/CSharp/Portable/GenerateType/CSharpGenerateTypeService.cs
浏览文件 @
9fc091e1
...
...
@@ -619,7 +619,7 @@ protected override bool IsConversionImplicit(Compilation compilation, ITypeSymbo
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
)
{
...
...
src/Features/CSharp/Portable/InlineDeclaration/CSharpInlineDeclarationCodeFixProvider.cs
浏览文件 @
9fc091e1
...
...
@@ -68,7 +68,7 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context)
// type of the out-var-decl affects overload resolution or generic instantiation).
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
(
document
,
...
...
@@ -85,13 +85,12 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context)
(
semanticModel
,
currentRoot
,
t
,
currentNode
)
=>
ReplaceIdentifierWithInlineDeclaration
(
options
,
semanticModel
,
currentRoot
,
t
.
declarator
,
t
.
identifier
,
t
.
invocationOrCreation
,
currentNode
,
declarationsToRemove
),
t
.
identifier
,
currentNode
,
declarationsToRemove
),
cancellationToken
).
ConfigureAwait
(
false
);
}
private
(
VariableDeclaratorSyntax
declarator
,
IdentifierNameSyntax
identifier
,
SyntaxNode
invocationOrCreation
)
FindDiagnosticNodes
(
Document
document
,
Diagnostic
diagnostic
,
OptionSet
options
,
CancellationToken
cancellationToken
)
Diagnostic
diagnostic
,
CancellationToken
cancellationToken
)
{
// Recover the nodes we care about.
var
declaratorLocation
=
diagnostic
.
AdditionalLocations
[
0
];
...
...
@@ -110,8 +109,7 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context)
private
SyntaxNode
ReplaceIdentifierWithInlineDeclaration
(
OptionSet
options
,
SemanticModel
semanticModel
,
SyntaxNode
currentRoot
,
VariableDeclaratorSyntax
declarator
,
IdentifierNameSyntax
identifier
,
SyntaxNode
invocationOrCreation
,
SyntaxNode
currentNode
,
HashSet
<
StatementSyntax
>
declarationsToRemove
)
IdentifierNameSyntax
identifier
,
SyntaxNode
currentNode
,
HashSet
<
StatementSyntax
>
declarationsToRemove
)
{
declarator
=
currentRoot
.
GetCurrentNode
(
declarator
);
identifier
=
currentRoot
.
GetCurrentNode
(
identifier
);
...
...
@@ -234,7 +232,7 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context)
sourceText
,
identifier
,
newType
,
singleDeclarator
?
null
:
declarator
);
// 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
)
{
// Switching to 'var' changed semantics. Just use the original type of the local.
...
...
@@ -326,7 +324,6 @@ private static IEnumerable<SyntaxTrivia> MassageTrivia(IEnumerable<SyntaxTrivia>
private
bool
SemanticsChanged
(
SemanticModel
semanticModel
,
SyntaxNode
root
,
SyntaxNode
nodeToReplace
,
IdentifierNameSyntax
identifier
,
DeclarationExpressionSyntax
declarationExpression
)
...
...
src/Features/CSharp/Portable/SignatureHelp/GenericNameSignatureHelpProvider.cs
浏览文件 @
9fc091e1
...
...
@@ -186,7 +186,7 @@ protected virtual TextSpan GetTextSpan(SyntaxToken genericIdentifier, SyntaxToke
symbol
.
GetDocumentationPartsFactory
(
semanticModel
,
position
,
documentationCommentFormattingService
),
GetPreambleParts
(
namedType
,
semanticModel
,
position
),
GetSeparatorParts
(),
GetPostambleParts
(
namedType
),
GetPostambleParts
(),
namedType
.
TypeParameters
.
Select
(
p
=>
Convert
(
p
,
semanticModel
,
position
,
documentationCommentFormattingService
,
cancellationToken
)).
ToList
());
}
else
...
...
@@ -222,14 +222,13 @@ protected virtual TextSpan GetTextSpan(SyntaxToken genericIdentifier, SyntaxToke
isOptional
:
false
,
documentationFactory
:
parameter
.
GetDocumentationPartsFactory
(
semanticModel
,
position
,
formatter
),
displayParts
:
parameter
.
ToMinimalDisplayParts
(
semanticModel
,
position
,
s_minimallyQualifiedFormat
),
selectedDisplayParts
:
GetSelectedDisplayParts
(
parameter
,
semanticModel
,
position
,
cancellationToken
));
selectedDisplayParts
:
GetSelectedDisplayParts
(
parameter
,
semanticModel
,
position
));
}
private
IList
<
SymbolDisplayPart
>
GetSelectedDisplayParts
(
ITypeParameterSymbol
typeParam
,
SemanticModel
semanticModel
,
int
position
,
CancellationToken
cancellationToken
)
int
position
)
{
var
parts
=
new
List
<
SymbolDisplayPart
>();
...
...
src/Features/CSharp/Portable/SignatureHelp/GenericNameSignatureHelpProvider_NamedType.cs
浏览文件 @
9fc091e1
...
...
@@ -22,10 +22,7 @@ internal partial class GenericNameSignatureHelpProvider
return
result
;
}
private
IList
<
SymbolDisplayPart
>
GetPostambleParts
(
INamedTypeSymbol
namedType
)
{
return
SpecializedCollections
.
SingletonList
(
Punctuation
(
SyntaxKind
.
GreaterThanToken
));
}
private
IList
<
SymbolDisplayPart
>
GetPostambleParts
()
=>
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
var
syntaxFacts
=
document
.
GetLanguageService
<
ISyntaxFactsService
>();
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
);
return
CreateSignatureHelpItems
(
items
,
textSpan
,
...
...
src/Features/CSharp/Portable/SignatureHelp/ObjectCreationExpressionSignatureHelpProvider_DelegateType.cs
浏览文件 @
9fc091e1
...
...
@@ -19,7 +19,6 @@ internal partial class ObjectCreationExpressionSignatureHelpProvider
ISymbolDisplayService
symbolDisplayService
,
IAnonymousTypeDisplayService
anonymousTypeDisplayService
,
INamedTypeSymbol
delegateType
,
INamedTypeSymbol
containingType
,
CancellationToken
cancellationToken
)
{
var
invokeMethod
=
delegateType
.
DelegateInvokeMethod
;
...
...
@@ -36,8 +35,8 @@ internal partial class ObjectCreationExpressionSignatureHelpProvider
documentationFactory
:
null
,
prefixParts
:
GetDelegateTypePreambleParts
(
invokeMethod
,
semanticModel
,
position
),
separatorParts
:
GetSeparatorParts
(),
suffixParts
:
GetDelegateTypePostambleParts
(
invokeMethod
),
parameters
:
GetDelegateTypeParameters
(
invokeMethod
,
semanticModel
,
position
,
cancellationToken
));
suffixParts
:
GetDelegateTypePostambleParts
(),
parameters
:
GetDelegateTypeParameters
(
invokeMethod
,
semanticModel
,
position
));
return
(
SpecializedCollections
.
SingletonList
(
item
),
0
);
}
...
...
@@ -52,7 +51,7 @@ private IList<SymbolDisplayPart> GetDelegateTypePreambleParts(IMethodSymbol invo
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"
;
...
...
@@ -86,10 +85,7 @@ private IList<SignatureHelpSymbolParameter> GetDelegateTypeParameters(IMethodSym
displayParts
:
parts
));
}
private
IList
<
SymbolDisplayPart
>
GetDelegateTypePostambleParts
(
IMethodSymbol
invokeMethod
)
{
return
SpecializedCollections
.
SingletonList
(
Punctuation
(
SyntaxKind
.
CloseParenToken
));
}
private
IList
<
SymbolDisplayPart
>
GetDelegateTypePostambleParts
()
=>
SpecializedCollections
.
SingletonList
(
Punctuation
(
SyntaxKind
.
CloseParenToken
));
}
}
src/Features/CSharp/Portable/UseIndexOrRangeOperator/CSharpUseRangeOperatorCodeFixProvider.cs
浏览文件 @
9fc091e1
...
...
@@ -77,7 +77,7 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context)
if
(
resultOpt
!=
null
)
{
var
result
=
resultOpt
.
Value
;
var
updatedNode
=
FixOne
(
result
,
cancellationToken
);
var
updatedNode
=
FixOne
(
result
);
if
(
updatedNode
!=
null
)
{
return
currentRoot
.
ReplaceNode
(
result
.
Invocation
,
updatedNode
);
...
...
@@ -91,7 +91,7 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context)
private
static
InvocationExpressionSyntax
GetInvocationExpression
(
Diagnostic
d
,
CancellationToken
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
expression
=
invocation
.
Expression
is
MemberAccessExpressionSyntax
memberAccess
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录