Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
d0642c9d
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,发现更多精彩内容 >>
提交
d0642c9d
编写于
6月 28, 2019
作者:
C
Cyrus Najmabadi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
use 'var'
上级
bacafc56
变更
41
显示空白变更内容
内联
并排
Showing
41 changed file
with
107 addition
and
107 deletion
+107
-107
src/Workspaces/CSharp/Portable/Classification/SyntaxClassification/NameSyntaxClassifier.cs
...assification/SyntaxClassification/NameSyntaxClassifier.cs
+1
-1
src/Workspaces/CSharp/Portable/CodeGeneration/CSharpCodeGenerationService.cs
...rp/Portable/CodeGeneration/CSharpCodeGenerationService.cs
+3
-3
src/Workspaces/CSharp/Portable/CodeGeneration/CSharpSyntaxGenerator.cs
...s/CSharp/Portable/CodeGeneration/CSharpSyntaxGenerator.cs
+6
-6
src/Workspaces/CSharp/Portable/CodeGeneration/DestructorGenerator.cs
...ces/CSharp/Portable/CodeGeneration/DestructorGenerator.cs
+1
-1
src/Workspaces/CSharp/Portable/CodeGeneration/ExpressionGenerator.cs
...ces/CSharp/Portable/CodeGeneration/ExpressionGenerator.cs
+1
-1
src/Workspaces/CSharp/Portable/CodeGeneration/ParameterGenerator.cs
...aces/CSharp/Portable/CodeGeneration/ParameterGenerator.cs
+1
-1
src/Workspaces/CSharp/Portable/Extensions/ContextQuery/SyntaxTreeExtensions.cs
.../Portable/Extensions/ContextQuery/SyntaxTreeExtensions.cs
+1
-1
src/Workspaces/CSharp/Portable/Extensions/ExpressionSyntaxExtensions.cs
.../CSharp/Portable/Extensions/ExpressionSyntaxExtensions.cs
+1
-1
src/Workspaces/CSharp/Portable/Extensions/ITypeSymbolExtensions.cs
...paces/CSharp/Portable/Extensions/ITypeSymbolExtensions.cs
+1
-1
src/Workspaces/CSharp/Portable/Extensions/SeparatedSyntaxListExtensions.cs
...harp/Portable/Extensions/SeparatedSyntaxListExtensions.cs
+1
-1
src/Workspaces/CSharp/Portable/Extensions/SyntaxNodeExtensions.cs
...spaces/CSharp/Portable/Extensions/SyntaxNodeExtensions.cs
+4
-4
src/Workspaces/CSharp/Portable/Extensions/SyntaxTokenExtensions.cs
...paces/CSharp/Portable/Extensions/SyntaxTokenExtensions.cs
+1
-1
src/Workspaces/CSharp/Portable/Extensions/SyntaxTreeExtensions.cs
...spaces/CSharp/Portable/Extensions/SyntaxTreeExtensions.cs
+3
-3
src/Workspaces/CSharp/Portable/Extensions/SyntaxTriviaListExtensions.cs
.../CSharp/Portable/Extensions/SyntaxTriviaListExtensions.cs
+1
-1
src/Workspaces/CSharp/Portable/Extensions/TypeDeclarationSyntaxExtensions.cs
...rp/Portable/Extensions/TypeDeclarationSyntaxExtensions.cs
+4
-4
src/Workspaces/CSharp/Portable/Formatting/CSharpFormattingOptions.Parsers.cs
...rp/Portable/Formatting/CSharpFormattingOptions.Parsers.cs
+2
-2
src/Workspaces/CSharp/Portable/Formatting/DefaultOperationProvider.cs
...es/CSharp/Portable/Formatting/DefaultOperationProvider.cs
+1
-1
src/Workspaces/CSharp/Portable/Formatting/Engine/Trivia/TriviaDataFactory.Analyzer.cs
...le/Formatting/Engine/Trivia/TriviaDataFactory.Analyzer.cs
+4
-4
src/Workspaces/CSharp/Portable/Formatting/Engine/Trivia/TriviaDataFactory.cs
...rp/Portable/Formatting/Engine/Trivia/TriviaDataFactory.cs
+1
-1
src/Workspaces/CSharp/Portable/Formatting/Engine/Trivia/TriviaRewriter.cs
...Sharp/Portable/Formatting/Engine/Trivia/TriviaRewriter.cs
+3
-3
src/Workspaces/CSharp/Portable/Formatting/FormattingHelpers.cs
...orkspaces/CSharp/Portable/Formatting/FormattingHelpers.cs
+3
-3
src/Workspaces/CSharp/Portable/Formatting/Rules/SuppressFormattingRule.cs
...Sharp/Portable/Formatting/Rules/SuppressFormattingRule.cs
+1
-1
src/Workspaces/CSharp/Portable/Formatting/Rules/TokenBasedFormattingRule.cs
...arp/Portable/Formatting/Rules/TokenBasedFormattingRule.cs
+1
-1
src/Workspaces/CSharp/Portable/Formatting/Rules/WrappingFormattingRule.cs
...Sharp/Portable/Formatting/Rules/WrappingFormattingRule.cs
+1
-1
src/Workspaces/CSharp/Portable/Indentation/CSharpIndentationService.Indenter.cs
...Portable/Indentation/CSharpIndentationService.Indenter.cs
+2
-2
src/Workspaces/CSharp/Portable/Indentation/CSharpIndentationService.cs
...s/CSharp/Portable/Indentation/CSharpIndentationService.cs
+1
-1
src/Workspaces/CSharp/Portable/Indentation/CSharpSmartTokenFormatter.cs
.../CSharp/Portable/Indentation/CSharpSmartTokenFormatter.cs
+1
-1
src/Workspaces/CSharp/Portable/LanguageServices/CSharpSyntaxFactsService.cs
...arp/Portable/LanguageServices/CSharpSyntaxFactsService.cs
+3
-3
src/Workspaces/CSharp/Portable/LanguageServices/CSharpSyntaxTreeFactory.PathSyntaxReference.cs
...geServices/CSharpSyntaxTreeFactory.PathSyntaxReference.cs
+2
-2
src/Workspaces/CSharp/Portable/LanguageServices/CSharpSyntaxTreeFactoryService.PositionalSyntaxReference.cs
...harpSyntaxTreeFactoryService.PositionalSyntaxReference.cs
+1
-1
src/Workspaces/CSharp/Portable/LanguageServices/CSharpSyntaxTreeFactoryService.RecoverableSyntaxTree.cs
...s/CSharpSyntaxTreeFactoryService.RecoverableSyntaxTree.cs
+1
-1
src/Workspaces/CSharp/Portable/LanguageServices/CSharpTypeInferenceService.TypeInferrer.cs
...nguageServices/CSharpTypeInferenceService.TypeInferrer.cs
+4
-4
src/Workspaces/CSharp/Portable/Rename/CSharpRenameRewriterLanguageService.cs
...rp/Portable/Rename/CSharpRenameRewriterLanguageService.cs
+12
-12
src/Workspaces/CSharp/Portable/Simplification/CSharpSimplificationService.Expander.cs
...le/Simplification/CSharpSimplificationService.Expander.cs
+4
-4
src/Workspaces/CSharp/Portable/Simplification/CSharpSimplificationService.NodesAndTokensToReduceComputer.cs
...rpSimplificationService.NodesAndTokensToReduceComputer.cs
+1
-1
src/Workspaces/CSharp/Portable/Simplification/Reducers/CSharpInferredMemberNameReducer.cs
...implification/Reducers/CSharpInferredMemberNameReducer.cs
+2
-2
src/Workspaces/CSharp/Portable/Simplification/Reducers/CSharpNameReducer.Rewriter.cs
...ble/Simplification/Reducers/CSharpNameReducer.Rewriter.cs
+11
-11
src/Workspaces/CSharp/Portable/Utilities/NameSyntaxComparer.cs
...orkspaces/CSharp/Portable/Utilities/NameSyntaxComparer.cs
+6
-6
src/Workspaces/CSharp/Portable/Utilities/SpeculationAnalyzer.cs
...rkspaces/CSharp/Portable/Utilities/SpeculationAnalyzer.cs
+6
-6
src/Workspaces/CSharp/Portable/Utilities/UsingsAndExternAliasesDirectiveComparer.cs
...able/Utilities/UsingsAndExternAliasesDirectiveComparer.cs
+1
-1
src/Workspaces/CSharp/Portable/Utilities/UsingsAndExternAliasesOrganizer.cs
...arp/Portable/Utilities/UsingsAndExternAliasesOrganizer.cs
+2
-2
未找到文件。
src/Workspaces/CSharp/Portable/Classification/SyntaxClassification/NameSyntaxClassifier.cs
浏览文件 @
d0642c9d
...
@@ -172,7 +172,7 @@ protected override bool IsParentAnAttribute(SyntaxNode node)
...
@@ -172,7 +172,7 @@ protected override bool IsParentAnAttribute(SyntaxNode node)
if
((
name
.
IsUnmanaged
||
name
.
IsNotNull
)
&&
name
.
Parent
.
IsKind
(
SyntaxKind
.
TypeConstraint
))
if
((
name
.
IsUnmanaged
||
name
.
IsNotNull
)
&&
name
.
Parent
.
IsKind
(
SyntaxKind
.
TypeConstraint
))
{
{
string
nameToCheck
=
name
.
IsUnmanaged
?
"unmanaged"
:
"notnull"
;
var
nameToCheck
=
name
.
IsUnmanaged
?
"unmanaged"
:
"notnull"
;
var
alias
=
semanticModel
.
GetAliasInfo
(
name
,
cancellationToken
);
var
alias
=
semanticModel
.
GetAliasInfo
(
name
,
cancellationToken
);
if
(
alias
==
null
||
alias
.
Name
!=
nameToCheck
)
if
(
alias
==
null
||
alias
.
Name
!=
nameToCheck
)
{
{
...
...
src/Workspaces/CSharp/Portable/CodeGeneration/CSharpCodeGenerationService.cs
浏览文件 @
d0642c9d
...
@@ -290,9 +290,9 @@ protected override TDeclarationNode AddNamespace<TDeclarationNode>(TDeclarationN
...
@@ -290,9 +290,9 @@ protected override TDeclarationNode AddNamespace<TDeclarationNode>(TDeclarationN
return
destinationMember
;
return
destinationMember
;
}
}
int
currentParamsCount
=
currentParameterList
.
Parameters
.
Count
;
var
currentParamsCount
=
currentParameterList
.
Parameters
.
Count
;
bool
seenOptional
=
currentParamsCount
>
0
&&
currentParameterList
.
Parameters
[
currentParamsCount
-
1
].
Default
!=
null
;
var
seenOptional
=
currentParamsCount
>
0
&&
currentParameterList
.
Parameters
[
currentParamsCount
-
1
].
Default
!=
null
;
bool
isFirstParam
=
currentParamsCount
==
0
;
var
isFirstParam
=
currentParamsCount
==
0
;
var
parameterNodesAndTokens
=
currentParameterList
.
Parameters
.
GetWithSeparators
().
ToList
();
var
parameterNodesAndTokens
=
currentParameterList
.
Parameters
.
GetWithSeparators
().
ToList
();
foreach
(
var
parameter
in
parameters
)
foreach
(
var
parameter
in
parameters
)
...
...
src/Workspaces/CSharp/Portable/CodeGeneration/CSharpSyntaxGenerator.cs
浏览文件 @
d0642c9d
...
@@ -179,7 +179,7 @@ internal static SyntaxToken GetArgumentModifiers(RefKind refKind)
...
@@ -179,7 +179,7 @@ internal static SyntaxToken GetArgumentModifiers(RefKind refKind)
DeclarationModifiers
modifiers
,
DeclarationModifiers
modifiers
,
IEnumerable
<
SyntaxNode
>
statements
)
IEnumerable
<
SyntaxNode
>
statements
)
{
{
bool
hasBody
=
!
modifiers
.
IsAbstract
&&
(!
modifiers
.
IsPartial
||
statements
!=
null
);
var
hasBody
=
!
modifiers
.
IsAbstract
&&
(!
modifiers
.
IsPartial
||
statements
!=
null
);
return
SyntaxFactory
.
MethodDeclaration
(
return
SyntaxFactory
.
MethodDeclaration
(
attributeLists
:
default
,
attributeLists
:
default
,
...
@@ -1187,7 +1187,7 @@ public override SyntaxNode InsertNamespaceImports(SyntaxNode declaration, int in
...
@@ -1187,7 +1187,7 @@ public override SyntaxNode InsertNamespaceImports(SyntaxNode declaration, int in
private
SyntaxNode
InsertNamespaceImportsInternal
(
SyntaxNode
declaration
,
int
index
,
IEnumerable
<
SyntaxNode
>
imports
)
private
SyntaxNode
InsertNamespaceImportsInternal
(
SyntaxNode
declaration
,
int
index
,
IEnumerable
<
SyntaxNode
>
imports
)
{
{
SyntaxList
<
UsingDirectiveSyntax
>
usingsToInsert
=
this
.
AsUsingDirectives
(
imports
);
var
usingsToInsert
=
this
.
AsUsingDirectives
(
imports
);
switch
(
declaration
.
Kind
())
switch
(
declaration
.
Kind
())
{
{
...
@@ -1604,7 +1604,7 @@ private static SyntaxTokenList AsModifierList(Accessibility accessibility, Decla
...
@@ -1604,7 +1604,7 @@ private static SyntaxTokenList AsModifierList(Accessibility accessibility, Decla
private
static
SyntaxTokenList
AsModifierList
(
Accessibility
accessibility
,
DeclarationModifiers
modifiers
)
private
static
SyntaxTokenList
AsModifierList
(
Accessibility
accessibility
,
DeclarationModifiers
modifiers
)
{
{
SyntaxTokenList
list
=
SyntaxFactory
.
TokenList
();
var
list
=
SyntaxFactory
.
TokenList
();
switch
(
accessibility
)
switch
(
accessibility
)
{
{
...
@@ -3286,7 +3286,7 @@ private SyntaxNode InsertNodesAfterInternal(SyntaxNode root, SyntaxNode declarat
...
@@ -3286,7 +3286,7 @@ private SyntaxNode InsertNodesAfterInternal(SyntaxNode root, SyntaxNode declarat
private
IEnumerable
<
SyntaxNode
>
SplitAndInsert
(
SyntaxNode
multiPartDeclaration
,
int
index
,
IEnumerable
<
SyntaxNode
>
newDeclarations
)
private
IEnumerable
<
SyntaxNode
>
SplitAndInsert
(
SyntaxNode
multiPartDeclaration
,
int
index
,
IEnumerable
<
SyntaxNode
>
newDeclarations
)
{
{
int
count
=
GetDeclarationCount
(
multiPartDeclaration
);
var
count
=
GetDeclarationCount
(
multiPartDeclaration
);
var
newNodes
=
new
List
<
SyntaxNode
>();
var
newNodes
=
new
List
<
SyntaxNode
>();
newNodes
.
Add
(
this
.
WithSubDeclarationsRemoved
(
multiPartDeclaration
,
index
,
count
-
index
).
WithTrailingTrivia
(
SyntaxFactory
.
ElasticSpace
));
newNodes
.
Add
(
this
.
WithSubDeclarationsRemoved
(
multiPartDeclaration
,
index
,
count
-
index
).
WithTrailingTrivia
(
SyntaxFactory
.
ElasticSpace
));
newNodes
.
AddRange
(
newDeclarations
);
newNodes
.
AddRange
(
newDeclarations
);
...
@@ -4143,8 +4143,8 @@ internal override SyntaxTriviaList RemoveCommentLines(SyntaxTriviaList syntaxTri
...
@@ -4143,8 +4143,8 @@ internal override SyntaxTriviaList RemoveCommentLines(SyntaxTriviaList syntaxTri
{
{
IEnumerable
<
IEnumerable
<
SyntaxTrivia
>>
splitIntoLines
(
SyntaxTriviaList
triviaList
)
IEnumerable
<
IEnumerable
<
SyntaxTrivia
>>
splitIntoLines
(
SyntaxTriviaList
triviaList
)
{
{
int
index
=
0
;
var
index
=
0
;
for
(
int
i
=
0
;
i
<
triviaList
.
Count
;
i
++)
for
(
var
i
=
0
;
i
<
triviaList
.
Count
;
i
++)
{
{
if
(
triviaList
[
i
].
IsEndOfLine
())
if
(
triviaList
[
i
].
IsEndOfLine
())
{
{
...
...
src/Workspaces/CSharp/Portable/CodeGeneration/DestructorGenerator.cs
浏览文件 @
d0642c9d
...
@@ -44,7 +44,7 @@ private static MemberDeclarationSyntax LastConstructorOrField(SyntaxList<MemberD
...
@@ -44,7 +44,7 @@ private static MemberDeclarationSyntax LastConstructorOrField(SyntaxList<MemberD
return
reusableSyntax
;
return
reusableSyntax
;
}
}
bool
hasNoBody
=
!
options
.
GenerateMethodBodies
;
var
hasNoBody
=
!
options
.
GenerateMethodBodies
;
var
declaration
=
SyntaxFactory
.
DestructorDeclaration
(
var
declaration
=
SyntaxFactory
.
DestructorDeclaration
(
attributeLists
:
AttributeGenerator
.
GenerateAttributeLists
(
destructor
.
GetAttributes
(),
options
),
attributeLists
:
AttributeGenerator
.
GenerateAttributeLists
(
destructor
.
GetAttributes
(),
options
),
...
...
src/Workspaces/CSharp/Portable/CodeGeneration/ExpressionGenerator.cs
浏览文件 @
d0642c9d
...
@@ -301,7 +301,7 @@ private static ExpressionSyntax GenerateFieldReference<T>(ITypeSymbol type, T va
...
@@ -301,7 +301,7 @@ private static ExpressionSyntax GenerateFieldReference<T>(ITypeSymbol type, T va
private
static
ExpressionSyntax
GenerateMemberAccess
(
params
string
[]
names
)
private
static
ExpressionSyntax
GenerateMemberAccess
(
params
string
[]
names
)
{
{
ExpressionSyntax
result
=
SyntaxFactory
.
IdentifierName
(
SyntaxFactory
.
Token
(
SyntaxKind
.
GlobalKeyword
));
ExpressionSyntax
result
=
SyntaxFactory
.
IdentifierName
(
SyntaxFactory
.
Token
(
SyntaxKind
.
GlobalKeyword
));
for
(
int
i
=
0
;
i
<
names
.
Length
;
i
++)
for
(
var
i
=
0
;
i
<
names
.
Length
;
i
++)
{
{
var
name
=
SyntaxFactory
.
IdentifierName
(
names
[
i
]);
var
name
=
SyntaxFactory
.
IdentifierName
(
names
[
i
]);
if
(
i
==
0
)
if
(
i
==
0
)
...
...
src/Workspaces/CSharp/Portable/CodeGeneration/ParameterGenerator.cs
浏览文件 @
d0642c9d
...
@@ -92,7 +92,7 @@ internal static ParameterSyntax GetParameter(IParameterSymbol p, CodeGenerationO
...
@@ -92,7 +92,7 @@ internal static ParameterSyntax GetParameter(IParameterSymbol p, CodeGenerationO
private
static
SyntaxTokenList
GenerateModifiers
(
private
static
SyntaxTokenList
GenerateModifiers
(
IParameterSymbol
parameter
,
bool
isFirstParam
)
IParameterSymbol
parameter
,
bool
isFirstParam
)
{
{
SyntaxTokenList
list
=
CSharpSyntaxGenerator
.
GetParameterModifiers
(
parameter
.
RefKind
);
var
list
=
CSharpSyntaxGenerator
.
GetParameterModifiers
(
parameter
.
RefKind
);
if
(
isFirstParam
&&
if
(
isFirstParam
&&
parameter
.
ContainingSymbol
is
IMethodSymbol
methodSymbol
&&
parameter
.
ContainingSymbol
is
IMethodSymbol
methodSymbol
&&
...
...
src/Workspaces/CSharp/Portable/Extensions/ContextQuery/SyntaxTreeExtensions.cs
浏览文件 @
d0642c9d
...
@@ -311,7 +311,7 @@ public static bool IsAttributeNameContext(this SyntaxTree syntaxTree, int positi
...
@@ -311,7 +311,7 @@ public static bool IsAttributeNameContext(this SyntaxTree syntaxTree, int positi
var
validModifiers
=
SyntaxKindSet
.
LocalFunctionModifiers
;
var
validModifiers
=
SyntaxKindSet
.
LocalFunctionModifiers
;
var
modifierTokens
=
syntaxTree
.
GetPrecedingModifiers
(
var
modifierTokens
=
syntaxTree
.
GetPrecedingModifiers
(
position
,
token
,
out
int
beforeModifiersPosition
);
position
,
token
,
out
var
beforeModifiersPosition
);
if
(
modifierTokens
.
IsSubsetOf
(
validModifiers
))
if
(
modifierTokens
.
IsSubsetOf
(
validModifiers
))
{
{
...
...
src/Workspaces/CSharp/Portable/Extensions/ExpressionSyntaxExtensions.cs
浏览文件 @
d0642c9d
...
@@ -2089,7 +2089,7 @@ private static bool HidingTypeParameterSymbolExists(ISymbol candidateSymbol, Lis
...
@@ -2089,7 +2089,7 @@ private static bool HidingTypeParameterSymbolExists(ISymbol candidateSymbol, Lis
{
{
foreach
(
var
enclosingTypeParameter
in
enclosingTypeParametersInsideOut
)
foreach
(
var
enclosingTypeParameter
in
enclosingTypeParametersInsideOut
)
{
{
ISymbol
newCandidateSymbol
=
candidateSymbol
;
var
newCandidateSymbol
=
candidateSymbol
;
if
(
candidateSymbol
.
IsKind
(
SymbolKind
.
ArrayType
))
if
(
candidateSymbol
.
IsKind
(
SymbolKind
.
ArrayType
))
{
{
newCandidateSymbol
=
((
IArrayTypeSymbol
)
candidateSymbol
).
ElementType
;
newCandidateSymbol
=
((
IArrayTypeSymbol
)
candidateSymbol
).
ElementType
;
...
...
src/Workspaces/CSharp/Portable/Extensions/ITypeSymbolExtensions.cs
浏览文件 @
d0642c9d
...
@@ -109,7 +109,7 @@ public static async Task<ISymbol> FindApplicableAlias(this ITypeSymbol type, int
...
@@ -109,7 +109,7 @@ public static async Task<ISymbol> FindApplicableAlias(this ITypeSymbol type, int
var
root
=
await
semanticModel
.
SyntaxTree
.
GetRootAsync
(
cancellationToken
).
ConfigureAwait
(
false
);
var
root
=
await
semanticModel
.
SyntaxTree
.
GetRootAsync
(
cancellationToken
).
ConfigureAwait
(
false
);
IEnumerable
<
UsingDirectiveSyntax
>
applicableUsings
=
GetApplicableUsings
(
position
,
root
as
CompilationUnitSyntax
);
var
applicableUsings
=
GetApplicableUsings
(
position
,
root
as
CompilationUnitSyntax
);
foreach
(
var
applicableUsing
in
applicableUsings
)
foreach
(
var
applicableUsing
in
applicableUsings
)
{
{
var
alias
=
semanticModel
.
GetOriginalSemanticModel
().
GetDeclaredSymbol
(
applicableUsing
,
cancellationToken
);
var
alias
=
semanticModel
.
GetOriginalSemanticModel
().
GetDeclaredSymbol
(
applicableUsing
,
cancellationToken
);
...
...
src/Workspaces/CSharp/Portable/Extensions/SeparatedSyntaxListExtensions.cs
浏览文件 @
d0642c9d
...
@@ -22,7 +22,7 @@ internal static class SeparatedSyntaxListExtensions
...
@@ -22,7 +22,7 @@ internal static class SeparatedSyntaxListExtensions
var
nodes
=
new
List
<
T
>(
separatedList
.
Count
);
var
nodes
=
new
List
<
T
>(
separatedList
.
Count
);
var
separators
=
new
List
<
SyntaxToken
>(
separatedList
.
SeparatorCount
);
var
separators
=
new
List
<
SyntaxToken
>(
separatedList
.
SeparatorCount
);
for
(
int
i
=
0
;
i
<
separatedList
.
Count
;
i
++)
for
(
var
i
=
0
;
i
<
separatedList
.
Count
;
i
++)
{
{
nodes
.
Add
(
separatedList
[
i
]);
nodes
.
Add
(
separatedList
[
i
]);
...
...
src/Workspaces/CSharp/Portable/Extensions/SyntaxNodeExtensions.cs
浏览文件 @
d0642c9d
...
@@ -490,13 +490,13 @@ internal static SyntaxNodeOrToken ChildThatContainsPosition(this SyntaxNode self
...
@@ -490,13 +490,13 @@ internal static SyntaxNodeOrToken ChildThatContainsPosition(this SyntaxNode self
{
{
var
childList
=
self
.
ChildNodesAndTokens
();
var
childList
=
self
.
ChildNodesAndTokens
();
int
left
=
0
;
var
left
=
0
;
int
right
=
childList
.
Count
-
1
;
var
right
=
childList
.
Count
-
1
;
while
(
left
<=
right
)
while
(
left
<=
right
)
{
{
int
middle
=
left
+
((
right
-
left
)
/
2
);
var
middle
=
left
+
((
right
-
left
)
/
2
);
SyntaxNodeOrToken
node
=
childList
[
middle
];
var
node
=
childList
[
middle
];
var
span
=
node
.
FullSpan
;
var
span
=
node
.
FullSpan
;
if
(
position
<
span
.
Start
)
if
(
position
<
span
.
Start
)
...
...
src/Workspaces/CSharp/Portable/Extensions/SyntaxTokenExtensions.cs
浏览文件 @
d0642c9d
...
@@ -124,7 +124,7 @@ public static SyntaxToken FindLastTokenOfPartialGenericName(this SyntaxToken gen
...
@@ -124,7 +124,7 @@ public static SyntaxToken FindLastTokenOfPartialGenericName(this SyntaxToken gen
var
token
=
genericIdentifier
.
GetNextToken
(
includeSkipped
:
true
);
var
token
=
genericIdentifier
.
GetNextToken
(
includeSkipped
:
true
);
Contract
.
ThrowIfFalse
(
token
.
Kind
()
==
SyntaxKind
.
LessThanToken
);
Contract
.
ThrowIfFalse
(
token
.
Kind
()
==
SyntaxKind
.
LessThanToken
);
int
stack
=
0
;
var
stack
=
0
;
do
do
{
{
...
...
src/Workspaces/CSharp/Portable/Extensions/SyntaxTreeExtensions.cs
浏览文件 @
d0642c9d
...
@@ -377,7 +377,7 @@ private static bool AtEndOfIncompleteStringOrCharLiteral(SyntaxToken token, int
...
@@ -377,7 +377,7 @@ private static bool AtEndOfIncompleteStringOrCharLiteral(SyntaxToken token, int
throw
new
ArgumentException
(
CSharpWorkspaceResources
.
Expected_string_or_char_literal
,
nameof
(
token
));
throw
new
ArgumentException
(
CSharpWorkspaceResources
.
Expected_string_or_char_literal
,
nameof
(
token
));
}
}
int
startLength
=
1
;
var
startLength
=
1
;
if
(
token
.
IsVerbatimStringLiteral
())
if
(
token
.
IsVerbatimStringLiteral
())
{
{
startLength
=
2
;
startLength
=
2
;
...
@@ -622,7 +622,7 @@ static bool IsSelectedFieldOrProperty(TextSpan textSpan, MemberDeclarationSyntax
...
@@ -622,7 +622,7 @@ static bool IsSelectedFieldOrProperty(TextSpan textSpan, MemberDeclarationSyntax
{
{
genericIdentifier
=
default
;
genericIdentifier
=
default
;
lessThanToken
=
default
;
lessThanToken
=
default
;
int
index
=
0
;
var
index
=
0
;
var
token
=
syntaxTree
.
FindTokenOnLeftOfPosition
(
position
,
cancellationToken
);
var
token
=
syntaxTree
.
FindTokenOnLeftOfPosition
(
position
,
cancellationToken
);
if
(
token
.
Kind
()
==
SyntaxKind
.
None
)
if
(
token
.
Kind
()
==
SyntaxKind
.
None
)
...
@@ -636,7 +636,7 @@ static bool IsSelectedFieldOrProperty(TextSpan textSpan, MemberDeclarationSyntax
...
@@ -636,7 +636,7 @@ static bool IsSelectedFieldOrProperty(TextSpan textSpan, MemberDeclarationSyntax
return
false
;
return
false
;
}
}
int
stack
=
0
;
var
stack
=
0
;
while
(
true
)
while
(
true
)
{
{
switch
(
token
.
Kind
())
switch
(
token
.
Kind
())
...
...
src/Workspaces/CSharp/Portable/Extensions/SyntaxTriviaListExtensions.cs
浏览文件 @
d0642c9d
...
@@ -59,7 +59,7 @@ private static ImmutableArray<ImmutableArray<SyntaxTrivia>> GetLeadingBlankLines
...
@@ -59,7 +59,7 @@ private static ImmutableArray<ImmutableArray<SyntaxTrivia>> GetLeadingBlankLines
currentLine
.
Add
(
trivia
);
currentLine
.
Add
(
trivia
);
if
(
trivia
.
Kind
()
==
SyntaxKind
.
EndOfLineTrivia
)
if
(
trivia
.
Kind
()
==
SyntaxKind
.
EndOfLineTrivia
)
{
{
bool
currentLineIsBlank
=
currentLine
.
All
(
t
=>
var
currentLineIsBlank
=
currentLine
.
All
(
t
=>
t
.
Kind
()
==
SyntaxKind
.
EndOfLineTrivia
||
t
.
Kind
()
==
SyntaxKind
.
EndOfLineTrivia
||
t
.
Kind
()
==
SyntaxKind
.
WhitespaceTrivia
);
t
.
Kind
()
==
SyntaxKind
.
WhitespaceTrivia
);
if
(!
currentLineIsBlank
)
if
(!
currentLineIsBlank
)
...
...
src/Workspaces/CSharp/Portable/Extensions/TypeDeclarationSyntaxExtensions.cs
浏览文件 @
d0642c9d
...
@@ -33,7 +33,7 @@ public static IList<bool> GetInsertionIndices(this TypeDeclarationSyntax destina
...
@@ -33,7 +33,7 @@ public static IList<bool> GetInsertionIndices(this TypeDeclarationSyntax destina
var
end
=
destination
.
Members
.
First
().
SpanStart
;
var
end
=
destination
.
Members
.
First
().
SpanStart
;
indices
.
Add
(!
destination
.
OverlapsHiddenPosition
(
TextSpan
.
FromBounds
(
start
,
end
),
cancellationToken
));
indices
.
Add
(!
destination
.
OverlapsHiddenPosition
(
TextSpan
.
FromBounds
(
start
,
end
),
cancellationToken
));
for
(
int
i
=
0
;
i
<
members
.
Count
-
1
;
i
++)
for
(
var
i
=
0
;
i
<
members
.
Count
-
1
;
i
++)
{
{
var
member1
=
members
[
i
];
var
member1
=
members
[
i
];
var
member2
=
members
[
i
+
1
];
var
member2
=
members
[
i
+
1
];
...
@@ -69,7 +69,7 @@ public static IEnumerable<BaseTypeSyntax> GetAllBaseListTypes(this TypeDeclarati
...
@@ -69,7 +69,7 @@ public static IEnumerable<BaseTypeSyntax> GetAllBaseListTypes(this TypeDeclarati
{
{
Contract
.
ThrowIfNull
(
typeNode
);
Contract
.
ThrowIfNull
(
typeNode
);
IEnumerable
<
BaseTypeSyntax
>
baseListTypes
=
SpecializedCollections
.
EmptyEnumerable
<
BaseTypeSyntax
>();
var
baseListTypes
=
SpecializedCollections
.
EmptyEnumerable
<
BaseTypeSyntax
>();
var
isPartialType
=
typeNode
.
Modifiers
.
Any
(
m
=>
m
.
Kind
()
==
SyntaxKind
.
PartialKeyword
);
var
isPartialType
=
typeNode
.
Modifiers
.
Any
(
m
=>
m
.
Kind
()
==
SyntaxKind
.
PartialKeyword
);
if
(
isPartialType
)
if
(
isPartialType
)
...
@@ -119,9 +119,9 @@ private static SyntaxToken EnsureToken(SyntaxToken token, bool prependNewLineIfM
...
@@ -119,9 +119,9 @@ private static SyntaxToken EnsureToken(SyntaxToken token, bool prependNewLineIfM
{
{
// Bug 539673: If there are no members, take any trivia that
// Bug 539673: If there are no members, take any trivia that
// belongs to the end brace and attach it to the opening brace.
// belongs to the end brace and attach it to the opening brace.
int
index
=
-
1
;
var
index
=
-
1
;
var
leadingTrivia
=
closeBrace
.
LeadingTrivia
;
var
leadingTrivia
=
closeBrace
.
LeadingTrivia
;
for
(
int
i
=
leadingTrivia
.
Count
-
1
;
i
>=
0
;
i
--)
for
(
var
i
=
leadingTrivia
.
Count
-
1
;
i
>=
0
;
i
--)
{
{
if
(!
leadingTrivia
[
i
].
IsWhitespaceOrEndOfLine
())
if
(!
leadingTrivia
[
i
].
IsWhitespaceOrEndOfLine
())
{
{
...
...
src/Workspaces/CSharp/Portable/Formatting/CSharpFormattingOptions.Parsers.cs
浏览文件 @
d0642c9d
...
@@ -50,13 +50,13 @@ internal static BinaryOperatorSpacingOptions ParseEditorConfigSpacingAroundBinar
...
@@ -50,13 +50,13 @@ internal static BinaryOperatorSpacingOptions ParseEditorConfigSpacingAroundBinar
=>
s_binaryOperatorSpacingOptionsEditorConfigMap
.
TryGetValue
(
binaryOperatorSpacingValue
.
Trim
(),
out
var
value
)
?
value
:
BinaryOperatorSpacingOptions
.
Single
;
=>
s_binaryOperatorSpacingOptionsEditorConfigMap
.
TryGetValue
(
binaryOperatorSpacingValue
.
Trim
(),
out
var
value
)
?
value
:
BinaryOperatorSpacingOptions
.
Single
;
private
static
string
GetSpacingAroundBinaryOperatorEditorConfigString
(
BinaryOperatorSpacingOptions
value
)
private
static
string
GetSpacingAroundBinaryOperatorEditorConfigString
(
BinaryOperatorSpacingOptions
value
)
=>
s_binaryOperatorSpacingOptionsEditorConfigMap
.
TryGetKey
(
value
,
out
string
key
)
?
key
:
null
;
=>
s_binaryOperatorSpacingOptionsEditorConfigMap
.
TryGetKey
(
value
,
out
var
key
)
?
key
:
null
;
internal
static
LabelPositionOptions
ParseEditorConfigLabelPositioning
(
string
labelIndentationValue
)
internal
static
LabelPositionOptions
ParseEditorConfigLabelPositioning
(
string
labelIndentationValue
)
=>
s_labelPositionOptionsEditorConfigMap
.
TryGetValue
(
labelIndentationValue
.
Trim
(),
out
var
value
)
?
value
:
LabelPositionOptions
.
NoIndent
;
=>
s_labelPositionOptionsEditorConfigMap
.
TryGetValue
(
labelIndentationValue
.
Trim
(),
out
var
value
)
?
value
:
LabelPositionOptions
.
NoIndent
;
private
static
string
GetLabelPositionOptionEditorConfigString
(
LabelPositionOptions
value
)
private
static
string
GetLabelPositionOptionEditorConfigString
(
LabelPositionOptions
value
)
=>
s_labelPositionOptionsEditorConfigMap
.
TryGetKey
(
value
,
out
string
key
)
?
key
:
null
;
=>
s_labelPositionOptionsEditorConfigMap
.
TryGetKey
(
value
,
out
var
key
)
?
key
:
null
;
internal
static
bool
DetermineIfNewLineOptionIsSet
(
string
value
,
NewLineOption
optionName
)
internal
static
bool
DetermineIfNewLineOptionIsSet
(
string
value
,
NewLineOption
optionName
)
{
{
...
...
src/Workspaces/CSharp/Portable/Formatting/DefaultOperationProvider.cs
浏览文件 @
d0642c9d
...
@@ -45,7 +45,7 @@ public override AdjustNewLinesOperation GetAdjustNewLinesOperation(SyntaxToken p
...
@@ -45,7 +45,7 @@ public override AdjustNewLinesOperation GetAdjustNewLinesOperation(SyntaxToken p
// return 1 space for every token pairs as a default operation
// return 1 space for every token pairs as a default operation
public
override
AdjustSpacesOperation
GetAdjustSpacesOperation
(
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
OptionSet
optionSet
,
in
NextGetAdjustSpacesOperation
nextOperation
)
public
override
AdjustSpacesOperation
GetAdjustSpacesOperation
(
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
OptionSet
optionSet
,
in
NextGetAdjustSpacesOperation
nextOperation
)
{
{
int
space
=
currentToken
.
Kind
()
==
SyntaxKind
.
EndOfFileToken
?
0
:
1
;
var
space
=
currentToken
.
Kind
()
==
SyntaxKind
.
EndOfFileToken
?
0
:
1
;
return
FormattingOperations
.
CreateAdjustSpacesOperation
(
space
,
AdjustSpacesOption
.
DefaultSpacesIfOnSingleLine
);
return
FormattingOperations
.
CreateAdjustSpacesOperation
(
space
,
AdjustSpacesOption
.
DefaultSpacesIfOnSingleLine
);
}
}
}
}
...
...
src/Workspaces/CSharp/Portable/Formatting/Engine/Trivia/TriviaDataFactory.Analyzer.cs
浏览文件 @
d0642c9d
...
@@ -160,12 +160,12 @@ private static void AnalyzeWhitespacesInTrivia(SyntaxTrivia trivia, ref Analysis
...
@@ -160,12 +160,12 @@ private static void AnalyzeWhitespacesInTrivia(SyntaxTrivia trivia, ref Analysis
Debug
.
Assert
(
trivia
.
Kind
()
==
SyntaxKind
.
WhitespaceTrivia
);
Debug
.
Assert
(
trivia
.
Kind
()
==
SyntaxKind
.
WhitespaceTrivia
);
Debug
.
Assert
(
trivia
.
Width
()
==
trivia
.
FullWidth
());
Debug
.
Assert
(
trivia
.
Width
()
==
trivia
.
FullWidth
());
int
space
=
0
;
var
space
=
0
;
int
tab
=
0
;
var
tab
=
0
;
int
unknownWhitespace
=
0
;
var
unknownWhitespace
=
0
;
var
text
=
trivia
.
ToString
();
var
text
=
trivia
.
ToString
();
for
(
int
i
=
0
;
i
<
trivia
.
Width
();
i
++)
for
(
var
i
=
0
;
i
<
trivia
.
Width
();
i
++)
{
{
if
(
text
[
i
]
==
' '
)
if
(
text
[
i
]
==
' '
)
{
{
...
...
src/Workspaces/CSharp/Portable/Formatting/Engine/Trivia/TriviaDataFactory.cs
浏览文件 @
d0642c9d
...
@@ -110,7 +110,7 @@ private TriviaData GetWhitespaceOnlyTriviaInfo(SyntaxToken token1, SyntaxToken t
...
@@ -110,7 +110,7 @@ private TriviaData GetWhitespaceOnlyTriviaInfo(SyntaxToken token1, SyntaxToken t
}
}
// only whitespace in between
// only whitespace in between
int
space
=
GetSpaceOnSingleLine
(
result
);
var
space
=
GetSpaceOnSingleLine
(
result
);
Contract
.
ThrowIfFalse
(
space
>=
-
1
);
Contract
.
ThrowIfFalse
(
space
>=
-
1
);
if
(
space
>=
0
)
if
(
space
>=
0
)
...
...
src/Workspaces/CSharp/Portable/Formatting/Engine/Trivia/TriviaRewriter.cs
浏览文件 @
d0642c9d
...
@@ -97,7 +97,7 @@ public SyntaxNode Transform()
...
@@ -97,7 +97,7 @@ public SyntaxNode Transform()
var
text
=
pair
.
Value
.
GetTextChanges
(
GetTextSpan
(
pair
.
Key
)).
Single
().
NewText
;
var
text
=
pair
.
Value
.
GetTextChanges
(
GetTextSpan
(
pair
.
Key
)).
Single
().
NewText
;
var
trailingTrivia
=
SyntaxFactory
.
ParseTrailingTrivia
(
text
);
var
trailingTrivia
=
SyntaxFactory
.
ParseTrailingTrivia
(
text
);
int
width
=
trailingTrivia
.
GetFullWidth
();
var
width
=
trailingTrivia
.
GetFullWidth
();
var
leadingTrivia
=
SyntaxFactory
.
ParseLeadingTrivia
(
text
.
Substring
(
width
));
var
leadingTrivia
=
SyntaxFactory
.
ParseLeadingTrivia
(
text
.
Substring
(
width
));
return
ValueTuple
.
Create
(
trailingTrivia
,
leadingTrivia
);
return
ValueTuple
.
Create
(
trailingTrivia
,
leadingTrivia
);
...
@@ -125,7 +125,7 @@ private IEnumerable<SyntaxTrivia> CreateTriviaListFromTo(List<SyntaxTrivia> triv
...
@@ -125,7 +125,7 @@ private IEnumerable<SyntaxTrivia> CreateTriviaListFromTo(List<SyntaxTrivia> triv
yield
break
;
yield
break
;
}
}
for
(
int
i
=
startIndex
;
i
<=
endIndex
;
i
++)
for
(
var
i
=
startIndex
;
i
<=
endIndex
;
i
++)
{
{
yield
return
triviaList
[
i
];
yield
return
triviaList
[
i
];
}
}
...
@@ -133,7 +133,7 @@ private IEnumerable<SyntaxTrivia> CreateTriviaListFromTo(List<SyntaxTrivia> triv
...
@@ -133,7 +133,7 @@ private IEnumerable<SyntaxTrivia> CreateTriviaListFromTo(List<SyntaxTrivia> triv
private
int
GetFirstEndOfLineIndexOrRightBeforeComment
(
List
<
SyntaxTrivia
>
triviaList
)
private
int
GetFirstEndOfLineIndexOrRightBeforeComment
(
List
<
SyntaxTrivia
>
triviaList
)
{
{
for
(
int
i
=
0
;
i
<
triviaList
.
Count
;
i
++)
for
(
var
i
=
0
;
i
<
triviaList
.
Count
;
i
++)
{
{
var
trivia
=
triviaList
[
i
];
var
trivia
=
triviaList
[
i
];
...
...
src/Workspaces/CSharp/Portable/Formatting/FormattingHelpers.cs
浏览文件 @
d0642c9d
...
@@ -21,10 +21,10 @@ public static string GetIndent(this SyntaxToken token)
...
@@ -21,10 +21,10 @@ public static string GetIndent(this SyntaxToken token)
// indent is the spaces/tabs between last new line (if there is one) and end of trivia
// indent is the spaces/tabs between last new line (if there is one) and end of trivia
var
indent
=
precedingTrivia
.
AsString
();
var
indent
=
precedingTrivia
.
AsString
();
int
lastNewLinePos
=
indent
.
LastIndexOf
(
NewLine
,
StringComparison
.
Ordinal
);
var
lastNewLinePos
=
indent
.
LastIndexOf
(
NewLine
,
StringComparison
.
Ordinal
);
if
(
lastNewLinePos
!=
-
1
)
if
(
lastNewLinePos
!=
-
1
)
{
{
int
start
=
lastNewLinePos
+
NewLine
.
Length
;
var
start
=
lastNewLinePos
+
NewLine
.
Length
;
indent
=
indent
.
Substring
(
start
,
indent
.
Length
-
start
);
indent
=
indent
.
Substring
(
start
,
indent
.
Length
-
start
);
}
}
...
@@ -34,7 +34,7 @@ public static string GetIndent(this SyntaxToken token)
...
@@ -34,7 +34,7 @@ public static string GetIndent(this SyntaxToken token)
public
static
string
ContentBeforeLastNewLine
(
this
IEnumerable
<
SyntaxTrivia
>
trivia
)
public
static
string
ContentBeforeLastNewLine
(
this
IEnumerable
<
SyntaxTrivia
>
trivia
)
{
{
var
leading
=
trivia
.
AsString
();
var
leading
=
trivia
.
AsString
();
int
lastNewLinePos
=
leading
.
LastIndexOf
(
NewLine
,
StringComparison
.
Ordinal
);
var
lastNewLinePos
=
leading
.
LastIndexOf
(
NewLine
,
StringComparison
.
Ordinal
);
if
(
lastNewLinePos
==
-
1
)
if
(
lastNewLinePos
==
-
1
)
{
{
return
string
.
Empty
;
return
string
.
Empty
;
...
...
src/Workspaces/CSharp/Portable/Formatting/Rules/SuppressFormattingRule.cs
浏览文件 @
d0642c9d
...
@@ -203,7 +203,7 @@ private void AddSpecificNodesSuppressOperations(List<SuppressOperation> list, Sy
...
@@ -203,7 +203,7 @@ private void AddSpecificNodesSuppressOperations(List<SuppressOperation> list, Sy
else
else
{
{
// Add Separate suppression for each Label and for the last label, add the <>
// Add Separate suppression for each Label and for the last label, add the <>
for
(
int
i
=
0
;
i
<
switchSection
.
Labels
.
Count
-
1
;
++
i
)
for
(
var
i
=
0
;
i
<
switchSection
.
Labels
.
Count
-
1
;
++
i
)
{
{
if
(
switchSection
.
Labels
[
i
]
!=
null
)
if
(
switchSection
.
Labels
[
i
]
!=
null
)
{
{
...
...
src/Workspaces/CSharp/Portable/Formatting/Rules/TokenBasedFormattingRule.cs
浏览文件 @
d0642c9d
...
@@ -400,7 +400,7 @@ public override AdjustSpacesOperation GetAdjustSpacesOperation(SyntaxToken previ
...
@@ -400,7 +400,7 @@ public override AdjustSpacesOperation GetAdjustSpacesOperation(SyntaxToken previ
case
SyntaxKind
.
CloseParenToken
:
case
SyntaxKind
.
CloseParenToken
:
case
SyntaxKind
.
CloseBracketToken
:
case
SyntaxKind
.
CloseBracketToken
:
int
space
=
(
previousToken
.
Kind
()
==
currentToken
.
Kind
())
?
0
:
1
;
var
space
=
(
previousToken
.
Kind
()
==
currentToken
.
Kind
())
?
0
:
1
;
return
CreateAdjustSpacesOperation
(
space
,
AdjustSpacesOption
.
ForceSpacesIfOnSingleLine
);
return
CreateAdjustSpacesOperation
(
space
,
AdjustSpacesOption
.
ForceSpacesIfOnSingleLine
);
}
}
...
...
src/Workspaces/CSharp/Portable/Formatting/Rules/WrappingFormattingRule.cs
浏览文件 @
d0642c9d
...
@@ -164,7 +164,7 @@ private void RemoveSuppressOperationForBlock(List<SuppressOperation> list, Synta
...
@@ -164,7 +164,7 @@ private void RemoveSuppressOperationForBlock(List<SuppressOperation> list, Synta
var
span
=
TextSpan
.
FromBounds
(
startToken
.
SpanStart
,
endToken
.
Span
.
End
);
var
span
=
TextSpan
.
FromBounds
(
startToken
.
SpanStart
,
endToken
.
Span
.
End
);
for
(
int
i
=
0
;
i
<
list
.
Count
;
i
++)
for
(
var
i
=
0
;
i
<
list
.
Count
;
i
++)
{
{
if
(
list
[
i
]
!=
null
&&
list
[
i
].
TextSpan
.
Start
>=
span
.
Start
&&
list
[
i
].
TextSpan
.
End
<=
span
.
End
&&
list
[
i
].
Option
.
HasFlag
(
SuppressOption
.
NoWrappingIfOnSingleLine
))
if
(
list
[
i
]
!=
null
&&
list
[
i
].
TextSpan
.
Start
>=
span
.
Start
&&
list
[
i
].
TextSpan
.
End
<=
span
.
End
&&
list
[
i
].
Option
.
HasFlag
(
SuppressOption
.
NoWrappingIfOnSingleLine
))
{
{
...
...
src/Workspaces/CSharp/Portable/Indentation/CSharpIndentationService.Indenter.cs
浏览文件 @
d0642c9d
...
@@ -296,7 +296,7 @@ private IndentationResult GetIndentationFromCommaSeparatedList(SyntaxToken token
...
@@ -296,7 +296,7 @@ private IndentationResult GetIndentationFromCommaSeparatedList(SyntaxToken token
// find node that starts at the beginning of a line
// find node that starts at the beginning of a line
var
sourceText
=
LineToBeIndented
.
Text
;
var
sourceText
=
LineToBeIndented
.
Text
;
for
(
int
i
=
(
index
-
1
)
/
2
;
i
>=
0
;
i
--)
for
(
var
i
=
(
index
-
1
)
/
2
;
i
>=
0
;
i
--)
{
{
var
node
=
list
[
i
];
var
node
=
list
[
i
];
var
firstToken
=
node
.
GetFirstToken
(
includeZeroWidth
:
true
);
var
firstToken
=
node
.
GetFirstToken
(
includeZeroWidth
:
true
);
...
@@ -361,7 +361,7 @@ private IndentationResult GetIndentationForQueryExpression(SyntaxToken token)
...
@@ -361,7 +361,7 @@ private IndentationResult GetIndentationForQueryExpression(SyntaxToken token)
// find preceding clause that starts on its own.
// find preceding clause that starts on its own.
var
clauses
=
queryBody
.
Clauses
;
var
clauses
=
queryBody
.
Clauses
;
for
(
int
i
=
clauses
.
Count
-
1
;
i
>=
0
;
i
--)
for
(
var
i
=
clauses
.
Count
-
1
;
i
>=
0
;
i
--)
{
{
var
clause
=
clauses
[
i
];
var
clause
=
clauses
[
i
];
if
(
firstToken
.
SpanStart
<=
clause
.
SpanStart
)
if
(
firstToken
.
SpanStart
<=
clause
.
SpanStart
)
...
...
src/Workspaces/CSharp/Portable/Indentation/CSharpIndentationService.cs
浏览文件 @
d0642c9d
...
@@ -172,7 +172,7 @@ private void ReplaceCaseIndentationRules(List<IndentBlockOperation> list, Syntax
...
@@ -172,7 +172,7 @@ private void ReplaceCaseIndentationRules(List<IndentBlockOperation> list, Syntax
var
startToken
=
section
.
Statements
.
First
().
GetFirstToken
(
includeZeroWidth
:
true
);
var
startToken
=
section
.
Statements
.
First
().
GetFirstToken
(
includeZeroWidth
:
true
);
var
endToken
=
section
.
Statements
.
Last
().
GetLastToken
(
includeZeroWidth
:
true
);
var
endToken
=
section
.
Statements
.
Last
().
GetLastToken
(
includeZeroWidth
:
true
);
for
(
int
i
=
0
;
i
<
list
.
Count
;
i
++)
for
(
var
i
=
0
;
i
<
list
.
Count
;
i
++)
{
{
var
operation
=
list
[
i
];
var
operation
=
list
[
i
];
if
(
operation
.
StartToken
==
startToken
&&
operation
.
EndToken
==
endToken
)
if
(
operation
.
StartToken
==
startToken
&&
operation
.
EndToken
==
endToken
)
...
...
src/Workspaces/CSharp/Portable/Indentation/CSharpSmartTokenFormatter.cs
浏览文件 @
d0642c9d
...
@@ -84,7 +84,7 @@ private bool CloseBraceOfTryOrDoBlock(SyntaxToken endToken)
...
@@ -84,7 +84,7 @@ private bool CloseBraceOfTryOrDoBlock(SyntaxToken endToken)
// Formatter uses FindToken on the position, which returns token to left, if there is nothing to the right and returns token to the right
// Formatter uses FindToken on the position, which returns token to left, if there is nothing to the right and returns token to the right
// if there exists one. If the shape is "{|}", we're including '}' in the formatting range. Avoid doing that to improve verbatim typing
// if there exists one. If the shape is "{|}", we're including '}' in the formatting range. Avoid doing that to improve verbatim typing
// in the following special scenarios.
// in the following special scenarios.
int
adjustedEndPosition
=
token
.
Span
.
End
;
var
adjustedEndPosition
=
token
.
Span
.
End
;
if
(
token
.
IsKind
(
SyntaxKind
.
OpenBraceToken
)
&&
if
(
token
.
IsKind
(
SyntaxKind
.
OpenBraceToken
)
&&
(
token
.
Parent
.
IsInitializerForArrayOrCollectionCreationExpression
()
||
(
token
.
Parent
.
IsInitializerForArrayOrCollectionCreationExpression
()
||
token
.
Parent
is
AnonymousObjectCreationExpressionSyntax
))
token
.
Parent
is
AnonymousObjectCreationExpressionSyntax
))
...
...
src/Workspaces/CSharp/Portable/LanguageServices/CSharpSyntaxFactsService.cs
浏览文件 @
d0642c9d
...
@@ -1028,7 +1028,7 @@ private static void AppendTypeParameterList(StringBuilder builder, TypeParameter
...
@@ -1028,7 +1028,7 @@ private static void AppendTypeParameterList(StringBuilder builder, TypeParameter
{
{
builder
.
Append
(
'<'
);
builder
.
Append
(
'<'
);
builder
.
Append
(
typeParameterList
.
Parameters
[
0
].
Identifier
.
ValueText
);
builder
.
Append
(
typeParameterList
.
Parameters
[
0
].
Identifier
.
ValueText
);
for
(
int
i
=
1
;
i
<
typeParameterList
.
Parameters
.
Count
;
i
++)
for
(
var
i
=
1
;
i
<
typeParameterList
.
Parameters
.
Count
;
i
++)
{
{
builder
.
Append
(
", "
);
builder
.
Append
(
", "
);
builder
.
Append
(
typeParameterList
.
Parameters
[
i
].
Identifier
.
ValueText
);
builder
.
Append
(
typeParameterList
.
Parameters
[
i
].
Identifier
.
ValueText
);
...
@@ -1123,7 +1123,7 @@ public int GetMethodLevelMemberId(SyntaxNode root, SyntaxNode node)
...
@@ -1123,7 +1123,7 @@ public int GetMethodLevelMemberId(SyntaxNode root, SyntaxNode node)
{
{
Debug
.
Assert
(
root
.
SyntaxTree
==
node
.
SyntaxTree
);
Debug
.
Assert
(
root
.
SyntaxTree
==
node
.
SyntaxTree
);
int
currentId
=
0
;
var
currentId
=
0
;
Contract
.
ThrowIfFalse
(
TryGetMethodLevelMember
(
root
,
(
n
,
i
)
=>
n
==
node
,
ref
currentId
,
out
var
currentNode
));
Contract
.
ThrowIfFalse
(
TryGetMethodLevelMember
(
root
,
(
n
,
i
)
=>
n
==
node
,
ref
currentId
,
out
var
currentNode
));
Contract
.
ThrowIfFalse
(
currentId
>=
0
);
Contract
.
ThrowIfFalse
(
currentId
>=
0
);
...
@@ -1133,7 +1133,7 @@ public int GetMethodLevelMemberId(SyntaxNode root, SyntaxNode node)
...
@@ -1133,7 +1133,7 @@ public int GetMethodLevelMemberId(SyntaxNode root, SyntaxNode node)
public
SyntaxNode
GetMethodLevelMember
(
SyntaxNode
root
,
int
memberId
)
public
SyntaxNode
GetMethodLevelMember
(
SyntaxNode
root
,
int
memberId
)
{
{
int
currentId
=
0
;
var
currentId
=
0
;
if
(!
TryGetMethodLevelMember
(
root
,
(
n
,
i
)
=>
i
==
memberId
,
ref
currentId
,
out
var
currentNode
))
if
(!
TryGetMethodLevelMember
(
root
,
(
n
,
i
)
=>
i
==
memberId
,
ref
currentId
,
out
var
currentNode
))
{
{
return
null
;
return
null
;
...
...
src/Workspaces/CSharp/Portable/LanguageServices/CSharpSyntaxTreeFactory.PathSyntaxReference.cs
浏览文件 @
d0642c9d
...
@@ -86,7 +86,7 @@ private ImmutableArray<int> ComputePathFromRoot(SyntaxNode node)
...
@@ -86,7 +86,7 @@ private ImmutableArray<int> ComputePathFromRoot(SyntaxNode node)
private
int
GetChildIndex
(
SyntaxNodeOrToken
child
)
private
int
GetChildIndex
(
SyntaxNodeOrToken
child
)
{
{
var
parent
=
child
.
Parent
;
var
parent
=
child
.
Parent
;
int
index
=
0
;
var
index
=
0
;
foreach
(
var
nodeOrToken
in
parent
.
ChildNodesAndTokens
())
foreach
(
var
nodeOrToken
in
parent
.
ChildNodesAndTokens
())
{
{
...
@@ -104,7 +104,7 @@ private int GetChildIndex(SyntaxNodeOrToken child)
...
@@ -104,7 +104,7 @@ private int GetChildIndex(SyntaxNodeOrToken child)
private
int
GetTriviaIndex
(
SyntaxTrivia
trivia
)
private
int
GetTriviaIndex
(
SyntaxTrivia
trivia
)
{
{
var
token
=
trivia
.
Token
;
var
token
=
trivia
.
Token
;
int
index
=
0
;
var
index
=
0
;
foreach
(
var
tr
in
token
.
LeadingTrivia
)
foreach
(
var
tr
in
token
.
LeadingTrivia
)
{
{
...
...
src/Workspaces/CSharp/Portable/LanguageServices/CSharpSyntaxTreeFactoryService.PositionalSyntaxReference.cs
浏览文件 @
d0642c9d
...
@@ -65,7 +65,7 @@ public async override Task<SyntaxNode> GetSyntaxAsync(CancellationToken cancella
...
@@ -65,7 +65,7 @@ public async override Task<SyntaxNode> GetSyntaxAsync(CancellationToken cancella
private
SyntaxNode
GetNode
(
SyntaxNode
root
)
private
SyntaxNode
GetNode
(
SyntaxNode
root
)
{
{
var
current
=
root
;
var
current
=
root
;
int
spanStart
=
_textSpan
.
Start
;
var
spanStart
=
_textSpan
.
Start
;
while
(
current
.
FullSpan
.
Contains
(
spanStart
))
while
(
current
.
FullSpan
.
Contains
(
spanStart
))
{
{
...
...
src/Workspaces/CSharp/Portable/LanguageServices/CSharpSyntaxTreeFactoryService.RecoverableSyntaxTree.cs
浏览文件 @
d0642c9d
...
@@ -117,7 +117,7 @@ private CompilationUnitSyntax CacheRootNode(CompilationUnitSyntax node)
...
@@ -117,7 +117,7 @@ private CompilationUnitSyntax CacheRootNode(CompilationUnitSyntax node)
public
override
bool
TryGetRoot
(
out
CSharpSyntaxNode
root
)
public
override
bool
TryGetRoot
(
out
CSharpSyntaxNode
root
)
{
{
bool
status
=
_recoverableRoot
.
TryGetValue
(
out
var
node
);
var
status
=
_recoverableRoot
.
TryGetValue
(
out
var
node
);
root
=
node
;
root
=
node
;
CacheRootNode
(
node
);
CacheRootNode
(
node
);
return
status
;
return
status
;
...
...
src/Workspaces/CSharp/Portable/LanguageServices/CSharpTypeInferenceService.TypeInferrer.cs
浏览文件 @
d0642c9d
...
@@ -1345,7 +1345,7 @@ private IEnumerable<TypeInferenceInfo> InferTypeInImplicitArrayCreation(Implicit
...
@@ -1345,7 +1345,7 @@ private IEnumerable<TypeInferenceInfo> InferTypeInImplicitArrayCreation(Implicit
{
{
// = { Goo() }
// = { Goo() }
var
equalsValueClause
=
(
EqualsValueClauseSyntax
)
initializerExpression
.
Parent
;
var
equalsValueClause
=
(
EqualsValueClauseSyntax
)
initializerExpression
.
Parent
;
IEnumerable
<
ITypeSymbol
>
types
=
InferTypeInEqualsValueClause
(
equalsValueClause
).
Select
(
t
=>
t
.
InferredType
);
var
types
=
InferTypeInEqualsValueClause
(
equalsValueClause
).
Select
(
t
=>
t
.
InferredType
);
if
(
types
.
Any
(
t
=>
t
is
IArrayTypeSymbol
))
if
(
types
.
Any
(
t
=>
t
is
IArrayTypeSymbol
))
{
{
...
@@ -1356,7 +1356,7 @@ private IEnumerable<TypeInferenceInfo> InferTypeInImplicitArrayCreation(Implicit
...
@@ -1356,7 +1356,7 @@ private IEnumerable<TypeInferenceInfo> InferTypeInImplicitArrayCreation(Implicit
{
{
// new int[] { Goo() }
// new int[] { Goo() }
var
arrayCreation
=
(
ArrayCreationExpressionSyntax
)
initializerExpression
.
Parent
;
var
arrayCreation
=
(
ArrayCreationExpressionSyntax
)
initializerExpression
.
Parent
;
IEnumerable
<
ITypeSymbol
>
types
=
GetTypes
(
arrayCreation
).
Select
(
t
=>
t
.
InferredType
);
var
types
=
GetTypes
(
arrayCreation
).
Select
(
t
=>
t
.
InferredType
);
if
(
types
.
Any
(
t
=>
t
is
IArrayTypeSymbol
))
if
(
types
.
Any
(
t
=>
t
is
IArrayTypeSymbol
))
{
{
...
@@ -1369,7 +1369,7 @@ private IEnumerable<TypeInferenceInfo> InferTypeInImplicitArrayCreation(Implicit
...
@@ -1369,7 +1369,7 @@ private IEnumerable<TypeInferenceInfo> InferTypeInImplicitArrayCreation(Implicit
var
objectCreation
=
(
ObjectCreationExpressionSyntax
)
initializerExpression
.
Parent
;
var
objectCreation
=
(
ObjectCreationExpressionSyntax
)
initializerExpression
.
Parent
;
IEnumerable
<
ITypeSymbol
>
types
=
GetTypes
(
objectCreation
).
Select
(
t
=>
t
.
InferredType
);
var
types
=
GetTypes
(
objectCreation
).
Select
(
t
=>
t
.
InferredType
);
if
(
types
.
Any
(
t
=>
t
is
INamedTypeSymbol
))
if
(
types
.
Any
(
t
=>
t
is
INamedTypeSymbol
))
{
{
return
types
.
OfType
<
INamedTypeSymbol
>().
SelectMany
(
t
=>
return
types
.
OfType
<
INamedTypeSymbol
>().
SelectMany
(
t
=>
...
@@ -1391,7 +1391,7 @@ private IEnumerable<TypeInferenceInfo> InferTypeInImplicitArrayCreation(Implicit
...
@@ -1391,7 +1391,7 @@ private IEnumerable<TypeInferenceInfo> InferTypeInImplicitArrayCreation(Implicit
}
}
var
assignExpression
=
(
AssignmentExpressionSyntax
)
initializerExpression
.
Parent
;
var
assignExpression
=
(
AssignmentExpressionSyntax
)
initializerExpression
.
Parent
;
IEnumerable
<
ITypeSymbol
>
types
=
GetTypes
(
assignExpression
.
Left
).
Select
(
t
=>
t
.
InferredType
);
var
types
=
GetTypes
(
assignExpression
.
Left
).
Select
(
t
=>
t
.
InferredType
);
if
(
types
.
Any
(
t
=>
t
is
INamedTypeSymbol
))
if
(
types
.
Any
(
t
=>
t
is
INamedTypeSymbol
))
{
{
...
...
src/Workspaces/CSharp/Portable/Rename/CSharpRenameRewriterLanguageService.cs
浏览文件 @
d0642c9d
...
@@ -211,7 +211,7 @@ public override SyntaxToken VisitToken(SyntaxToken token)
...
@@ -211,7 +211,7 @@ public override SyntaxToken VisitToken(SyntaxToken token)
return
newToken
;
return
newToken
;
}
}
bool
isRenameLocation
=
IsRenameLocation
(
token
);
var
isRenameLocation
=
IsRenameLocation
(
token
);
// if this is a reference location, or the identifier token's name could possibly
// if this is a reference location, or the identifier token's name could possibly
// be a conflict, we need to process this token
// be a conflict, we need to process this token
...
@@ -352,7 +352,7 @@ private async Task<SyntaxToken> RenameAndAnnotateAsync(SyntaxToken token, Syntax
...
@@ -352,7 +352,7 @@ private async Task<SyntaxToken> RenameAndAnnotateAsync(SyntaxToken token, Syntax
var
symbols
=
RenameUtilities
.
GetSymbolsTouchingPosition
(
token
.
Span
.
Start
,
_semanticModel
,
_solution
.
Workspace
,
_cancellationToken
);
var
symbols
=
RenameUtilities
.
GetSymbolsTouchingPosition
(
token
.
Span
.
Start
,
_semanticModel
,
_solution
.
Workspace
,
_cancellationToken
);
string
suffix
=
null
;
string
suffix
=
null
;
string
prefix
=
isRenameLocation
&&
_renameLocations
[
token
.
Span
].
IsRenamableAccessor
var
prefix
=
isRenameLocation
&&
_renameLocations
[
token
.
Span
].
IsRenamableAccessor
?
newToken
.
ValueText
.
Substring
(
0
,
newToken
.
ValueText
.
IndexOf
(
'_'
)
+
1
)
?
newToken
.
ValueText
.
Substring
(
0
,
newToken
.
ValueText
.
IndexOf
(
'_'
)
+
1
)
:
null
;
:
null
;
...
@@ -481,7 +481,7 @@ private RenameActionAnnotation GetAnnotationForInvocationExpression(InvocationEx
...
@@ -481,7 +481,7 @@ private RenameActionAnnotation GetAnnotationForInvocationExpression(InvocationEx
symbols
=
SpecializedCollections
.
SingletonEnumerable
(
symbolInfo
.
Symbol
);
symbols
=
SpecializedCollections
.
SingletonEnumerable
(
symbolInfo
.
Symbol
);
}
}
RenameDeclarationLocationReference
[]
renameDeclarationLocations
=
var
renameDeclarationLocations
=
ConflictResolver
.
CreateDeclarationLocationAnnotationsAsync
(
ConflictResolver
.
CreateDeclarationLocationAnnotationsAsync
(
_solution
,
_solution
,
symbols
,
symbols
,
...
@@ -566,7 +566,7 @@ private SyntaxToken UpdateAliasAnnotation(SyntaxToken newToken)
...
@@ -566,7 +566,7 @@ private SyntaxToken UpdateAliasAnnotation(SyntaxToken newToken)
private
SyntaxToken
RenameToken
(
SyntaxToken
oldToken
,
SyntaxToken
newToken
,
string
prefix
,
string
suffix
)
private
SyntaxToken
RenameToken
(
SyntaxToken
oldToken
,
SyntaxToken
newToken
,
string
prefix
,
string
suffix
)
{
{
var
parent
=
oldToken
.
Parent
;
var
parent
=
oldToken
.
Parent
;
string
currentNewIdentifier
=
_isVerbatim
?
_replacementText
.
Substring
(
1
)
:
_replacementText
;
var
currentNewIdentifier
=
_isVerbatim
?
_replacementText
.
Substring
(
1
)
:
_replacementText
;
var
oldIdentifier
=
newToken
.
ValueText
;
var
oldIdentifier
=
newToken
.
ValueText
;
var
isAttributeName
=
SyntaxFacts
.
IsAttributeName
(
parent
);
var
isAttributeName
=
SyntaxFacts
.
IsAttributeName
(
parent
);
...
@@ -594,7 +594,7 @@ private SyntaxToken RenameToken(SyntaxToken oldToken, SyntaxToken newToken, stri
...
@@ -594,7 +594,7 @@ private SyntaxToken RenameToken(SyntaxToken oldToken, SyntaxToken newToken, stri
}
}
// determine the canonical identifier name (unescaped, no unicode escaping, ...)
// determine the canonical identifier name (unescaped, no unicode escaping, ...)
string
valueText
=
currentNewIdentifier
;
var
valueText
=
currentNewIdentifier
;
var
kind
=
SyntaxFacts
.
GetKeywordKind
(
currentNewIdentifier
);
var
kind
=
SyntaxFacts
.
GetKeywordKind
(
currentNewIdentifier
);
if
(
kind
!=
SyntaxKind
.
None
)
if
(
kind
!=
SyntaxKind
.
None
)
{
{
...
@@ -638,7 +638,7 @@ private SyntaxToken RenameToken(SyntaxToken oldToken, SyntaxToken newToken, stri
...
@@ -638,7 +638,7 @@ private SyntaxToken RenameToken(SyntaxToken oldToken, SyntaxToken newToken, stri
private
SyntaxToken
RenameInStringLiteral
(
SyntaxToken
oldToken
,
SyntaxToken
newToken
,
Func
<
SyntaxTriviaList
,
string
,
string
,
SyntaxTriviaList
,
SyntaxToken
>
createNewStringLiteral
)
private
SyntaxToken
RenameInStringLiteral
(
SyntaxToken
oldToken
,
SyntaxToken
newToken
,
Func
<
SyntaxTriviaList
,
string
,
string
,
SyntaxTriviaList
,
SyntaxToken
>
createNewStringLiteral
)
{
{
var
originalString
=
newToken
.
ToString
();
var
originalString
=
newToken
.
ToString
();
string
replacedString
=
RenameLocations
.
ReferenceProcessing
.
ReplaceMatchingSubStrings
(
originalString
,
_originalText
,
_replacementText
);
var
replacedString
=
RenameLocations
.
ReferenceProcessing
.
ReplaceMatchingSubStrings
(
originalString
,
_originalText
,
_replacementText
);
if
(
replacedString
!=
originalString
)
if
(
replacedString
!=
originalString
)
{
{
var
oldSpan
=
oldToken
.
Span
;
var
oldSpan
=
oldToken
.
Span
;
...
@@ -666,7 +666,7 @@ private SyntaxToken RenameInTrivia(SyntaxToken token, IEnumerable<SyntaxTrivia>
...
@@ -666,7 +666,7 @@ private SyntaxToken RenameInTrivia(SyntaxToken token, IEnumerable<SyntaxTrivia>
private
SyntaxTrivia
RenameInCommentTrivia
(
SyntaxTrivia
trivia
)
private
SyntaxTrivia
RenameInCommentTrivia
(
SyntaxTrivia
trivia
)
{
{
var
originalString
=
trivia
.
ToString
();
var
originalString
=
trivia
.
ToString
();
string
replacedString
=
RenameLocations
.
ReferenceProcessing
.
ReplaceMatchingSubStrings
(
originalString
,
_originalText
,
_replacementText
);
var
replacedString
=
RenameLocations
.
ReferenceProcessing
.
ReplaceMatchingSubStrings
(
originalString
,
_originalText
,
_replacementText
);
if
(
replacedString
!=
originalString
)
if
(
replacedString
!=
originalString
)
{
{
var
oldSpan
=
trivia
.
Span
;
var
oldSpan
=
trivia
.
Span
;
...
@@ -992,7 +992,7 @@ private static async Task<ISymbol> GetVBPropertyFromAccessorOrAnOverrideAsync(IS
...
@@ -992,7 +992,7 @@ private static async Task<ISymbol> GetVBPropertyFromAccessorOrAnOverrideAsync(IS
ISymbol
renameSymbol
,
ISymbol
renamedSymbol
,
IEnumerable
<
ReferenceLocation
>
implicitReferenceLocations
,
CancellationToken
cancellationToken
)
ISymbol
renameSymbol
,
ISymbol
renamedSymbol
,
IEnumerable
<
ReferenceLocation
>
implicitReferenceLocations
,
CancellationToken
cancellationToken
)
{
{
// Handle renaming of symbols used for foreach
// Handle renaming of symbols used for foreach
bool
implicitReferencesMightConflict
=
renameSymbol
.
Kind
==
SymbolKind
.
Property
&&
var
implicitReferencesMightConflict
=
renameSymbol
.
Kind
==
SymbolKind
.
Property
&&
string
.
Compare
(
renameSymbol
.
Name
,
"Current"
,
StringComparison
.
OrdinalIgnoreCase
)
==
0
;
string
.
Compare
(
renameSymbol
.
Name
,
"Current"
,
StringComparison
.
OrdinalIgnoreCase
)
==
0
;
implicitReferencesMightConflict
=
implicitReferencesMightConflict
=
...
@@ -1127,8 +1127,8 @@ public void TryAddPossibleNameConflicts(ISymbol symbol, string replacementText,
...
@@ -1127,8 +1127,8 @@ public void TryAddPossibleNameConflicts(ISymbol symbol, string replacementText,
// in C# we also need to add the valueText because it can be different from the text in source
// in C# we also need to add the valueText because it can be different from the text in source
// e.g. it can contain escaped unicode characters. Otherwise conflicts would be detected for
// e.g. it can contain escaped unicode characters. Otherwise conflicts would be detected for
// v\u0061r and var or similar.
// v\u0061r and var or similar.
string
valueText
=
replacementText
;
var
valueText
=
replacementText
;
SyntaxKind
kind
=
SyntaxFacts
.
GetKeywordKind
(
replacementText
);
var
kind
=
SyntaxFacts
.
GetKeywordKind
(
replacementText
);
if
(
kind
!=
SyntaxKind
.
None
)
if
(
kind
!=
SyntaxKind
.
None
)
{
{
valueText
=
SyntaxFacts
.
GetText
(
kind
);
valueText
=
SyntaxFacts
.
GetText
(
kind
);
...
@@ -1167,7 +1167,7 @@ private static SyntaxNode GetExpansionTarget(SyntaxToken token)
...
@@ -1167,7 +1167,7 @@ private static SyntaxNode GetExpansionTarget(SyntaxToken token)
var
enclosingStatement
=
token
.
GetAncestors
(
n
=>
n
is
StatementSyntax
).
FirstOrDefault
();
var
enclosingStatement
=
token
.
GetAncestors
(
n
=>
n
is
StatementSyntax
).
FirstOrDefault
();
// System.Func<int, int> myFunc = arg => X;
// System.Func<int, int> myFunc = arg => X;
SyntaxNode
possibleLambdaExpression
=
enclosingStatement
==
null
var
possibleLambdaExpression
=
enclosingStatement
==
null
?
token
.
GetAncestors
(
n
=>
n
is
SimpleLambdaExpressionSyntax
||
n
is
ParenthesizedLambdaExpressionSyntax
).
FirstOrDefault
()
?
token
.
GetAncestors
(
n
=>
n
is
SimpleLambdaExpressionSyntax
||
n
is
ParenthesizedLambdaExpressionSyntax
).
FirstOrDefault
()
:
null
;
:
null
;
if
(
possibleLambdaExpression
!=
null
)
if
(
possibleLambdaExpression
!=
null
)
...
@@ -1283,7 +1283,7 @@ public static SemanticModel GetSemanticModelForNode(SyntaxNode node, SemanticMod
...
@@ -1283,7 +1283,7 @@ public static SemanticModel GetSemanticModelForNode(SyntaxNode node, SemanticMod
}
}
}
}
bool
isInNamespaceOrTypeContext
=
SyntaxFacts
.
IsInNamespaceOrTypeContext
(
node
as
ExpressionSyntax
);
var
isInNamespaceOrTypeContext
=
SyntaxFacts
.
IsInNamespaceOrTypeContext
(
node
as
ExpressionSyntax
);
var
position
=
nodeToSpeculate
.
SpanStart
;
var
position
=
nodeToSpeculate
.
SpanStart
;
return
SpeculationAnalyzer
.
CreateSpeculativeSemanticModelForNode
(
nodeToSpeculate
,
originalSemanticModel
,
position
,
isInNamespaceOrTypeContext
);
return
SpeculationAnalyzer
.
CreateSpeculativeSemanticModelForNode
(
nodeToSpeculate
,
originalSemanticModel
,
position
,
isInNamespaceOrTypeContext
);
}
}
...
...
src/Workspaces/CSharp/Portable/Simplification/CSharpSimplificationService.Expander.cs
浏览文件 @
d0642c9d
...
@@ -189,7 +189,7 @@ public override SyntaxNode VisitParenthesizedLambdaExpression(ParenthesizedLambd
...
@@ -189,7 +189,7 @@ public override SyntaxNode VisitParenthesizedLambdaExpression(ParenthesizedLambd
{
{
var
newParameters
=
parameterList
.
Parameters
;
var
newParameters
=
parameterList
.
Parameters
;
for
(
int
i
=
0
;
i
<
parameterSymbols
.
Length
;
i
++)
for
(
var
i
=
0
;
i
<
parameterSymbols
.
Length
;
i
++)
{
{
var
typeSyntax
=
parameterSymbols
[
i
].
Type
.
GenerateTypeSyntax
().
WithTrailingTrivia
(
s_oneWhitespaceSeparator
);
var
typeSyntax
=
parameterSymbols
[
i
].
Type
.
GenerateTypeSyntax
().
WithTrailingTrivia
(
s_oneWhitespaceSeparator
);
var
newParameter
=
parameters
[
i
].
WithType
(
typeSyntax
).
WithAdditionalAnnotations
(
Simplifier
.
Annotation
);
var
newParameter
=
parameters
[
i
].
WithType
(
typeSyntax
).
WithAdditionalAnnotations
(
Simplifier
.
Annotation
);
...
@@ -297,7 +297,7 @@ private static bool CanMakeNameExplicitInTuple(TupleExpressionSyntax tuple, stri
...
@@ -297,7 +297,7 @@ private static bool CanMakeNameExplicitInTuple(TupleExpressionSyntax tuple, stri
return
false
;
return
false
;
}
}
bool
found
=
false
;
var
found
=
false
;
foreach
(
var
argument
in
tuple
.
Arguments
)
foreach
(
var
argument
in
tuple
.
Arguments
)
{
{
string
elementName
=
null
;
string
elementName
=
null
;
...
@@ -730,7 +730,7 @@ private ExpressionSyntax TryReplaceAngleBracesWithCurlyBraces(ExpressionSyntax e
...
@@ -730,7 +730,7 @@ private ExpressionSyntax TryReplaceAngleBracesWithCurlyBraces(ExpressionSyntax e
if
(
isInsideCref
)
if
(
isInsideCref
)
{
{
var
leftTokens
=
expression
.
DescendantTokens
();
var
leftTokens
=
expression
.
DescendantTokens
();
List
<
SyntaxToken
>
candidateTokens
=
new
List
<
SyntaxToken
>();
var
candidateTokens
=
new
List
<
SyntaxToken
>();
foreach
(
var
candidateToken
in
leftTokens
)
foreach
(
var
candidateToken
in
leftTokens
)
{
{
...
@@ -776,7 +776,7 @@ private ExpressionSyntax TryAddTypeArgumentToIdentifierName(ExpressionSyntax new
...
@@ -776,7 +776,7 @@ private ExpressionSyntax TryAddTypeArgumentToIdentifierName(ExpressionSyntax new
private
IList
<
ISymbol
>
TypeArgumentSymbolsPresentInName
(
SimpleNameSyntax
simpleName
)
private
IList
<
ISymbol
>
TypeArgumentSymbolsPresentInName
(
SimpleNameSyntax
simpleName
)
{
{
List
<
ISymbol
>
typeArgumentSymbols
=
new
List
<
ISymbol
>();
var
typeArgumentSymbols
=
new
List
<
ISymbol
>();
var
typeArgumentListSyntax
=
simpleName
.
DescendantNodesAndSelf
().
Where
(
n
=>
n
is
TypeArgumentListSyntax
);
var
typeArgumentListSyntax
=
simpleName
.
DescendantNodesAndSelf
().
Where
(
n
=>
n
is
TypeArgumentListSyntax
);
foreach
(
var
typeArgumentList
in
typeArgumentListSyntax
)
foreach
(
var
typeArgumentList
in
typeArgumentListSyntax
)
{
{
...
...
src/Workspaces/CSharp/Portable/Simplification/CSharpSimplificationService.NodesAndTokensToReduceComputer.cs
浏览文件 @
d0642c9d
...
@@ -101,7 +101,7 @@ public override SyntaxToken VisitToken(SyntaxToken token)
...
@@ -101,7 +101,7 @@ public override SyntaxToken VisitToken(SyntaxToken token)
}
}
}
}
bool
savedSimplifyAllDescendants
=
_simplifyAllDescendants
;
var
savedSimplifyAllDescendants
=
_simplifyAllDescendants
;
_simplifyAllDescendants
=
_simplifyAllDescendants
||
token
.
HasAnnotation
(
Simplifier
.
Annotation
);
_simplifyAllDescendants
=
_simplifyAllDescendants
||
token
.
HasAnnotation
(
Simplifier
.
Annotation
);
if
(
_simplifyAllDescendants
&&
!
_insideSpeculatedNode
&&
!
token
.
IsKind
(
SyntaxKind
.
None
))
if
(
_simplifyAllDescendants
&&
!
_insideSpeculatedNode
&&
!
token
.
IsKind
(
SyntaxKind
.
None
))
...
...
src/Workspaces/CSharp/Portable/Simplification/Reducers/CSharpInferredMemberNameReducer.cs
浏览文件 @
d0642c9d
...
@@ -71,7 +71,7 @@ internal static bool CanSimplifyAnonymousTypeMemberName(AnonymousObjectMemberDec
...
@@ -71,7 +71,7 @@ internal static bool CanSimplifyAnonymousTypeMemberName(AnonymousObjectMemberDec
// An explicit name cannot be removed if some other position would produce it as inferred name
// An explicit name cannot be removed if some other position would produce it as inferred name
private
static
bool
RemovalCausesAmbiguity
(
SeparatedSyntaxList
<
ArgumentSyntax
>
arguments
,
ArgumentSyntax
toRemove
)
private
static
bool
RemovalCausesAmbiguity
(
SeparatedSyntaxList
<
ArgumentSyntax
>
arguments
,
ArgumentSyntax
toRemove
)
{
{
string
name
=
toRemove
.
NameColon
.
Name
.
Identifier
.
ValueText
;
var
name
=
toRemove
.
NameColon
.
Name
.
Identifier
.
ValueText
;
foreach
(
var
argument
in
arguments
)
foreach
(
var
argument
in
arguments
)
{
{
if
(
argument
==
toRemove
)
if
(
argument
==
toRemove
)
...
@@ -91,7 +91,7 @@ private static bool RemovalCausesAmbiguity(SeparatedSyntaxList<ArgumentSyntax> a
...
@@ -91,7 +91,7 @@ private static bool RemovalCausesAmbiguity(SeparatedSyntaxList<ArgumentSyntax> a
// An explicit name cannot be removed if some other position would produce it as inferred name
// An explicit name cannot be removed if some other position would produce it as inferred name
private
static
bool
RemovalCausesAmbiguity
(
SeparatedSyntaxList
<
AnonymousObjectMemberDeclaratorSyntax
>
initializers
,
AnonymousObjectMemberDeclaratorSyntax
toRemove
)
private
static
bool
RemovalCausesAmbiguity
(
SeparatedSyntaxList
<
AnonymousObjectMemberDeclaratorSyntax
>
initializers
,
AnonymousObjectMemberDeclaratorSyntax
toRemove
)
{
{
string
name
=
toRemove
.
NameEquals
.
Name
.
Identifier
.
ValueText
;
var
name
=
toRemove
.
NameEquals
.
Name
.
Identifier
.
ValueText
;
foreach
(
var
initializer
in
initializers
)
foreach
(
var
initializer
in
initializers
)
{
{
if
(
initializer
==
toRemove
)
if
(
initializer
==
toRemove
)
...
...
src/Workspaces/CSharp/Portable/Simplification/Reducers/CSharpNameReducer.Rewriter.cs
浏览文件 @
d0642c9d
...
@@ -20,7 +20,7 @@ public Rewriter(ObjectPool<IReductionRewriter> pool)
...
@@ -20,7 +20,7 @@ public Rewriter(ObjectPool<IReductionRewriter> pool)
public
override
SyntaxNode
VisitPredefinedType
(
PredefinedTypeSyntax
node
)
public
override
SyntaxNode
VisitPredefinedType
(
PredefinedTypeSyntax
node
)
{
{
bool
oldAlwaysSimplify
=
this
.
alwaysSimplify
;
var
oldAlwaysSimplify
=
this
.
alwaysSimplify
;
if
(!
this
.
alwaysSimplify
)
if
(!
this
.
alwaysSimplify
)
{
{
this
.
alwaysSimplify
=
node
.
HasAnnotation
(
Simplifier
.
Annotation
);
this
.
alwaysSimplify
=
node
.
HasAnnotation
(
Simplifier
.
Annotation
);
...
@@ -38,7 +38,7 @@ public override SyntaxNode VisitPredefinedType(PredefinedTypeSyntax node)
...
@@ -38,7 +38,7 @@ public override SyntaxNode VisitPredefinedType(PredefinedTypeSyntax node)
public
override
SyntaxNode
VisitAliasQualifiedName
(
AliasQualifiedNameSyntax
node
)
public
override
SyntaxNode
VisitAliasQualifiedName
(
AliasQualifiedNameSyntax
node
)
{
{
bool
oldAlwaysSimplify
=
this
.
alwaysSimplify
;
var
oldAlwaysSimplify
=
this
.
alwaysSimplify
;
if
(!
this
.
alwaysSimplify
)
if
(!
this
.
alwaysSimplify
)
{
{
this
.
alwaysSimplify
=
node
.
HasAnnotation
(
Simplifier
.
Annotation
);
this
.
alwaysSimplify
=
node
.
HasAnnotation
(
Simplifier
.
Annotation
);
...
@@ -56,7 +56,7 @@ public override SyntaxNode VisitAliasQualifiedName(AliasQualifiedNameSyntax node
...
@@ -56,7 +56,7 @@ public override SyntaxNode VisitAliasQualifiedName(AliasQualifiedNameSyntax node
public
override
SyntaxNode
VisitQualifiedName
(
QualifiedNameSyntax
node
)
public
override
SyntaxNode
VisitQualifiedName
(
QualifiedNameSyntax
node
)
{
{
bool
oldAlwaysSimplify
=
this
.
alwaysSimplify
;
var
oldAlwaysSimplify
=
this
.
alwaysSimplify
;
if
(!
this
.
alwaysSimplify
)
if
(!
this
.
alwaysSimplify
)
{
{
this
.
alwaysSimplify
=
node
.
HasAnnotation
(
Simplifier
.
Annotation
);
this
.
alwaysSimplify
=
node
.
HasAnnotation
(
Simplifier
.
Annotation
);
...
@@ -74,7 +74,7 @@ public override SyntaxNode VisitQualifiedName(QualifiedNameSyntax node)
...
@@ -74,7 +74,7 @@ public override SyntaxNode VisitQualifiedName(QualifiedNameSyntax node)
public
override
SyntaxNode
VisitMemberAccessExpression
(
MemberAccessExpressionSyntax
node
)
public
override
SyntaxNode
VisitMemberAccessExpression
(
MemberAccessExpressionSyntax
node
)
{
{
bool
oldAlwaysSimplify
=
this
.
alwaysSimplify
;
var
oldAlwaysSimplify
=
this
.
alwaysSimplify
;
if
(!
this
.
alwaysSimplify
)
if
(!
this
.
alwaysSimplify
)
{
{
this
.
alwaysSimplify
=
node
.
HasAnnotation
(
Simplifier
.
Annotation
);
this
.
alwaysSimplify
=
node
.
HasAnnotation
(
Simplifier
.
Annotation
);
...
@@ -92,7 +92,7 @@ public override SyntaxNode VisitMemberAccessExpression(MemberAccessExpressionSyn
...
@@ -92,7 +92,7 @@ public override SyntaxNode VisitMemberAccessExpression(MemberAccessExpressionSyn
public
override
SyntaxNode
VisitIdentifierName
(
IdentifierNameSyntax
node
)
public
override
SyntaxNode
VisitIdentifierName
(
IdentifierNameSyntax
node
)
{
{
bool
oldAlwaysSimplify
=
this
.
alwaysSimplify
;
var
oldAlwaysSimplify
=
this
.
alwaysSimplify
;
if
(!
this
.
alwaysSimplify
)
if
(!
this
.
alwaysSimplify
)
{
{
this
.
alwaysSimplify
=
node
.
HasAnnotation
(
Simplifier
.
Annotation
);
this
.
alwaysSimplify
=
node
.
HasAnnotation
(
Simplifier
.
Annotation
);
...
@@ -110,7 +110,7 @@ public override SyntaxNode VisitIdentifierName(IdentifierNameSyntax node)
...
@@ -110,7 +110,7 @@ public override SyntaxNode VisitIdentifierName(IdentifierNameSyntax node)
public
override
SyntaxNode
VisitGenericName
(
GenericNameSyntax
node
)
public
override
SyntaxNode
VisitGenericName
(
GenericNameSyntax
node
)
{
{
bool
oldAlwaysSimplify
=
this
.
alwaysSimplify
;
var
oldAlwaysSimplify
=
this
.
alwaysSimplify
;
if
(!
this
.
alwaysSimplify
)
if
(!
this
.
alwaysSimplify
)
{
{
this
.
alwaysSimplify
=
node
.
HasAnnotation
(
Simplifier
.
Annotation
);
this
.
alwaysSimplify
=
node
.
HasAnnotation
(
Simplifier
.
Annotation
);
...
@@ -128,7 +128,7 @@ public override SyntaxNode VisitGenericName(GenericNameSyntax node)
...
@@ -128,7 +128,7 @@ public override SyntaxNode VisitGenericName(GenericNameSyntax node)
public
override
SyntaxNode
VisitQualifiedCref
(
QualifiedCrefSyntax
node
)
public
override
SyntaxNode
VisitQualifiedCref
(
QualifiedCrefSyntax
node
)
{
{
bool
oldAlwaysSimplify
=
this
.
alwaysSimplify
;
var
oldAlwaysSimplify
=
this
.
alwaysSimplify
;
if
(!
this
.
alwaysSimplify
)
if
(!
this
.
alwaysSimplify
)
{
{
this
.
alwaysSimplify
=
node
.
HasAnnotation
(
Simplifier
.
Annotation
);
this
.
alwaysSimplify
=
node
.
HasAnnotation
(
Simplifier
.
Annotation
);
...
@@ -146,7 +146,7 @@ public override SyntaxNode VisitQualifiedCref(QualifiedCrefSyntax node)
...
@@ -146,7 +146,7 @@ public override SyntaxNode VisitQualifiedCref(QualifiedCrefSyntax node)
public
override
SyntaxNode
VisitArrayType
(
ArrayTypeSyntax
node
)
public
override
SyntaxNode
VisitArrayType
(
ArrayTypeSyntax
node
)
{
{
bool
oldAlwaysSimplify
=
this
.
alwaysSimplify
;
var
oldAlwaysSimplify
=
this
.
alwaysSimplify
;
if
(!
this
.
alwaysSimplify
)
if
(!
this
.
alwaysSimplify
)
{
{
this
.
alwaysSimplify
=
node
.
HasAnnotation
(
Simplifier
.
Annotation
);
this
.
alwaysSimplify
=
node
.
HasAnnotation
(
Simplifier
.
Annotation
);
...
@@ -164,7 +164,7 @@ public override SyntaxNode VisitArrayType(ArrayTypeSyntax node)
...
@@ -164,7 +164,7 @@ public override SyntaxNode VisitArrayType(ArrayTypeSyntax node)
public
override
SyntaxNode
VisitNullableType
(
NullableTypeSyntax
node
)
public
override
SyntaxNode
VisitNullableType
(
NullableTypeSyntax
node
)
{
{
bool
oldAlwaysSimplify
=
this
.
alwaysSimplify
;
var
oldAlwaysSimplify
=
this
.
alwaysSimplify
;
if
(!
this
.
alwaysSimplify
)
if
(!
this
.
alwaysSimplify
)
{
{
this
.
alwaysSimplify
=
node
.
HasAnnotation
(
Simplifier
.
Annotation
);
this
.
alwaysSimplify
=
node
.
HasAnnotation
(
Simplifier
.
Annotation
);
...
@@ -182,7 +182,7 @@ public override SyntaxNode VisitNullableType(NullableTypeSyntax node)
...
@@ -182,7 +182,7 @@ public override SyntaxNode VisitNullableType(NullableTypeSyntax node)
public
override
SyntaxNode
VisitTupleType
(
TupleTypeSyntax
node
)
public
override
SyntaxNode
VisitTupleType
(
TupleTypeSyntax
node
)
{
{
bool
oldAlwaysSimplify
=
this
.
alwaysSimplify
;
var
oldAlwaysSimplify
=
this
.
alwaysSimplify
;
if
(!
this
.
alwaysSimplify
)
if
(!
this
.
alwaysSimplify
)
{
{
this
.
alwaysSimplify
=
node
.
HasAnnotation
(
Simplifier
.
Annotation
);
this
.
alwaysSimplify
=
node
.
HasAnnotation
(
Simplifier
.
Annotation
);
...
@@ -200,7 +200,7 @@ public override SyntaxNode VisitTupleType(TupleTypeSyntax node)
...
@@ -200,7 +200,7 @@ public override SyntaxNode VisitTupleType(TupleTypeSyntax node)
public
override
SyntaxNode
VisitBinaryExpression
(
BinaryExpressionSyntax
node
)
public
override
SyntaxNode
VisitBinaryExpression
(
BinaryExpressionSyntax
node
)
{
{
bool
isOrAsNode
=
node
.
Kind
()
==
SyntaxKind
.
AsExpression
||
node
.
Kind
()
==
SyntaxKind
.
IsExpression
;
var
isOrAsNode
=
node
.
Kind
()
==
SyntaxKind
.
AsExpression
||
node
.
Kind
()
==
SyntaxKind
.
IsExpression
;
var
result
=
(
ExpressionSyntax
)
base
.
VisitBinaryExpression
(
node
);
var
result
=
(
ExpressionSyntax
)
base
.
VisitBinaryExpression
(
node
);
...
...
src/Workspaces/CSharp/Portable/Utilities/NameSyntaxComparer.cs
浏览文件 @
d0642c9d
...
@@ -67,7 +67,7 @@ public int Compare(NameSyntax x, NameSyntax y)
...
@@ -67,7 +67,7 @@ public int Compare(NameSyntax x, NameSyntax y)
}
}
else
if
(
x
is
IdentifierNameSyntax
&&
y
is
GenericNameSyntax
)
else
if
(
x
is
IdentifierNameSyntax
&&
y
is
GenericNameSyntax
)
{
{
int
compare
=
_tokenComparer
.
Compare
(
x
.
GetFirstToken
(
includeSkipped
:
true
),
y
.
GetFirstToken
());
var
compare
=
_tokenComparer
.
Compare
(
x
.
GetFirstToken
(
includeSkipped
:
true
),
y
.
GetFirstToken
());
if
(
compare
!=
0
)
if
(
compare
!=
0
)
{
{
return
compare
;
return
compare
;
...
@@ -78,7 +78,7 @@ public int Compare(NameSyntax x, NameSyntax y)
...
@@ -78,7 +78,7 @@ public int Compare(NameSyntax x, NameSyntax y)
}
}
else
if
(
x
is
GenericNameSyntax
&&
y
is
IdentifierNameSyntax
)
else
if
(
x
is
GenericNameSyntax
&&
y
is
IdentifierNameSyntax
)
{
{
int
compare
=
_tokenComparer
.
Compare
(
x
.
GetFirstToken
(
includeSkipped
:
true
),
y
.
GetFirstToken
());
var
compare
=
_tokenComparer
.
Compare
(
x
.
GetFirstToken
(
includeSkipped
:
true
),
y
.
GetFirstToken
());
if
(
compare
!=
0
)
if
(
compare
!=
0
)
{
{
return
compare
;
return
compare
;
...
@@ -95,9 +95,9 @@ public int Compare(NameSyntax x, NameSyntax y)
...
@@ -95,9 +95,9 @@ public int Compare(NameSyntax x, NameSyntax y)
var
xNameParts
=
DecomposeNameParts
(
x
);
var
xNameParts
=
DecomposeNameParts
(
x
);
var
yNameParts
=
DecomposeNameParts
(
y
);
var
yNameParts
=
DecomposeNameParts
(
y
);
for
(
int
i
=
0
;
i
<
xNameParts
.
Count
&&
i
<
yNameParts
.
Count
;
i
++)
for
(
var
i
=
0
;
i
<
xNameParts
.
Count
&&
i
<
yNameParts
.
Count
;
i
++)
{
{
int
compare
=
Compare
(
xNameParts
[
i
],
yNameParts
[
i
]);
var
compare
=
Compare
(
xNameParts
[
i
],
yNameParts
[
i
]);
if
(
compare
!=
0
)
if
(
compare
!=
0
)
{
{
return
compare
;
return
compare
;
...
@@ -141,7 +141,7 @@ private void DecomposeNameParts(NameSyntax name, List<SimpleNameSyntax> result)
...
@@ -141,7 +141,7 @@ private void DecomposeNameParts(NameSyntax name, List<SimpleNameSyntax> result)
private
int
Compare
(
GenericNameSyntax
x
,
GenericNameSyntax
y
)
private
int
Compare
(
GenericNameSyntax
x
,
GenericNameSyntax
y
)
{
{
int
compare
=
_tokenComparer
.
Compare
(
x
.
Identifier
,
y
.
Identifier
);
var
compare
=
_tokenComparer
.
Compare
(
x
.
Identifier
,
y
.
Identifier
);
if
(
compare
!=
0
)
if
(
compare
!=
0
)
{
{
return
compare
;
return
compare
;
...
@@ -155,7 +155,7 @@ private int Compare(GenericNameSyntax x, GenericNameSyntax y)
...
@@ -155,7 +155,7 @@ private int Compare(GenericNameSyntax x, GenericNameSyntax y)
}
}
// Same name, same parameter count. Compare each parameter.
// Same name, same parameter count. Compare each parameter.
for
(
int
i
=
0
;
i
<
x
.
Arity
;
i
++)
for
(
var
i
=
0
;
i
<
x
.
Arity
;
i
++)
{
{
var
xArg
=
x
.
TypeArgumentList
.
Arguments
[
i
];
var
xArg
=
x
.
TypeArgumentList
.
Arguments
[
i
];
var
yArg
=
y
.
TypeArgumentList
.
Arguments
[
i
];
var
yArg
=
y
.
TypeArgumentList
.
Arguments
[
i
];
...
...
src/Workspaces/CSharp/Portable/Utilities/SpeculationAnalyzer.cs
浏览文件 @
d0642c9d
...
@@ -98,8 +98,8 @@ protected override SemanticModel CreateSpeculativeSemanticModel(SyntaxNode origi
...
@@ -98,8 +98,8 @@ protected override SemanticModel CreateSpeculativeSemanticModel(SyntaxNode origi
public
static
SemanticModel
CreateSpeculativeSemanticModelForNode
(
SyntaxNode
originalNode
,
SyntaxNode
nodeToSpeculate
,
SemanticModel
semanticModel
)
public
static
SemanticModel
CreateSpeculativeSemanticModelForNode
(
SyntaxNode
originalNode
,
SyntaxNode
nodeToSpeculate
,
SemanticModel
semanticModel
)
{
{
int
position
=
originalNode
.
SpanStart
;
var
position
=
originalNode
.
SpanStart
;
bool
isInNamespaceOrTypeContext
=
SyntaxFacts
.
IsInNamespaceOrTypeContext
(
originalNode
as
ExpressionSyntax
);
var
isInNamespaceOrTypeContext
=
SyntaxFacts
.
IsInNamespaceOrTypeContext
(
originalNode
as
ExpressionSyntax
);
return
CreateSpeculativeSemanticModelForNode
(
nodeToSpeculate
,
semanticModel
,
position
,
isInNamespaceOrTypeContext
);
return
CreateSpeculativeSemanticModelForNode
(
nodeToSpeculate
,
semanticModel
,
position
,
isInNamespaceOrTypeContext
);
}
}
...
@@ -192,7 +192,7 @@ public bool ReplacementChangesSemanticsOfUnchangedLambda(ExpressionSyntax origin
...
@@ -192,7 +192,7 @@ public bool ReplacementChangesSemanticsOfUnchangedLambda(ExpressionSyntax origin
Debug
.
Assert
(
originalParams
.
Count
==
replacedParams
.
Count
);
Debug
.
Assert
(
originalParams
.
Count
==
replacedParams
.
Count
);
paramNames
=
new
List
<
string
>();
paramNames
=
new
List
<
string
>();
for
(
int
i
=
0
;
i
<
originalParams
.
Count
;
i
++)
for
(
var
i
=
0
;
i
<
originalParams
.
Count
;
i
++)
{
{
var
originalParam
=
originalParams
[
i
];
var
originalParam
=
originalParams
[
i
];
var
replacedParam
=
replacedParams
[
i
];
var
replacedParam
=
replacedParams
[
i
];
...
@@ -438,7 +438,7 @@ protected override bool ReplacementChangesSemanticsForNodeLanguageSpecific(Synta
...
@@ -438,7 +438,7 @@ protected override bool ReplacementChangesSemanticsForNodeLanguageSpecific(Synta
var
originalSwitchLabels
=
originalSwitchStatement
.
Sections
.
SelectMany
(
section
=>
section
.
Labels
).
ToArray
();
var
originalSwitchLabels
=
originalSwitchStatement
.
Sections
.
SelectMany
(
section
=>
section
.
Labels
).
ToArray
();
var
newSwitchLabels
=
newSwitchStatement
.
Sections
.
SelectMany
(
section
=>
section
.
Labels
).
ToArray
();
var
newSwitchLabels
=
newSwitchStatement
.
Sections
.
SelectMany
(
section
=>
section
.
Labels
).
ToArray
();
for
(
int
i
=
0
;
i
<
originalSwitchLabels
.
Length
;
i
++)
for
(
var
i
=
0
;
i
<
originalSwitchLabels
.
Length
;
i
++)
{
{
if
(
originalSwitchLabels
[
i
]
is
CaseSwitchLabelSyntax
originalSwitchLabel
)
if
(
originalSwitchLabels
[
i
]
is
CaseSwitchLabelSyntax
originalSwitchLabel
)
{
{
...
@@ -715,8 +715,8 @@ private bool ReplacementBreaksAssignmentExpression(AssignmentExpressionSyntax as
...
@@ -715,8 +715,8 @@ private bool ReplacementBreaksAssignmentExpression(AssignmentExpressionSyntax as
private
bool
ReplacementBreaksQueryClause
(
QueryClauseSyntax
originalClause
,
QueryClauseSyntax
newClause
)
private
bool
ReplacementBreaksQueryClause
(
QueryClauseSyntax
originalClause
,
QueryClauseSyntax
newClause
)
{
{
// Ensure QueryClauseInfos are compatible.
// Ensure QueryClauseInfos are compatible.
QueryClauseInfo
originalClauseInfo
=
this
.
OriginalSemanticModel
.
GetQueryClauseInfo
(
originalClause
,
this
.
CancellationToken
);
var
originalClauseInfo
=
this
.
OriginalSemanticModel
.
GetQueryClauseInfo
(
originalClause
,
this
.
CancellationToken
);
QueryClauseInfo
newClauseInfo
=
this
.
SpeculativeSemanticModel
.
GetQueryClauseInfo
(
newClause
,
this
.
CancellationToken
);
var
newClauseInfo
=
this
.
SpeculativeSemanticModel
.
GetQueryClauseInfo
(
newClause
,
this
.
CancellationToken
);
return
!
SymbolInfosAreCompatible
(
originalClauseInfo
.
CastInfo
,
newClauseInfo
.
CastInfo
)
||
return
!
SymbolInfosAreCompatible
(
originalClauseInfo
.
CastInfo
,
newClauseInfo
.
CastInfo
)
||
!
SymbolInfosAreCompatible
(
originalClauseInfo
.
OperationInfo
,
newClauseInfo
.
OperationInfo
);
!
SymbolInfosAreCompatible
(
originalClauseInfo
.
OperationInfo
,
newClauseInfo
.
OperationInfo
);
...
...
src/Workspaces/CSharp/Portable/Utilities/UsingsAndExternAliasesDirectiveComparer.cs
浏览文件 @
d0642c9d
...
@@ -76,7 +76,7 @@ public int Compare(SyntaxNode directive1, SyntaxNode directive2)
...
@@ -76,7 +76,7 @@ public int Compare(SyntaxNode directive1, SyntaxNode directive2)
// * using statics
// * using statics
// * aliases
// * aliases
int
directiveKindDifference
=
directive1Kind
-
directive2Kind
;
var
directiveKindDifference
=
directive1Kind
-
directive2Kind
;
if
(
directiveKindDifference
!=
0
)
if
(
directiveKindDifference
!=
0
)
{
{
return
directiveKindDifference
;
return
directiveKindDifference
;
...
...
src/Workspaces/CSharp/Portable/Utilities/UsingsAndExternAliasesOrganizer.cs
浏览文件 @
d0642c9d
...
@@ -146,7 +146,7 @@ private static void EnsureNewLines(IList<SyntaxNode> list)
...
@@ -146,7 +146,7 @@ private static void EnsureNewLines(IList<SyntaxNode> list)
{
{
// First, make sure that every node (except the last one) ends with
// First, make sure that every node (except the last one) ends with
// a newline.
// a newline.
for
(
int
i
=
0
;
i
<
list
.
Count
-
1
;
i
++)
for
(
var
i
=
0
;
i
<
list
.
Count
-
1
;
i
++)
{
{
var
node
=
list
[
i
];
var
node
=
list
[
i
];
var
trailingTrivia
=
node
.
GetTrailingTrivia
();
var
trailingTrivia
=
node
.
GetTrailingTrivia
();
...
@@ -159,7 +159,7 @@ private static void EnsureNewLines(IList<SyntaxNode> list)
...
@@ -159,7 +159,7 @@ private static void EnsureNewLines(IList<SyntaxNode> list)
// Now, make sure that every node (except the first one) does *not*
// Now, make sure that every node (except the first one) does *not*
// start with newlines.
// start with newlines.
for
(
int
i
=
1
;
i
<
list
.
Count
;
i
++)
for
(
var
i
=
1
;
i
<
list
.
Count
;
i
++)
{
{
var
node
=
list
[
i
];
var
node
=
list
[
i
];
list
[
i
]
=
TrimLeadingNewLines
(
node
);
list
[
i
]
=
TrimLeadingNewLines
(
node
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录