Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
b43cc84c
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,发现更多精彩内容 >>
提交
b43cc84c
编写于
2月 11, 2019
作者:
S
Sam Harwell
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Avoid closure allocations in ApplyTriviaOperations
上级
da78b3ec
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
47 addition
and
29 deletion
+47
-29
src/CodeStyle/Core/Analyzers/Microsoft.CodeAnalysis.CodeStyle.csproj
...le/Core/Analyzers/Microsoft.CodeAnalysis.CodeStyle.csproj
+2
-0
src/Workspaces/CSharp/Portable/Formatting/Engine/Trivia/TriviaDataFactory.ComplexTrivia.cs
...rmatting/Engine/Trivia/TriviaDataFactory.ComplexTrivia.cs
+3
-2
src/Workspaces/CSharp/Portable/Formatting/Engine/Trivia/TriviaDataFactory.FormattedComplexTrivia.cs
...Engine/Trivia/TriviaDataFactory.FormattedComplexTrivia.cs
+1
-1
src/Workspaces/CSharp/Portable/Formatting/Engine/Trivia/TriviaDataFactory.ModifiedComplexTrivia.cs
.../Engine/Trivia/TriviaDataFactory.ModifiedComplexTrivia.cs
+3
-1
src/Workspaces/Core/Portable/Formatting/Engine/AbstractFormatEngine.cs
...s/Core/Portable/Formatting/Engine/AbstractFormatEngine.cs
+19
-14
src/Workspaces/Core/Portable/Formatting/Engine/AbstractTriviaDataFactory.FormattedWhitespace.cs
...g/Engine/AbstractTriviaDataFactory.FormattedWhitespace.cs
+1
-1
src/Workspaces/Core/Portable/Formatting/Engine/AbstractTriviaDataFactory.ModifiedWhitespace.cs
...ng/Engine/AbstractTriviaDataFactory.ModifiedWhitespace.cs
+3
-2
src/Workspaces/Core/Portable/Formatting/Engine/AbstractTriviaDataFactory.Whitespace.cs
...Formatting/Engine/AbstractTriviaDataFactory.Whitespace.cs
+2
-1
src/Workspaces/Core/Portable/Formatting/Engine/TriviaData.cs
src/Workspaces/Core/Portable/Formatting/Engine/TriviaData.cs
+2
-1
src/Workspaces/VisualBasic/Portable/Formatting/Engine/Trivia/TriviaDataFactory.AbstractLineBreakTrivia.vb
...ngine/Trivia/TriviaDataFactory.AbstractLineBreakTrivia.vb
+3
-2
src/Workspaces/VisualBasic/Portable/Formatting/Engine/Trivia/TriviaDataFactory.ComplexTrivia.vb
...rmatting/Engine/Trivia/TriviaDataFactory.ComplexTrivia.vb
+3
-2
src/Workspaces/VisualBasic/Portable/Formatting/Engine/Trivia/TriviaDataFactory.FormattedComplexTrivia.vb
...Engine/Trivia/TriviaDataFactory.FormattedComplexTrivia.vb
+2
-1
src/Workspaces/VisualBasic/Portable/Formatting/Engine/Trivia/TriviaDataFactory.ModifiedComplexTrivia.vb
.../Engine/Trivia/TriviaDataFactory.ModifiedComplexTrivia.vb
+3
-1
未找到文件。
src/CodeStyle/Core/Analyzers/Microsoft.CodeAnalysis.CodeStyle.csproj
浏览文件 @
b43cc84c
...
...
@@ -11,6 +11,7 @@
<ItemGroup>
<PackageReference
Include=
"Microsoft.VisualStudio.CodingConventions"
Version=
"$(MicrosoftVisualStudioCodingConventionsVersion)"
/>
<PackageReference
Include=
"Microsoft.CodeAnalysis.Common"
Version=
"$(MicrosoftCodeAnalysisCommonFixedVersion)"
/>
<PackageReference
Include=
"System.Threading.Tasks.Extensions"
Version=
"$(SystemThreadingTasksExtensionsVersion)"
/>
</ItemGroup>
<ItemGroup>
<!--
...
...
@@ -30,6 +31,7 @@
<Compile
Include=
"..\..\..\Compilers\Core\Portable\InternalUtilities\ExceptionUtilities.cs"
Link=
"InternalUtilities\ExceptionUtilities.cs"
/>
<Compile
Include=
"..\..\..\Compilers\Core\Portable\InternalUtilities\IReadOnlySet.cs"
Link=
"InternalUtilities\IReadOnlySet.cs"
/>
<Compile
Include=
"..\..\..\Compilers\Core\Portable\InternalUtilities\KeyValuePairUtil.cs"
Link=
"InternalUtilities\KeyValuePairUtil.cs"
/>
<Compile
Include=
"..\..\..\Compilers\Core\Portable\InternalUtilities\PerformanceSensitiveAttribute.cs"
Link=
"PerformanceSensitiveAttribute.cs"
/>
<Compile
Include=
"..\..\..\Compilers\Core\Portable\InternalUtilities\SpecializedCollections.cs"
Link=
"InternalUtilities\SpecializedCollections.cs"
/>
<Compile
Include=
"..\..\..\Compilers\Core\Portable\InternalUtilities\SpecializedCollections.Empty.Collection.cs"
Link=
"InternalUtilities\SpecializedCollections.Empty.Collection.cs"
/>
<Compile
Include=
"..\..\..\Compilers\Core\Portable\InternalUtilities\SpecializedCollections.Empty.cs"
Link=
"InternalUtilities\SpecializedCollections.Empty.cs"
/>
...
...
src/Workspaces/CSharp/Portable/Formatting/Engine/Trivia/TriviaDataFactory.ComplexTrivia.cs
浏览文件 @
b43cc84c
...
...
@@ -100,7 +100,8 @@ private bool ShouldFormat(FormattingContext context)
public
override
void
Format
(
FormattingContext
context
,
ChainedFormattingRules
formattingRules
,
Action
<
int
,
TriviaData
>
formattingResultApplier
,
Action
<
int
,
TokenStream
,
TriviaData
>
formattingResultApplier
,
TokenStream
tokenStream
,
CancellationToken
cancellationToken
,
int
tokenPairIndex
=
TokenPairIndexNotNeeded
)
{
...
...
@@ -109,7 +110,7 @@ private bool ShouldFormat(FormattingContext context)
return
;
}
formattingResultApplier
(
tokenPairIndex
,
Format
(
context
,
formattingRules
,
this
.
LineBreaks
,
this
.
Spaces
,
cancellationToken
));
formattingResultApplier
(
tokenPairIndex
,
tokenStream
,
Format
(
context
,
formattingRules
,
this
.
LineBreaks
,
this
.
Spaces
,
cancellationToken
));
}
public
override
List
<
SyntaxTrivia
>
GetTriviaList
(
CancellationToken
cancellationToken
)
...
...
src/Workspaces/CSharp/Portable/Formatting/Engine/Trivia/TriviaDataFactory.FormattedComplexTrivia.cs
浏览文件 @
b43cc84c
...
...
@@ -78,7 +78,7 @@ public override TriviaData WithIndentation(int indentation, FormattingContext co
throw
new
NotImplementedException
();
}
public
override
void
Format
(
FormattingContext
context
,
ChainedFormattingRules
formattingRules
,
Action
<
int
,
T
riviaData
>
formattingResultApplier
,
CancellationToken
cancellationToken
,
int
tokenPairIndex
=
TokenPairIndexNotNeeded
)
public
override
void
Format
(
FormattingContext
context
,
ChainedFormattingRules
formattingRules
,
Action
<
int
,
T
okenStream
,
TriviaData
>
formattingResultApplier
,
TokenStream
tokenStream
,
CancellationToken
cancellationToken
,
int
tokenPairIndex
=
TokenPairIndexNotNeeded
)
{
throw
new
NotImplementedException
();
}
...
...
src/Workspaces/CSharp/Portable/Formatting/Engine/Trivia/TriviaDataFactory.ModifiedComplexTrivia.cs
浏览文件 @
b43cc84c
...
...
@@ -71,7 +71,8 @@ public override TriviaData WithSpace(int space, FormattingContext context, Chain
public
override
void
Format
(
FormattingContext
context
,
ChainedFormattingRules
formattingRules
,
Action
<
int
,
TriviaData
>
formattingResultApplier
,
Action
<
int
,
TokenStream
,
TriviaData
>
formattingResultApplier
,
TokenStream
tokenStream
,
CancellationToken
cancellationToken
,
int
tokenPairIndex
=
TokenPairIndexNotNeeded
)
{
...
...
@@ -90,6 +91,7 @@ public override TriviaData WithSpace(int space, FormattingContext context, Chain
}
formattingResultApplier
(
tokenPairIndex
,
tokenStream
,
new
FormattedComplexTrivia
(
context
,
formattingRules
,
...
...
src/Workspaces/Core/Portable/Formatting/Engine/AbstractFormatEngine.cs
浏览文件 @
b43cc84c
...
...
@@ -252,15 +252,15 @@ private List<T> AddOperations<T>(List<SyntaxNode> nodes, Action<List<T>, SyntaxN
return
;
}
void
beginningOfTreeTriviaInfoApplier
(
int
i
,
TriviaData
info
)
void
beginningOfTreeTriviaInfoApplier
(
int
i
,
T
okenStream
ts
,
T
riviaData
info
)
{
t
okenStream
.
ApplyBeginningOfTreeChange
(
info
);
t
s
.
ApplyBeginningOfTreeChange
(
info
);
}
// remove all leading indentation
var
triviaInfo
=
tokenStream
.
GetTriviaDataAtBeginningOfTree
().
WithIndentation
(
0
,
context
,
_formattingRules
,
cancellationToken
);
triviaInfo
.
Format
(
context
,
_formattingRules
,
beginningOfTreeTriviaInfoApplier
,
cancellationToken
);
triviaInfo
.
Format
(
context
,
_formattingRules
,
beginningOfTreeTriviaInfoApplier
,
tokenStream
,
cancellationToken
);
}
private
void
ApplyEndOfTreeTriviaOperation
(
...
...
@@ -271,36 +271,41 @@ void beginningOfTreeTriviaInfoApplier(int i, TriviaData info)
return
;
}
void
endOfTreeTriviaInfoApplier
(
int
i
,
TriviaData
info
)
void
endOfTreeTriviaInfoApplier
(
int
i
,
T
okenStream
ts
,
T
riviaData
info
)
{
t
okenStream
.
ApplyEndOfTreeChange
(
info
);
t
s
.
ApplyEndOfTreeChange
(
info
);
}
// remove all trailing indentation
var
triviaInfo
=
tokenStream
.
GetTriviaDataAtEndOfTree
().
WithIndentation
(
0
,
context
,
_formattingRules
,
cancellationToken
);
triviaInfo
.
Format
(
context
,
_formattingRules
,
endOfTreeTriviaInfoApplier
,
cancellationToken
);
triviaInfo
.
Format
(
context
,
_formattingRules
,
endOfTreeTriviaInfoApplier
,
tokenStream
,
cancellationToken
);
}
[
PerformanceSensitive
(
"https://github.com/dotnet/roslyn/issues/30819"
,
AllowCaptures
=
false
)]
private
void
ApplyTriviaOperations
(
FormattingContext
context
,
TokenStream
tokenStream
,
CancellationToken
cancellationToken
)
{
// trivia formatting result appliers
void
regularApplier
(
int
tokenPairIndex
,
TriviaData
info
)
void
regularApplier
(
int
tokenPairIndex
,
TriviaData
info
,
TokenStream
ts
)
{
t
okenStream
.
ApplyChange
(
tokenPairIndex
,
info
);
t
s
.
ApplyChange
(
tokenPairIndex
,
info
);
}
// trivia formatting applier
void
triviaFormatter
(
int
tokenPairIndex
)
void
triviaFormatter
(
int
tokenPairIndex
,
FormattingContext
ctx
,
ChainedFormattingRules
formattingRules
,
TokenStream
ts
,
CancellationToken
ct
)
{
var
triviaInfo
=
tokenStream
.
GetTriviaData
(
tokenPairIndex
);
triviaInfo
.
Format
(
context
,
_formattingRules
,
regularApplier
,
cancellationToken
,
tokenPairIndex
);
var
triviaInfo
=
ts
.
GetTriviaData
(
tokenPairIndex
);
triviaInfo
.
Format
(
ctx
,
formattingRules
,
(
int
tokenPairIndex1
,
TokenStream
ts2
,
TriviaData
info
)
=>
regularApplier
(
tokenPairIndex1
,
info
,
ts2
),
ts
,
ct
,
tokenPairIndex
);
}
for
(
var
i
=
0
;
i
<
tokenStream
.
TokenCount
-
1
;
i
++)
{
cancellationToken
.
ThrowIfCancellationRequested
();
triviaFormatter
(
i
);
triviaFormatter
(
i
,
context
,
_formattingRules
,
tokenStream
,
cancellationToken
);
}
}
...
...
src/Workspaces/Core/Portable/Formatting/Engine/AbstractTriviaDataFactory.FormattedWhitespace.cs
浏览文件 @
b43cc84c
...
...
@@ -69,7 +69,7 @@ public override TriviaData WithIndentation(int indentation, FormattingContext co
}
public
override
void
Format
(
FormattingContext
context
,
ChainedFormattingRules
formattingRules
,
Action
<
int
,
T
riviaData
>
formattingResultApplier
,
CancellationToken
cancellationToken
,
int
tokenPairIndex
=
TokenPairIndexNotNeeded
)
FormattingContext
context
,
ChainedFormattingRules
formattingRules
,
Action
<
int
,
T
okenStream
,
TriviaData
>
formattingResultApplier
,
TokenStream
tokenStream
,
CancellationToken
cancellationToken
,
int
tokenPairIndex
=
TokenPairIndexNotNeeded
)
{
throw
new
NotImplementedException
();
}
...
...
src/Workspaces/Core/Portable/Formatting/Engine/AbstractTriviaDataFactory.ModifiedWhitespace.cs
浏览文件 @
b43cc84c
...
...
@@ -77,11 +77,12 @@ public override TriviaData WithLine(int line, int indentation, FormattingContext
public
override
void
Format
(
FormattingContext
context
,
ChainedFormattingRules
formattingRules
,
Action
<
int
,
TriviaData
>
formattingResultApplier
,
Action
<
int
,
TokenStream
,
TriviaData
>
formattingResultApplier
,
TokenStream
tokenStream
,
CancellationToken
cancellationToken
,
int
tokenPairIndex
=
TokenPairIndexNotNeeded
)
{
formattingResultApplier
(
tokenPairIndex
,
new
FormattedWhitespace
(
this
.
OptionSet
,
this
.
LineBreaks
,
this
.
Spaces
,
this
.
Language
));
formattingResultApplier
(
tokenPairIndex
,
tokenStream
,
new
FormattedWhitespace
(
this
.
OptionSet
,
this
.
LineBreaks
,
this
.
Spaces
,
this
.
Language
));
}
}
}
...
...
src/Workspaces/Core/Portable/Formatting/Engine/AbstractTriviaDataFactory.Whitespace.cs
浏览文件 @
b43cc84c
...
...
@@ -78,7 +78,8 @@ public override TriviaData WithLine(int line, int indentation, FormattingContext
public
override
void
Format
(
FormattingContext
context
,
ChainedFormattingRules
formattingRules
,
Action
<
int
,
TriviaData
>
formattingResultApplier
,
Action
<
int
,
TokenStream
,
TriviaData
>
formattingResultApplier
,
TokenStream
tokenStream
,
CancellationToken
cancellationToken
,
int
tokenPairIndex
=
TokenPairIndexNotNeeded
)
{
...
...
src/Workspaces/Core/Portable/Formatting/Engine/TriviaData.cs
浏览文件 @
b43cc84c
...
...
@@ -49,7 +49,8 @@ protected TriviaData(OptionSet optionSet, string language)
public
abstract
void
Format
(
FormattingContext
context
,
ChainedFormattingRules
formattingRules
,
Action
<
int
,
TriviaData
>
formattingResultApplier
,
Action
<
int
,
TokenStream
,
TriviaData
>
formattingResultApplier
,
TokenStream
tokenStream
,
CancellationToken
cancellationToken
,
int
tokenPairIndex
=
TokenPairIndexNotNeeded
);
}
...
...
src/Workspaces/VisualBasic/Portable/Formatting/Engine/Trivia/TriviaDataFactory.AbstractLineBreakTrivia.vb
浏览文件 @
b43cc84c
...
...
@@ -57,11 +57,12 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Formatting
Public
Overrides
Sub
Format
(
context
As
FormattingContext
,
formattingRules
As
ChainedFormattingRules
,
formattingResultApplier
As
Action
(
Of
Integer
,
TriviaData
),
formattingResultApplier
As
Action
(
Of
Integer
,
TokenStream
,
TriviaData
),
tokenStream
As
TokenStream
,
cancellationToken
As
CancellationToken
,
Optional
tokenPairIndex
As
Integer
=
TokenPairIndexNotNeeded
)
If
Me
.
ContainsChanges
Then
formattingResultApplier
(
tokenPairIndex
,
Me
)
formattingResultApplier
(
tokenPairIndex
,
tokenStream
,
Me
)
End
If
End
Sub
End
Class
...
...
src/Workspaces/VisualBasic/Portable/Formatting/Engine/Trivia/TriviaDataFactory.ComplexTrivia.vb
浏览文件 @
b43cc84c
...
...
@@ -90,14 +90,15 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Formatting
Public
Overrides
Sub
Format
(
context
As
FormattingContext
,
formattingRules
As
ChainedFormattingRules
,
formattingResultApplier
As
Action
(
Of
Integer
,
TriviaData
),
formattingResultApplier
As
Action
(
Of
Integer
,
TokenStream
,
TriviaData
),
tokenStream
As
TokenStream
,
cancellationToken
As
CancellationToken
,
Optional
tokenPairIndex
As
Integer
=
TokenPairIndexNotNeeded
)
If
Not
ShouldFormat
(
context
)
Then
Return
End
If
formattingResultApplier
(
tokenPairIndex
,
Format
(
context
,
formattingRules
,
Me
.
LineBreaks
,
Me
.
Spaces
,
cancellationToken
))
formattingResultApplier
(
tokenPairIndex
,
tokenStream
,
Format
(
context
,
formattingRules
,
Me
.
LineBreaks
,
Me
.
Spaces
,
cancellationToken
))
End
Sub
Public
Overrides
Function
GetTextChanges
(
span
As
TextSpan
)
As
IEnumerable
(
Of
TextChange
)
...
...
src/Workspaces/VisualBasic/Portable/Formatting/Engine/Trivia/TriviaDataFactory.FormattedComplexTrivia.vb
浏览文件 @
b43cc84c
...
...
@@ -63,7 +63,8 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Formatting
Public
Overrides
Sub
Format
(
context
As
FormattingContext
,
formattingRules
As
ChainedFormattingRules
,
formattingResultApplier
As
Action
(
Of
Integer
,
TriviaData
),
formattingResultApplier
As
Action
(
Of
Integer
,
TokenStream
,
TriviaData
),
tokenStream
As
TokenStream
,
cancellationToken
As
CancellationToken
,
Optional
tokenPairIndex
As
Integer
=
TokenPairIndexNotNeeded
)
Throw
New
NotImplementedException
()
...
...
src/Workspaces/VisualBasic/Portable/Formatting/Engine/Trivia/TriviaDataFactory.ModifiedComplexTrivia.vb
浏览文件 @
b43cc84c
...
...
@@ -69,7 +69,8 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Formatting
Public
Overrides
Sub
Format
(
context
As
FormattingContext
,
formattingRules
As
ChainedFormattingRules
,
formattingResultApplier
As
Action
(
Of
Integer
,
TriviaData
),
formattingResultApplier
As
Action
(
Of
Integer
,
TokenStream
,
TriviaData
),
tokenStream
As
TokenStream
,
cancellationToken
As
CancellationToken
,
Optional
tokenPairIndex
As
Integer
=
TokenPairIndexNotNeeded
)
Contract
.
ThrowIfFalse
(
Me
.
SecondTokenIsFirstTokenOnLine
)
...
...
@@ -87,6 +88,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Formatting
formattingResultApplier
(
tokenPairIndex
,
tokenStream
,
New
FormattedComplexTrivia
(
context
,
formattingRules
,
Me
.
_original
.
Token1
,
Me
.
_original
.
Token2
,
Me
.
LineBreaks
,
Me
.
Spaces
,
Me
.
_original
.
OriginalString
,
cancellationToken
))
End
Sub
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录