Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
4c467bf6
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,发现更多精彩内容 >>
提交
4c467bf6
编写于
1月 29, 2019
作者:
S
Sam Harwell
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Pass NextOperation and OperationCache by reference
上级
f7f993f3
变更
34
隐藏空白更改
内联
并排
Showing
34 changed file
with
72 addition
and
69 deletion
+72
-69
src/EditorFeatures/CSharp/AutomaticCompletion/Sessions/CurlyBraceCompletionSession.cs
...tomaticCompletion/Sessions/CurlyBraceCompletionSession.cs
+2
-2
src/EditorFeatures/CSharp/Formatting/CSharpEditorFormattingService.PasteFormattingRule.cs
...ting/CSharpEditorFormattingService.PasteFormattingRule.cs
+1
-1
src/EditorFeatures/CSharp/Formatting/Indentation/SmartTokenFormatter.cs
...ures/CSharp/Formatting/Indentation/SmartTokenFormatter.cs
+4
-4
src/EditorFeatures/VisualBasic/Formatting/Indentation/SpecialFormattingOperation.vb
...asic/Formatting/Indentation/SpecialFormattingOperation.vb
+2
-2
src/EditorFeatures/VisualBasic/Utilities/LineAdjustmentFormattingRule.vb
...res/VisualBasic/Utilities/LineAdjustmentFormattingRule.vb
+1
-1
src/Features/CSharp/Portable/ChangeSignature/ChangeSignatureFormattingRule.cs
...Portable/ChangeSignature/ChangeSignatureFormattingRule.cs
+2
-2
src/Features/CSharp/Portable/ExtractMethod/CSharpMethodExtractor.FormattingProvider.cs
...ExtractMethod/CSharpMethodExtractor.FormattingProvider.cs
+2
-2
src/Features/CSharp/Portable/UseAutoProperty/CSharpUseAutoPropertyCodeFixProvider.cs
...e/UseAutoProperty/CSharpUseAutoPropertyCodeFixProvider.cs
+4
-4
src/Features/CSharp/Portable/UseConditionalExpression/MultiLineConditionalExpressionFormattingRule.cs
...xpression/MultiLineConditionalExpressionFormattingRule.cs
+1
-1
src/Features/Core/Portable/CodeRefactorings/AddMissingImports/AbstractAddMissingImportsFeatureService.cs
...MissingImports/AbstractAddMissingImportsFeatureService.cs
+1
-1
src/Features/Core/Portable/GenerateEqualsAndGetHashCodeFromMembers/FormatLargeBinaryExpressionRule.cs
...GetHashCodeFromMembers/FormatLargeBinaryExpressionRule.cs
+1
-1
src/Features/Core/Portable/MetadataAsSource/AbstractMetadataAsSourceService.AbstractMetadataFormattingRule.cs
...MetadataAsSourceService.AbstractMetadataFormattingRule.cs
+1
-1
src/Features/VisualBasic/Portable/ChangeSignature/ChangeSignatureFormattingRule.vb
...Portable/ChangeSignature/ChangeSignatureFormattingRule.vb
+1
-1
src/Features/VisualBasic/Portable/ExtractMethod/VisualBasicMethodExtractor.vb
...asic/Portable/ExtractMethod/VisualBasicMethodExtractor.vb
+1
-1
src/Features/VisualBasic/Portable/UseConditionalExpression/MultiLineConditionalExpressionFormattingRule.vb
...xpression/MultiLineConditionalExpressionFormattingRule.vb
+1
-1
src/VisualStudio/CSharp/Impl/CodeModel/EndRegionFormattingRule.cs
...alStudio/CSharp/Impl/CodeModel/EndRegionFormattingRule.cs
+1
-1
src/VisualStudio/CSharp/Impl/Utilities/BlankLineInGeneratedMethodFormattingRule.cs
...mpl/Utilities/BlankLineInGeneratedMethodFormattingRule.cs
+1
-1
src/VisualStudio/Core/Def/Implementation/Venus/ContainedDocumentPreserveFormattingRule.cs
...entation/Venus/ContainedDocumentPreserveFormattingRule.cs
+4
-4
src/Workspaces/CSharp/Portable/Formatting/DefaultOperationProvider.cs
...es/CSharp/Portable/Formatting/DefaultOperationProvider.cs
+2
-2
src/Workspaces/CSharp/Portable/Formatting/Rules/ElasticTriviaFormattingRule.cs
.../Portable/Formatting/Rules/ElasticTriviaFormattingRule.cs
+2
-2
src/Workspaces/CSharp/Portable/Formatting/Rules/EndOfFileTokenFormattingRule.cs
...Portable/Formatting/Rules/EndOfFileTokenFormattingRule.cs
+2
-2
src/Workspaces/CSharp/Portable/Formatting/Rules/NewLineUserSettingFormattingRule.cs
...able/Formatting/Rules/NewLineUserSettingFormattingRule.cs
+2
-2
src/Workspaces/CSharp/Portable/Formatting/Rules/QueryExpressionFormattingRule.cs
...ortable/Formatting/Rules/QueryExpressionFormattingRule.cs
+1
-1
src/Workspaces/CSharp/Portable/Formatting/Rules/SpacingFormattingRule.cs
...CSharp/Portable/Formatting/Rules/SpacingFormattingRule.cs
+1
-1
src/Workspaces/CSharp/Portable/Formatting/Rules/StructuredTriviaFormattingRule.cs
...rtable/Formatting/Rules/StructuredTriviaFormattingRule.cs
+4
-4
src/Workspaces/CSharp/Portable/Formatting/Rules/TokenBasedFormattingRule.cs
...arp/Portable/Formatting/Rules/TokenBasedFormattingRule.cs
+2
-2
src/Workspaces/Core/Portable/Formatting/Engine/ChainedFormattingRules.cs
...Core/Portable/Formatting/Engine/ChainedFormattingRules.cs
+4
-4
src/Workspaces/Core/Portable/Formatting/Engine/OperationCache`1.cs
...paces/Core/Portable/Formatting/Engine/OperationCache`1.cs
+7
-4
src/Workspaces/Core/Portable/Formatting/Rules/AbstractFormattingRule.cs
.../Core/Portable/Formatting/Rules/AbstractFormattingRule.cs
+2
-2
src/Workspaces/Core/Portable/Formatting/Rules/NextOperation`1.cs
...kspaces/Core/Portable/Formatting/Rules/NextOperation`1.cs
+5
-5
src/Workspaces/VisualBasic/Portable/Formatting/DefaultOperationProvider.vb
...sualBasic/Portable/Formatting/DefaultOperationProvider.vb
+2
-2
src/Workspaces/VisualBasic/Portable/Formatting/Rules/AdjustSpaceFormattingRule.vb
...ic/Portable/Formatting/Rules/AdjustSpaceFormattingRule.vb
+1
-1
src/Workspaces/VisualBasic/Portable/Formatting/Rules/ElasticTriviaFormattingRule.vb
.../Portable/Formatting/Rules/ElasticTriviaFormattingRule.vb
+2
-2
src/Workspaces/VisualBasic/Portable/Formatting/Rules/StructuredTriviaFormattingRule.vb
...rtable/Formatting/Rules/StructuredTriviaFormattingRule.vb
+2
-2
未找到文件。
src/EditorFeatures/CSharp/AutomaticCompletion/Sessions/CurlyBraceCompletionSession.cs
浏览文件 @
4c467bf6
...
...
@@ -197,7 +197,7 @@ private class BraceCompletionFormattingRule : BaseFormattingRule
public
static
readonly
AbstractFormattingRule
Instance
=
new
BraceCompletionFormattingRule
();
public
override
AdjustNewLinesOperation
GetAdjustNewLinesOperation
(
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
OptionSet
optionSet
,
NextOperation
<
AdjustNewLinesOperation
>
nextOperation
)
public
override
AdjustNewLinesOperation
GetAdjustNewLinesOperation
(
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
OptionSet
optionSet
,
ref
NextOperation
<
AdjustNewLinesOperation
>
nextOperation
)
{
// Eg Cases -
// new MyObject {
...
...
@@ -221,7 +221,7 @@ public override AdjustNewLinesOperation GetAdjustNewLinesOperation(SyntaxToken p
}
}
return
base
.
GetAdjustNewLinesOperation
(
previousToken
,
currentToken
,
optionSet
,
nextOperation
);
return
base
.
GetAdjustNewLinesOperation
(
previousToken
,
currentToken
,
optionSet
,
ref
nextOperation
);
}
public
override
void
AddAlignTokensOperations
(
List
<
AlignTokensOperation
>
list
,
SyntaxNode
node
,
OptionSet
optionSet
,
NextAction
<
AlignTokensOperation
>
nextOperation
)
...
...
src/EditorFeatures/CSharp/Formatting/CSharpEditorFormattingService.PasteFormattingRule.cs
浏览文件 @
4c467bf6
...
...
@@ -10,7 +10,7 @@ internal partial class CSharpEditorFormattingService : IEditorFormattingService
{
internal
class
PasteFormattingRule
:
AbstractFormattingRule
{
public
override
AdjustNewLinesOperation
GetAdjustNewLinesOperation
(
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
OptionSet
optionSet
,
NextOperation
<
AdjustNewLinesOperation
>
nextOperation
)
public
override
AdjustNewLinesOperation
GetAdjustNewLinesOperation
(
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
OptionSet
optionSet
,
ref
NextOperation
<
AdjustNewLinesOperation
>
nextOperation
)
{
if
(
currentToken
.
Parent
!=
null
)
{
...
...
src/EditorFeatures/CSharp/Formatting/Indentation/SmartTokenFormatter.cs
浏览文件 @
4c467bf6
...
...
@@ -118,10 +118,10 @@ private bool CloseBraceOfTryOrDoBlock(SyntaxToken endToken)
private
class
NoLineChangeFormattingRule
:
AbstractFormattingRule
{
public
override
AdjustNewLinesOperation
GetAdjustNewLinesOperation
(
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
OptionSet
optionSet
,
NextOperation
<
AdjustNewLinesOperation
>
nextOperation
)
public
override
AdjustNewLinesOperation
GetAdjustNewLinesOperation
(
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
OptionSet
optionSet
,
ref
NextOperation
<
AdjustNewLinesOperation
>
nextOperation
)
{
// no line operation. no line changes what so ever
var
lineOperation
=
base
.
GetAdjustNewLinesOperation
(
previousToken
,
currentToken
,
optionSet
,
nextOperation
);
var
lineOperation
=
base
.
GetAdjustNewLinesOperation
(
previousToken
,
currentToken
,
optionSet
,
ref
nextOperation
);
if
(
lineOperation
!=
null
)
{
// ignore force if same line option
...
...
@@ -146,9 +146,9 @@ public override void AddSuppressOperations(List<SuppressOperation> list, SyntaxN
// don't suppress anything
}
public
override
AdjustSpacesOperation
GetAdjustSpacesOperation
(
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
OptionSet
optionSet
,
NextOperation
<
AdjustSpacesOperation
>
nextOperation
)
public
override
AdjustSpacesOperation
GetAdjustSpacesOperation
(
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
OptionSet
optionSet
,
ref
NextOperation
<
AdjustSpacesOperation
>
nextOperation
)
{
var
spaceOperation
=
base
.
GetAdjustSpacesOperation
(
previousToken
,
currentToken
,
optionSet
,
nextOperation
);
var
spaceOperation
=
base
.
GetAdjustSpacesOperation
(
previousToken
,
currentToken
,
optionSet
,
ref
nextOperation
);
// if there is force space operation, convert it to ForceSpaceIfSingleLine operation.
// (force space basically means remove all line breaks)
...
...
src/EditorFeatures/VisualBasic/Formatting/Indentation/SpecialFormattingOperation.vb
浏览文件 @
4c467bf6
...
...
@@ -19,7 +19,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.Formatting.Indentation
' don't suppress anything
End
Sub
Public
Overrides
Function
GetAdjustNewLinesOperation
(
previousToken
As
SyntaxToken
,
currentToken
As
SyntaxToken
,
optionSet
As
OptionSet
,
nextOperation
As
NextOperation
(
Of
AdjustNewLinesOperation
))
As
AdjustNewLinesOperation
Public
Overrides
Function
GetAdjustNewLinesOperation
(
previousToken
As
SyntaxToken
,
currentToken
As
SyntaxToken
,
optionSet
As
OptionSet
,
ByRef
nextOperation
As
NextOperation
(
Of
AdjustNewLinesOperation
))
As
AdjustNewLinesOperation
' unlike regular one. force position of attribute
Dim
attributeNode
=
TryCast
(
previousToken
.
Parent
,
AttributeListSyntax
)
...
...
@@ -38,7 +38,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.Formatting.Indentation
Return
Nothing
End
Function
Public
Overrides
Function
GetAdjustSpacesOperation
(
previousToken
As
SyntaxToken
,
currentToken
As
SyntaxToken
,
optionSet
As
OptionSet
,
nextOperation
As
NextOperation
(
Of
AdjustSpacesOperation
))
As
AdjustSpacesOperation
Public
Overrides
Function
GetAdjustSpacesOperation
(
previousToken
As
SyntaxToken
,
currentToken
As
SyntaxToken
,
optionSet
As
OptionSet
,
ByRef
nextOperation
As
NextOperation
(
Of
AdjustSpacesOperation
))
As
AdjustSpacesOperation
Dim
spaceOperation
=
MyBase
.
GetAdjustSpacesOperation
(
previousToken
,
currentToken
,
optionSet
,
nextOperation
)
' if there is force space operation, convert it to ForceSpaceIfSingleLine operation.
...
...
src/EditorFeatures/VisualBasic/Utilities/LineAdjustmentFormattingRule.vb
浏览文件 @
4c467bf6
...
...
@@ -15,7 +15,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.Utilities
Private
Sub
New
()
End
Sub
Public
Overrides
Function
GetAdjustNewLinesOperation
(
previousToken
As
SyntaxToken
,
currentToken
As
SyntaxToken
,
optionSet
As
OptionSet
,
nextOperation
As
NextOperation
(
Of
AdjustNewLinesOperation
))
As
AdjustNewLinesOperation
Public
Overrides
Function
GetAdjustNewLinesOperation
(
previousToken
As
SyntaxToken
,
currentToken
As
SyntaxToken
,
optionSet
As
OptionSet
,
ByRef
nextOperation
As
NextOperation
(
Of
AdjustNewLinesOperation
))
As
AdjustNewLinesOperation
If
Not
CommonFormattingHelpers
.
HasAnyWhitespaceElasticTrivia
(
previousToken
,
currentToken
)
Then
Return
nextOperation
.
Invoke
()
End
If
...
...
src/Features/CSharp/Portable/ChangeSignature/ChangeSignatureFormattingRule.cs
浏览文件 @
4c467bf6
...
...
@@ -44,14 +44,14 @@ private void AddChangeSignatureIndentOperation(List<IndentBlockOperation> list,
}
}
public
override
AdjustNewLinesOperation
GetAdjustNewLinesOperation
(
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
OptionSet
optionSet
,
NextOperation
<
AdjustNewLinesOperation
>
nextOperation
)
public
override
AdjustNewLinesOperation
GetAdjustNewLinesOperation
(
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
OptionSet
optionSet
,
ref
NextOperation
<
AdjustNewLinesOperation
>
nextOperation
)
{
if
(
previousToken
.
Kind
()
==
SyntaxKind
.
CommaToken
&&
s_allowableKinds
.
Contains
(
previousToken
.
Parent
.
Kind
()))
{
return
FormattingOperations
.
CreateAdjustNewLinesOperation
(
0
,
AdjustNewLinesOption
.
PreserveLines
);
}
return
base
.
GetAdjustNewLinesOperation
(
previousToken
,
currentToken
,
optionSet
,
nextOperation
);
return
base
.
GetAdjustNewLinesOperation
(
previousToken
,
currentToken
,
optionSet
,
ref
nextOperation
);
}
}
}
src/Features/CSharp/Portable/ExtractMethod/CSharpMethodExtractor.FormattingProvider.cs
浏览文件 @
4c467bf6
...
...
@@ -15,10 +15,10 @@ public FormattingRule()
{
}
public
override
AdjustNewLinesOperation
GetAdjustNewLinesOperation
(
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
OptionSet
optionSet
,
NextOperation
<
AdjustNewLinesOperation
>
nextOperation
)
public
override
AdjustNewLinesOperation
GetAdjustNewLinesOperation
(
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
OptionSet
optionSet
,
ref
NextOperation
<
AdjustNewLinesOperation
>
nextOperation
)
{
// for extract method case, for a hybrid case, don't force rule, but preserve user style
var
operation
=
base
.
GetAdjustNewLinesOperation
(
previousToken
,
currentToken
,
optionSet
,
nextOperation
);
var
operation
=
base
.
GetAdjustNewLinesOperation
(
previousToken
,
currentToken
,
optionSet
,
ref
nextOperation
);
if
(
operation
==
null
)
{
return
null
;
...
...
src/Features/CSharp/Portable/UseAutoProperty/CSharpUseAutoPropertyCodeFixProvider.cs
浏览文件 @
4c467bf6
...
...
@@ -96,24 +96,24 @@ private bool ForceSingleSpace(SyntaxToken previousToken, SyntaxToken currentToke
return
false
;
}
public
override
AdjustNewLinesOperation
GetAdjustNewLinesOperation
(
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
OptionSet
optionSet
,
NextOperation
<
AdjustNewLinesOperation
>
nextOperation
)
public
override
AdjustNewLinesOperation
GetAdjustNewLinesOperation
(
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
OptionSet
optionSet
,
ref
NextOperation
<
AdjustNewLinesOperation
>
nextOperation
)
{
if
(
ForceSingleSpace
(
previousToken
,
currentToken
))
{
return
null
;
}
return
base
.
GetAdjustNewLinesOperation
(
previousToken
,
currentToken
,
optionSet
,
nextOperation
);
return
base
.
GetAdjustNewLinesOperation
(
previousToken
,
currentToken
,
optionSet
,
ref
nextOperation
);
}
public
override
AdjustSpacesOperation
GetAdjustSpacesOperation
(
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
OptionSet
optionSet
,
NextOperation
<
AdjustSpacesOperation
>
nextOperation
)
public
override
AdjustSpacesOperation
GetAdjustSpacesOperation
(
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
OptionSet
optionSet
,
ref
NextOperation
<
AdjustSpacesOperation
>
nextOperation
)
{
if
(
ForceSingleSpace
(
previousToken
,
currentToken
))
{
return
new
AdjustSpacesOperation
(
1
,
AdjustSpacesOption
.
ForceSpaces
);
}
return
base
.
GetAdjustSpacesOperation
(
previousToken
,
currentToken
,
optionSet
,
nextOperation
);
return
base
.
GetAdjustSpacesOperation
(
previousToken
,
currentToken
,
optionSet
,
ref
nextOperation
);
}
}
...
...
src/Features/CSharp/Portable/UseConditionalExpression/MultiLineConditionalExpressionFormattingRule.cs
浏览文件 @
4c467bf6
...
...
@@ -40,7 +40,7 @@ private bool IsQuestionOrColonOfNewConditional(SyntaxToken token)
}
public
override
AdjustNewLinesOperation
GetAdjustNewLinesOperation
(
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
OptionSet
optionSet
,
NextOperation
<
AdjustNewLinesOperation
>
nextOperation
)
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
OptionSet
optionSet
,
ref
NextOperation
<
AdjustNewLinesOperation
>
nextOperation
)
{
if
(
IsQuestionOrColonOfNewConditional
(
currentToken
))
{
...
...
src/Features/Core/Portable/CodeRefactorings/AddMissingImports/AbstractAddMissingImportsFeatureService.cs
浏览文件 @
4c467bf6
...
...
@@ -243,7 +243,7 @@ public CleanUpNewLinesFormatter(SourceText text)
_text
=
text
;
}
public
override
AdjustNewLinesOperation
GetAdjustNewLinesOperation
(
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
OptionSet
optionSet
,
NextOperation
<
AdjustNewLinesOperation
>
nextOperation
)
public
override
AdjustNewLinesOperation
GetAdjustNewLinesOperation
(
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
OptionSet
optionSet
,
ref
NextOperation
<
AdjustNewLinesOperation
>
nextOperation
)
{
// Since we know the general shape of these new import statements, we simply look for where
// tokens are not on the same line and force them to only be separated by a single newline.
...
...
src/Features/Core/Portable/GenerateEqualsAndGetHashCodeFromMembers/FormatLargeBinaryExpressionRule.cs
浏览文件 @
4c467bf6
...
...
@@ -27,7 +27,7 @@ public FormatLargeBinaryExpressionRule(ISyntaxFactsService syntaxFacts)
/// Wrap the large && expression after every && token.
/// </summary>
public
override
AdjustNewLinesOperation
GetAdjustNewLinesOperation
(
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
OptionSet
optionSet
,
NextOperation
<
AdjustNewLinesOperation
>
nextOperation
)
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
OptionSet
optionSet
,
ref
NextOperation
<
AdjustNewLinesOperation
>
nextOperation
)
{
if
(
_syntaxFacts
.
IsLogicalAndExpression
(
previousToken
.
Parent
))
{
...
...
src/Features/Core/Portable/MetadataAsSource/AbstractMetadataAsSourceService.AbstractMetadataFormattingRule.cs
浏览文件 @
4c467bf6
...
...
@@ -16,7 +16,7 @@ protected abstract class AbstractMetadataFormattingRule : AbstractFormattingRule
protected
abstract
bool
IsNewLine
(
char
c
);
public
override
AdjustNewLinesOperation
GetAdjustNewLinesOperation
(
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
OptionSet
optionSet
,
NextOperation
<
AdjustNewLinesOperation
>
nextOperation
)
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
OptionSet
optionSet
,
ref
NextOperation
<
AdjustNewLinesOperation
>
nextOperation
)
{
if
(
previousToken
.
RawKind
==
0
||
currentToken
.
RawKind
==
0
)
{
...
...
src/Features/VisualBasic/Portable/ChangeSignature/ChangeSignatureFormattingRule.vb
浏览文件 @
4c467bf6
...
...
@@ -32,7 +32,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ChangeSignature
End
If
End
Sub
Public
Overrides
Function
GetAdjustNewLinesOperation
(
previousToken
As
SyntaxToken
,
currentToken
As
SyntaxToken
,
optionSet
As
OptionSet
,
nextOperation
As
NextOperation
(
Of
AdjustNewLinesOperation
))
As
AdjustNewLinesOperation
Public
Overrides
Function
GetAdjustNewLinesOperation
(
previousToken
As
SyntaxToken
,
currentToken
As
SyntaxToken
,
optionSet
As
OptionSet
,
ByRef
nextOperation
As
NextOperation
(
Of
AdjustNewLinesOperation
))
As
AdjustNewLinesOperation
If
previousToken
.
IsKind
(
SyntaxKind
.
CommaToken
)
AndAlso
(
previousToken
.
Parent
.
IsKind
(
SyntaxKind
.
ParameterList
)
OrElse
previousToken
.
Parent
.
IsKind
(
SyntaxKind
.
ArgumentList
))
Then
Return
FormattingOperations
.
CreateAdjustNewLinesOperation
(
0
,
AdjustNewLinesOption
.
PreserveLines
)
...
...
src/Features/VisualBasic/Portable/ExtractMethod/VisualBasicMethodExtractor.vb
浏览文件 @
4c467bf6
...
...
@@ -115,7 +115,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ExtractMethod
Private
Class
FormattingRule
Inherits
AbstractFormattingRule
Public
Overrides
Function
GetAdjustNewLinesOperation
(
previousToken
As
SyntaxToken
,
currentToken
As
SyntaxToken
,
optionSet
As
OptionSet
,
nextOperation
As
NextOperation
(
Of
AdjustNewLinesOperation
))
As
AdjustNewLinesOperation
Public
Overrides
Function
GetAdjustNewLinesOperation
(
previousToken
As
SyntaxToken
,
currentToken
As
SyntaxToken
,
optionSet
As
OptionSet
,
ByRef
nextOperation
As
NextOperation
(
Of
AdjustNewLinesOperation
))
As
AdjustNewLinesOperation
If
Not
previousToken
.
IsLastTokenOfStatement
()
Then
Return
nextOperation
.
Invoke
()
End
If
...
...
src/Features/VisualBasic/Portable/UseConditionalExpression/MultiLineConditionalExpressionFormattingRule.vb
浏览文件 @
4c467bf6
...
...
@@ -37,7 +37,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.UseConditionalExpression
End
Function
Public
Overrides
Function
GetAdjustNewLinesOperation
(
previousToken
As
SyntaxToken
,
currentToken
As
SyntaxToken
,
optionSet
As
OptionSet
,
nextOperation
As
NextOperation
(
Of
AdjustNewLinesOperation
))
As
AdjustNewLinesOperation
previousToken
As
SyntaxToken
,
currentToken
As
SyntaxToken
,
optionSet
As
OptionSet
,
ByRef
nextOperation
As
NextOperation
(
Of
AdjustNewLinesOperation
))
As
AdjustNewLinesOperation
If
IsCommaOfNewConditional
(
previousToken
)
Then
' We want to force the expressions after the commas to be put on the
' next line.
...
...
src/VisualStudio/CSharp/Impl/CodeModel/EndRegionFormattingRule.cs
浏览文件 @
4c467bf6
...
...
@@ -26,7 +26,7 @@ private bool IsAfterEndRegionBeforeMethodDeclaration(SyntaxToken previousToken,
return
false
;
}
public
override
AdjustNewLinesOperation
GetAdjustNewLinesOperation
(
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
OptionSet
optionSet
,
NextOperation
<
AdjustNewLinesOperation
>
nextOperation
)
public
override
AdjustNewLinesOperation
GetAdjustNewLinesOperation
(
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
OptionSet
optionSet
,
ref
NextOperation
<
AdjustNewLinesOperation
>
nextOperation
)
{
if
(
IsAfterEndRegionBeforeMethodDeclaration
(
previousToken
,
currentToken
))
{
...
...
src/VisualStudio/CSharp/Impl/Utilities/BlankLineInGeneratedMethodFormattingRule.cs
浏览文件 @
4c467bf6
...
...
@@ -15,7 +15,7 @@ private BlankLineInGeneratedMethodFormattingRule()
{
}
public
override
AdjustNewLinesOperation
GetAdjustNewLinesOperation
(
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
OptionSet
optionSet
,
NextOperation
<
AdjustNewLinesOperation
>
nextOperation
)
public
override
AdjustNewLinesOperation
GetAdjustNewLinesOperation
(
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
OptionSet
optionSet
,
ref
NextOperation
<
AdjustNewLinesOperation
>
nextOperation
)
{
// case: insert blank line in empty method body.
if
(
previousToken
.
Kind
()
==
SyntaxKind
.
OpenBraceToken
&&
...
...
src/VisualStudio/Core/Def/Implementation/Venus/ContainedDocumentPreserveFormattingRule.cs
浏览文件 @
4c467bf6
...
...
@@ -13,9 +13,9 @@ internal class ContainedDocumentPreserveFormattingRule : AbstractFormattingRule
private
static
readonly
AdjustSpacesOperation
s_preserveSpace
=
FormattingOperations
.
CreateAdjustSpacesOperation
(
0
,
AdjustSpacesOption
.
PreserveSpaces
);
private
static
readonly
AdjustNewLinesOperation
s_preserveLine
=
FormattingOperations
.
CreateAdjustNewLinesOperation
(
0
,
AdjustNewLinesOption
.
PreserveLines
);
public
override
AdjustSpacesOperation
GetAdjustSpacesOperation
(
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
OptionSet
optionSet
,
NextOperation
<
AdjustSpacesOperation
>
nextOperation
)
public
override
AdjustSpacesOperation
GetAdjustSpacesOperation
(
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
OptionSet
optionSet
,
ref
NextOperation
<
AdjustSpacesOperation
>
nextOperation
)
{
var
operation
=
base
.
GetAdjustSpacesOperation
(
previousToken
,
currentToken
,
optionSet
,
nextOperation
);
var
operation
=
base
.
GetAdjustSpacesOperation
(
previousToken
,
currentToken
,
optionSet
,
ref
nextOperation
);
if
(
operation
!=
null
)
{
return
s_preserveSpace
;
...
...
@@ -24,9 +24,9 @@ public override AdjustSpacesOperation GetAdjustSpacesOperation(SyntaxToken previ
return
operation
;
}
public
override
AdjustNewLinesOperation
GetAdjustNewLinesOperation
(
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
OptionSet
optionSet
,
NextOperation
<
AdjustNewLinesOperation
>
nextOperation
)
public
override
AdjustNewLinesOperation
GetAdjustNewLinesOperation
(
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
OptionSet
optionSet
,
ref
NextOperation
<
AdjustNewLinesOperation
>
nextOperation
)
{
var
operation
=
base
.
GetAdjustNewLinesOperation
(
previousToken
,
currentToken
,
optionSet
,
nextOperation
);
var
operation
=
base
.
GetAdjustNewLinesOperation
(
previousToken
,
currentToken
,
optionSet
,
ref
nextOperation
);
if
(
operation
!=
null
)
{
return
s_preserveLine
;
...
...
src/Workspaces/CSharp/Portable/Formatting/DefaultOperationProvider.cs
浏览文件 @
4c467bf6
...
...
@@ -34,13 +34,13 @@ public override void AddAlignTokensOperations(List<AlignTokensOperation> list, S
{
}
public
override
AdjustNewLinesOperation
GetAdjustNewLinesOperation
(
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
OptionSet
optionSet
,
NextOperation
<
AdjustNewLinesOperation
>
nextOperation
)
public
override
AdjustNewLinesOperation
GetAdjustNewLinesOperation
(
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
OptionSet
optionSet
,
ref
NextOperation
<
AdjustNewLinesOperation
>
nextOperation
)
{
return
null
;
}
// return 1 space for every token pairs as a default operation
public
override
AdjustSpacesOperation
GetAdjustSpacesOperation
(
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
OptionSet
optionSet
,
NextOperation
<
AdjustSpacesOperation
>
nextOperation
)
public
override
AdjustSpacesOperation
GetAdjustSpacesOperation
(
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
OptionSet
optionSet
,
ref
NextOperation
<
AdjustSpacesOperation
>
nextOperation
)
{
int
space
=
currentToken
.
Kind
()
==
SyntaxKind
.
EndOfFileToken
?
0
:
1
;
return
FormattingOperations
.
CreateAdjustSpacesOperation
(
space
,
AdjustSpacesOption
.
DefaultSpacesIfOnSingleLine
);
...
...
src/Workspaces/CSharp/Portable/Formatting/Rules/ElasticTriviaFormattingRule.cs
浏览文件 @
4c467bf6
...
...
@@ -96,7 +96,7 @@ private InitializerExpressionSyntax GetInitializerNode(SyntaxNode node)
return
null
;
}
public
override
AdjustNewLinesOperation
GetAdjustNewLinesOperation
(
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
OptionSet
optionSet
,
NextOperation
<
AdjustNewLinesOperation
>
nextOperation
)
public
override
AdjustNewLinesOperation
GetAdjustNewLinesOperation
(
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
OptionSet
optionSet
,
ref
NextOperation
<
AdjustNewLinesOperation
>
nextOperation
)
{
var
operation
=
nextOperation
.
Invoke
();
if
(
operation
==
null
)
...
...
@@ -218,7 +218,7 @@ private AdjustNewLinesOperation GetAdjustNewLinesOperationBetweenMembers(SyntaxT
return
FormattingOperations
.
CreateAdjustNewLinesOperation
(
2
/* +1 for member itself and +1 for a blank line*/
,
AdjustNewLinesOption
.
ForceLines
);
}
public
override
AdjustSpacesOperation
GetAdjustSpacesOperation
(
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
OptionSet
optionSet
,
NextOperation
<
AdjustSpacesOperation
>
nextOperation
)
public
override
AdjustSpacesOperation
GetAdjustSpacesOperation
(
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
OptionSet
optionSet
,
ref
NextOperation
<
AdjustSpacesOperation
>
nextOperation
)
{
var
operation
=
nextOperation
.
Invoke
();
if
(
operation
==
null
)
...
...
src/Workspaces/CSharp/Portable/Formatting/Rules/EndOfFileTokenFormattingRule.cs
浏览文件 @
4c467bf6
...
...
@@ -9,7 +9,7 @@ internal class EndOfFileTokenFormattingRule : BaseFormattingRule
{
internal
const
string
Name
=
"CSharp End Of File Token Formatting Rule"
;
public
override
AdjustNewLinesOperation
GetAdjustNewLinesOperation
(
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
OptionSet
optionSet
,
NextOperation
<
AdjustNewLinesOperation
>
nextOperation
)
public
override
AdjustNewLinesOperation
GetAdjustNewLinesOperation
(
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
OptionSet
optionSet
,
ref
NextOperation
<
AdjustNewLinesOperation
>
nextOperation
)
{
// * <End Of File> case for C#, make sure we don't insert new line between * and <End of
// File> tokens.
...
...
@@ -21,7 +21,7 @@ public override AdjustNewLinesOperation GetAdjustNewLinesOperation(SyntaxToken p
return
nextOperation
.
Invoke
();
}
public
override
AdjustSpacesOperation
GetAdjustSpacesOperation
(
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
OptionSet
optionSet
,
NextOperation
<
AdjustSpacesOperation
>
nextOperation
)
public
override
AdjustSpacesOperation
GetAdjustSpacesOperation
(
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
OptionSet
optionSet
,
ref
NextOperation
<
AdjustSpacesOperation
>
nextOperation
)
{
// * <End Of File) case
// for C#, make sure we have nothing between these two tokens
...
...
src/Workspaces/CSharp/Portable/Formatting/Rules/NewLineUserSettingFormattingRule.cs
浏览文件 @
4c467bf6
...
...
@@ -45,7 +45,7 @@ private bool IsControlBlock(SyntaxNode node)
}
}
public
override
AdjustSpacesOperation
GetAdjustSpacesOperation
(
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
OptionSet
optionSet
,
NextOperation
<
AdjustSpacesOperation
>
nextOperation
)
public
override
AdjustSpacesOperation
GetAdjustSpacesOperation
(
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
OptionSet
optionSet
,
ref
NextOperation
<
AdjustSpacesOperation
>
nextOperation
)
{
var
operation
=
nextOperation
.
Invoke
();
...
...
@@ -166,7 +166,7 @@ public override AdjustSpacesOperation GetAdjustSpacesOperation(SyntaxToken previ
return
operation
;
}
public
override
AdjustNewLinesOperation
GetAdjustNewLinesOperation
(
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
OptionSet
optionSet
,
NextOperation
<
AdjustNewLinesOperation
>
nextOperation
)
public
override
AdjustNewLinesOperation
GetAdjustNewLinesOperation
(
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
OptionSet
optionSet
,
ref
NextOperation
<
AdjustNewLinesOperation
>
nextOperation
)
{
var
operation
=
nextOperation
.
Invoke
();
...
...
src/Workspaces/CSharp/Portable/Formatting/Rules/QueryExpressionFormattingRule.cs
浏览文件 @
4c467bf6
...
...
@@ -105,7 +105,7 @@ public override void AddAnchorIndentationOperations(List<AnchorIndentationOperat
}
}
public
override
AdjustNewLinesOperation
GetAdjustNewLinesOperation
(
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
OptionSet
optionSet
,
NextOperation
<
AdjustNewLinesOperation
>
nextOperation
)
public
override
AdjustNewLinesOperation
GetAdjustNewLinesOperation
(
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
OptionSet
optionSet
,
ref
NextOperation
<
AdjustNewLinesOperation
>
nextOperation
)
{
if
(
previousToken
.
IsNestedQueryExpression
())
{
...
...
src/Workspaces/CSharp/Portable/Formatting/Rules/SpacingFormattingRule.cs
浏览文件 @
4c467bf6
...
...
@@ -11,7 +11,7 @@ namespace Microsoft.CodeAnalysis.CSharp.Formatting
{
internal
class
SpacingFormattingRule
:
BaseFormattingRule
{
public
override
AdjustSpacesOperation
GetAdjustSpacesOperation
(
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
OptionSet
optionSet
,
NextOperation
<
AdjustSpacesOperation
>
nextOperation
)
public
override
AdjustSpacesOperation
GetAdjustSpacesOperation
(
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
OptionSet
optionSet
,
ref
NextOperation
<
AdjustSpacesOperation
>
nextOperation
)
{
if
(
optionSet
==
null
)
{
...
...
src/Workspaces/CSharp/Portable/Formatting/Rules/StructuredTriviaFormattingRule.cs
浏览文件 @
4c467bf6
...
...
@@ -10,7 +10,7 @@ internal class StructuredTriviaFormattingRule : BaseFormattingRule
{
internal
const
string
Name
=
"CSharp Structured Trivia Formatting Rule"
;
public
override
AdjustNewLinesOperation
GetAdjustNewLinesOperation
(
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
OptionSet
optionSet
,
NextOperation
<
AdjustNewLinesOperation
>
nextOperation
)
public
override
AdjustNewLinesOperation
GetAdjustNewLinesOperation
(
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
OptionSet
optionSet
,
ref
NextOperation
<
AdjustNewLinesOperation
>
nextOperation
)
{
if
(
previousToken
.
Parent
is
StructuredTriviaSyntax
||
currentToken
.
Parent
is
StructuredTriviaSyntax
)
{
...
...
@@ -20,18 +20,18 @@ public override AdjustNewLinesOperation GetAdjustNewLinesOperation(SyntaxToken p
return
nextOperation
.
Invoke
();
}
public
override
AdjustSpacesOperation
GetAdjustSpacesOperation
(
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
OptionSet
optionSet
,
NextOperation
<
AdjustSpacesOperation
>
nextOperation
)
public
override
AdjustSpacesOperation
GetAdjustSpacesOperation
(
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
OptionSet
optionSet
,
ref
NextOperation
<
AdjustSpacesOperation
>
nextOperation
)
{
if
(
previousToken
.
Parent
is
StructuredTriviaSyntax
||
currentToken
.
Parent
is
StructuredTriviaSyntax
)
{
// this doesn't take care of all cases where tokens belong to structured trivia. this is only for cases we care
return
GetAdjustSpacesOperation
(
previousToken
,
currentToken
,
nextOperation
);
return
GetAdjustSpacesOperation
(
previousToken
,
currentToken
,
in
nextOperation
);
}
return
nextOperation
.
Invoke
();
}
private
AdjustSpacesOperation
GetAdjustSpacesOperation
(
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
NextOperation
<
AdjustSpacesOperation
>
nextOperation
)
private
AdjustSpacesOperation
GetAdjustSpacesOperation
(
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
in
NextOperation
<
AdjustSpacesOperation
>
nextOperation
)
{
if
(
previousToken
.
Kind
()
==
SyntaxKind
.
HashToken
&&
SyntaxFacts
.
IsPreprocessorKeyword
(
currentToken
.
Kind
()))
{
...
...
src/Workspaces/CSharp/Portable/Formatting/Rules/TokenBasedFormattingRule.cs
浏览文件 @
4c467bf6
...
...
@@ -12,7 +12,7 @@ internal class TokenBasedFormattingRule : BaseFormattingRule
{
internal
const
string
Name
=
"CSharp Token Based Formatting Rule"
;
public
override
AdjustNewLinesOperation
GetAdjustNewLinesOperation
(
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
OptionSet
optionSet
,
NextOperation
<
AdjustNewLinesOperation
>
nextOperation
)
public
override
AdjustNewLinesOperation
GetAdjustNewLinesOperation
(
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
OptionSet
optionSet
,
ref
NextOperation
<
AdjustNewLinesOperation
>
nextOperation
)
{
////////////////////////////////////////////////////
// brace related operations
...
...
@@ -186,7 +186,7 @@ public override AdjustNewLinesOperation GetAdjustNewLinesOperation(SyntaxToken p
return
nextOperation
.
Invoke
();
}
public
override
AdjustSpacesOperation
GetAdjustSpacesOperation
(
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
OptionSet
optionSet
,
NextOperation
<
AdjustSpacesOperation
>
nextOperation
)
public
override
AdjustSpacesOperation
GetAdjustSpacesOperation
(
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
OptionSet
optionSet
,
ref
NextOperation
<
AdjustSpacesOperation
>
nextOperation
)
{
//////////////////////////////////////////////////////
// ";" related operations
...
...
src/Workspaces/Core/Portable/Formatting/Engine/ChainedFormattingRules.cs
浏览文件 @
4c467bf6
...
...
@@ -53,11 +53,11 @@ public ChainedFormattingRules(IEnumerable<AbstractFormattingRule> formattingRule
this
.
AddContinuedOperations
);
_newLinesFuncCache
=
new
OperationCache
<
AdjustNewLinesOperation
>(
(
in
dex
,
token1
,
token2
,
next
)
=>
_formattingRules
[
index
].
GetAdjustNewLinesOperation
(
token1
,
token2
,
_optionSet
,
next
),
(
in
t
index
,
SyntaxToken
token1
,
SyntaxToken
token2
,
ref
NextOperation
<
AdjustNewLinesOperation
>
next
)
=>
_formattingRules
[
index
].
GetAdjustNewLinesOperation
(
token1
,
token2
,
_optionSet
,
ref
next
),
this
.
GetContinuedOperations
);
_spaceFuncCache
=
new
OperationCache
<
AdjustSpacesOperation
>(
(
in
dex
,
token1
,
token2
,
next
)
=>
_formattingRules
[
index
].
GetAdjustSpacesOperation
(
token1
,
token2
,
_optionSet
,
next
),
(
in
t
index
,
SyntaxToken
token1
,
SyntaxToken
token2
,
ref
NextOperation
<
AdjustSpacesOperation
>
next
)
=>
_formattingRules
[
index
].
GetAdjustSpacesOperation
(
token1
,
token2
,
_optionSet
,
ref
next
),
this
.
GetContinuedOperations
);
}
...
...
@@ -107,7 +107,7 @@ private void AddContinuedOperations<TArg1>(int index, List<TArg1> arg1, SyntaxNo
}
}
private
TResult
GetContinuedOperations
<
TResult
>(
int
index
,
SyntaxToken
token1
,
SyntaxToken
token2
,
OperationCache
<
TResult
>
funcCache
)
private
TResult
GetContinuedOperations
<
TResult
>(
int
index
,
SyntaxToken
token1
,
SyntaxToken
token2
,
in
OperationCache
<
TResult
>
funcCache
)
{
// If we have no remaining handlers to execute, then we'll execute our last handler
if
(
index
>=
_formattingRules
.
Count
)
...
...
@@ -118,7 +118,7 @@ private TResult GetContinuedOperations<TResult>(int index, SyntaxToken token1, S
{
// Call the handler at the index, passing a continuation that will come back to here with index + 1
var
continuation
=
new
NextOperation
<
TResult
>(
index
+
1
,
token1
,
token2
,
funcCache
);
return
funcCache
.
NextOperation
(
index
,
token1
,
token2
,
continuation
);
return
funcCache
.
NextOperation
(
index
,
token1
,
token2
,
ref
continuation
);
}
}
}
...
...
src/Workspaces/Core/Portable/Formatting/Engine/OperationCache`1.cs
浏览文件 @
4c467bf6
...
...
@@ -10,15 +10,18 @@ namespace Microsoft.CodeAnalysis.Formatting
/// </summary>
internal
readonly
struct
OperationCache
<
TResult
>
{
public
delegate
TResult
NextOperationFunc
(
int
index
,
SyntaxToken
token1
,
SyntaxToken
token2
,
ref
NextOperation
<
TResult
>
next
);
public
delegate
TResult
ContinuationFunc
(
int
index
,
SyntaxToken
token1
,
SyntaxToken
token2
,
in
OperationCache
<
TResult
>
operationCache
);
public
OperationCache
(
Func
<
int
,
SyntaxToken
,
SyntaxToken
,
NextOperation
<
TResult
>,
TResult
>
nextOperation
,
Func
<
int
,
SyntaxToken
,
SyntaxToken
,
OperationCache
<
TResult
>,
TResult
>
continuation
)
NextOperationFunc
nextOperation
,
ContinuationFunc
continuation
)
{
this
.
NextOperation
=
nextOperation
;
this
.
Continuation
=
continuation
;
}
public
Func
<
int
,
SyntaxToken
,
SyntaxToken
,
NextOperation
<
TResult
>,
TResult
>
NextOperation
{
get
;
}
public
Func
<
int
,
SyntaxToken
,
SyntaxToken
,
OperationCache
<
TResult
>,
TResult
>
Continuation
{
get
;
}
public
NextOperationFunc
NextOperation
{
get
;
}
public
ContinuationFunc
Continuation
{
get
;
}
}
}
src/Workspaces/Core/Portable/Formatting/Rules/AbstractFormattingRule.cs
浏览文件 @
4c467bf6
...
...
@@ -47,7 +47,7 @@ public virtual void AddAlignTokensOperations(List<AlignTokensOperation> list, Sy
/// <summary>
/// returns AdjustNewLinesOperation between two tokens either by itself or by filtering/replacing a operation returned by NextOperation
/// </summary>
public
virtual
AdjustNewLinesOperation
GetAdjustNewLinesOperation
(
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
OptionSet
optionSet
,
NextOperation
<
AdjustNewLinesOperation
>
nextOperation
)
public
virtual
AdjustNewLinesOperation
GetAdjustNewLinesOperation
(
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
OptionSet
optionSet
,
ref
NextOperation
<
AdjustNewLinesOperation
>
nextOperation
)
{
return
nextOperation
.
Invoke
();
}
...
...
@@ -55,7 +55,7 @@ public virtual AdjustNewLinesOperation GetAdjustNewLinesOperation(SyntaxToken pr
/// <summary>
/// returns AdjustSpacesOperation between two tokens either by itself or by filtering/replacing a operation returned by NextOperation
/// </summary>
public
virtual
AdjustSpacesOperation
GetAdjustSpacesOperation
(
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
OptionSet
optionSet
,
NextOperation
<
AdjustSpacesOperation
>
nextOperation
)
public
virtual
AdjustSpacesOperation
GetAdjustSpacesOperation
(
SyntaxToken
previousToken
,
SyntaxToken
currentToken
,
OptionSet
optionSet
,
ref
NextOperation
<
AdjustSpacesOperation
>
nextOperation
)
{
return
nextOperation
.
Invoke
();
}
...
...
src/Workspaces/Core/Portable/Formatting/Rules/NextOperation`1.cs
浏览文件 @
4c467bf6
...
...
@@ -6,14 +6,14 @@ namespace Microsoft.CodeAnalysis.Formatting.Rules
/// <summary>
/// Represents a next operation to run in a continuation style chaining.
/// </summary>
internal
struct
NextOperation
<
TResult
>
internal
readonly
struct
NextOperation
<
TResult
>
{
private
readonly
int
_index
;
private
SyntaxToken
_token1
;
private
SyntaxToken
_token2
;
private
readonly
SyntaxToken
_token1
;
private
readonly
SyntaxToken
_token2
;
private
readonly
OperationCache
<
TResult
>
_operationCache
;
public
NextOperation
(
int
index
,
SyntaxToken
token1
,
SyntaxToken
token2
,
OperationCache
<
TResult
>
operationCache
)
public
NextOperation
(
int
index
,
SyntaxToken
token1
,
SyntaxToken
token2
,
in
OperationCache
<
TResult
>
operationCache
)
{
_index
=
index
;
_token1
=
token1
;
...
...
@@ -23,7 +23,7 @@ public NextOperation(int index, SyntaxToken token1, SyntaxToken token2, Operatio
public
TResult
Invoke
()
{
return
_operationCache
.
Continuation
(
_index
,
_token1
,
_token2
,
_operationCache
);
return
_operationCache
.
Continuation
(
_index
,
_token1
,
_token2
,
in
_operationCache
);
}
}
}
src/Workspaces/VisualBasic/Portable/Formatting/DefaultOperationProvider.vb
浏览文件 @
4c467bf6
...
...
@@ -31,7 +31,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Formatting
Public
Overrides
Sub
AddAlignTokensOperations
(
operations
As
List
(
Of
AlignTokensOperation
),
node
As
SyntaxNode
,
optionSet
As
OptionSet
,
nextAction
As
NextAction
(
Of
AlignTokensOperation
))
End
Sub
Public
Overrides
Function
GetAdjustNewLinesOperation
(
previousToken
As
SyntaxToken
,
currentToken
As
SyntaxToken
,
optionSet
As
OptionSet
,
nextOperation
As
NextOperation
(
Of
AdjustNewLinesOperation
))
As
AdjustNewLinesOperation
Public
Overrides
Function
GetAdjustNewLinesOperation
(
previousToken
As
SyntaxToken
,
currentToken
As
SyntaxToken
,
optionSet
As
OptionSet
,
ByRef
nextOperation
As
NextOperation
(
Of
AdjustNewLinesOperation
))
As
AdjustNewLinesOperation
If
previousToken
.
Parent
Is
Nothing
Then
Return
Nothing
End
If
...
...
@@ -149,7 +149,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Formatting
End
Function
' return 1 space for every token pairs as a default operation
Public
Overrides
Function
GetAdjustSpacesOperation
(
previousToken
As
SyntaxToken
,
currentToken
As
SyntaxToken
,
optionSet
As
OptionSet
,
nextOperation
As
NextOperation
(
Of
AdjustSpacesOperation
))
As
AdjustSpacesOperation
Public
Overrides
Function
GetAdjustSpacesOperation
(
previousToken
As
SyntaxToken
,
currentToken
As
SyntaxToken
,
optionSet
As
OptionSet
,
ByRef
nextOperation
As
NextOperation
(
Of
AdjustSpacesOperation
))
As
AdjustSpacesOperation
If
previousToken
.
Kind
=
SyntaxKind
.
ColonToken
AndAlso
TypeOf
previousToken
.
Parent
Is
LabelStatementSyntax
AndAlso
currentToken
.
Kind
<>
SyntaxKind
.
EndOfFileToken
Then
...
...
src/Workspaces/VisualBasic/Portable/Formatting/Rules/AdjustSpaceFormattingRule.vb
浏览文件 @
4c467bf6
...
...
@@ -12,7 +12,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Formatting
Public
Sub
New
()
End
Sub
Public
Overrides
Function
GetAdjustSpacesOperation
(
previousToken
As
SyntaxToken
,
currentToken
As
SyntaxToken
,
optionSet
As
OptionSet
,
nextFunc
As
NextOperation
(
Of
AdjustSpacesOperation
))
As
AdjustSpacesOperation
Public
Overrides
Function
GetAdjustSpacesOperation
(
previousToken
As
SyntaxToken
,
currentToken
As
SyntaxToken
,
optionSet
As
OptionSet
,
ByRef
nextFunc
As
NextOperation
(
Of
AdjustSpacesOperation
))
As
AdjustSpacesOperation
' * <end of file token>
If
currentToken
.
Kind
=
SyntaxKind
.
EndOfFileToken
Then
Return
CreateAdjustSpacesOperation
(
0
,
AdjustSpacesOption
.
ForceSpacesIfOnSingleLine
)
...
...
src/Workspaces/VisualBasic/Portable/Formatting/Rules/ElasticTriviaFormattingRule.vb
浏览文件 @
4c467bf6
...
...
@@ -84,7 +84,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Formatting
End
If
End
Sub
Public
Overrides
Function
GetAdjustSpacesOperation
(
previousToken
As
SyntaxToken
,
currentToken
As
SyntaxToken
,
optionSet
As
OptionSet
,
nextOperation
As
Rules
.
NextOperation
(
Of
AdjustSpacesOperation
))
As
AdjustSpacesOperation
Public
Overrides
Function
GetAdjustSpacesOperation
(
previousToken
As
SyntaxToken
,
currentToken
As
SyntaxToken
,
optionSet
As
OptionSet
,
ByRef
nextOperation
As
Rules
.
NextOperation
(
Of
AdjustSpacesOperation
))
As
AdjustSpacesOperation
' if it doesn't have elastic trivia, pass it through
If
Not
CommonFormattingHelpers
.
HasAnyWhitespaceElasticTrivia
(
previousToken
,
currentToken
)
Then
Return
nextOperation
.
Invoke
()
...
...
@@ -124,7 +124,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Formatting
previousToken
As
SyntaxToken
,
currentToken
As
SyntaxToken
,
optionSet
As
OptionSet
,
nextOperation
As
NextOperation
(
Of
AdjustNewLinesOperation
))
As
AdjustNewLinesOperation
ByRef
nextOperation
As
NextOperation
(
Of
AdjustNewLinesOperation
))
As
AdjustNewLinesOperation
' if it doesn't have elastic trivia, pass it through
If
Not
CommonFormattingHelpers
.
HasAnyWhitespaceElasticTrivia
(
previousToken
,
currentToken
)
Then
...
...
src/Workspaces/VisualBasic/Portable/Formatting/Rules/StructuredTriviaFormattingRule.vb
浏览文件 @
4c467bf6
...
...
@@ -12,7 +12,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Formatting
Public
Sub
New
()
End
Sub
Public
Overrides
Function
GetAdjustNewLinesOperation
(
previousToken
As
SyntaxToken
,
currentToken
As
SyntaxToken
,
optionSet
As
OptionSet
,
nextOperation
As
NextOperation
(
Of
AdjustNewLinesOperation
))
As
AdjustNewLinesOperation
Public
Overrides
Function
GetAdjustNewLinesOperation
(
previousToken
As
SyntaxToken
,
currentToken
As
SyntaxToken
,
optionSet
As
OptionSet
,
ByRef
nextOperation
As
NextOperation
(
Of
AdjustNewLinesOperation
))
As
AdjustNewLinesOperation
If
UnderStructuredTrivia
(
previousToken
,
currentToken
)
Then
Return
Nothing
End
If
...
...
@@ -21,7 +21,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Formatting
End
Function
Public
Overrides
Function
GetAdjustSpacesOperation
(
previousToken
As
SyntaxToken
,
currentToken
As
SyntaxToken
,
optionSet
As
OptionSet
,
nextOperation
As
NextOperation
(
Of
AdjustSpacesOperation
))
As
AdjustSpacesOperation
Public
Overrides
Function
GetAdjustSpacesOperation
(
previousToken
As
SyntaxToken
,
currentToken
As
SyntaxToken
,
optionSet
As
OptionSet
,
ByRef
nextOperation
As
NextOperation
(
Of
AdjustSpacesOperation
))
As
AdjustSpacesOperation
If
UnderStructuredTrivia
(
previousToken
,
currentToken
)
Then
If
previousToken
.
Kind
=
SyntaxKind
.
HashToken
AndAlso
SyntaxFacts
.
IsPreprocessorKeyword
(
CType
(
currentToken
.
Kind
,
SyntaxKind
))
Then
Return
CreateAdjustSpacesOperation
(
space
:
=
0
,
option
:
=
AdjustSpacesOption
.
ForceSpacesIfOnSingleLine
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录