Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
d2d03c8c
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,发现更多精彩内容 >>
未验证
提交
d2d03c8c
编写于
4月 13, 2018
作者:
V
Vladimir Sadov
提交者:
GitHub
4月 13, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #26010 from VSadov/useNewFeatures
Use 7.2 language features in Roslyn
上级
94ef9a5c
df4a2f45
变更
43
显示空白变更内容
内联
并排
Showing
43 changed file
with
177 addition
and
195 deletion
+177
-195
build/Targets/Packages.props
build/Targets/Packages.props
+1
-1
src/Compilers/CSharp/Portable/Parser/BlendedNode.cs
src/Compilers/CSharp/Portable/Parser/BlendedNode.cs
+1
-1
src/Compilers/CSharp/Portable/Parser/Blender.cs
src/Compilers/CSharp/Portable/Parser/Blender.cs
+1
-1
src/Compilers/CSharp/Portable/Parser/SyntaxParser.cs
src/Compilers/CSharp/Portable/Parser/SyntaxParser.cs
+1
-1
src/Compilers/Core/Portable/Diagnostic/SourceLocation.cs
src/Compilers/Core/Portable/Diagnostic/SourceLocation.cs
+3
-3
src/Compilers/Core/Portable/InternalUtilities/EnumField.cs
src/Compilers/Core/Portable/InternalUtilities/EnumField.cs
+1
-1
src/Compilers/Core/Portable/InternalUtilities/TextKeyedCache.cs
...mpilers/Core/Portable/InternalUtilities/TextKeyedCache.cs
+18
-42
src/Compilers/Core/Portable/Optional.cs
src/Compilers/Core/Portable/Optional.cs
+1
-1
src/Compilers/Core/Portable/PublicAPI.Shipped.txt
src/Compilers/Core/Portable/PublicAPI.Shipped.txt
+0
-2
src/Compilers/Core/Portable/Syntax/ChildSyntaxList.Enumerator.cs
...pilers/Core/Portable/Syntax/ChildSyntaxList.Enumerator.cs
+2
-1
src/Compilers/Core/Portable/Syntax/ChildSyntaxList.Reversed.cs
...ompilers/Core/Portable/Syntax/ChildSyntaxList.Reversed.cs
+2
-2
src/Compilers/Core/Portable/Syntax/ChildSyntaxList.cs
src/Compilers/Core/Portable/Syntax/ChildSyntaxList.cs
+1
-1
src/Compilers/Core/Portable/Syntax/InternalSyntax/SeparatedSyntaxList.cs
...ore/Portable/Syntax/InternalSyntax/SeparatedSyntaxList.cs
+2
-2
src/Compilers/Core/Portable/Syntax/InternalSyntax/SeparatedSyntaxListBuilder.cs
...table/Syntax/InternalSyntax/SeparatedSyntaxListBuilder.cs
+4
-4
src/Compilers/Core/Portable/Syntax/InternalSyntax/SyntaxListPool.cs
...ers/Core/Portable/Syntax/InternalSyntax/SyntaxListPool.cs
+1
-1
src/Compilers/Core/Portable/Syntax/SeparatedSyntaxList.Enumerator.cs
...rs/Core/Portable/Syntax/SeparatedSyntaxList.Enumerator.cs
+3
-3
src/Compilers/Core/Portable/Syntax/SeparatedSyntaxList.cs
src/Compilers/Core/Portable/Syntax/SeparatedSyntaxList.cs
+2
-2
src/Compilers/Core/Portable/Syntax/SeparatedSyntaxListBuilder.cs
...pilers/Core/Portable/Syntax/SeparatedSyntaxListBuilder.cs
+5
-5
src/Compilers/Core/Portable/Syntax/SyntaxDiffer.cs
src/Compilers/Core/Portable/Syntax/SyntaxDiffer.cs
+5
-5
src/Compilers/Core/Portable/Syntax/SyntaxList`1.Enumerator.cs
...Compilers/Core/Portable/Syntax/SyntaxList`1.Enumerator.cs
+3
-3
src/Compilers/Core/Portable/Syntax/SyntaxList`1.cs
src/Compilers/Core/Portable/Syntax/SyntaxList`1.cs
+1
-1
src/Compilers/Core/Portable/Syntax/SyntaxNavigator.cs
src/Compilers/Core/Portable/Syntax/SyntaxNavigator.cs
+8
-8
src/Compilers/Core/Portable/Syntax/SyntaxNode.Iterators.cs
src/Compilers/Core/Portable/Syntax/SyntaxNode.Iterators.cs
+41
-45
src/Compilers/Core/Portable/Syntax/SyntaxNode.cs
src/Compilers/Core/Portable/Syntax/SyntaxNode.cs
+2
-2
src/Compilers/Core/Portable/Syntax/SyntaxNodeOrToken.cs
src/Compilers/Core/Portable/Syntax/SyntaxNodeOrToken.cs
+3
-3
src/Compilers/Core/Portable/Syntax/SyntaxNodeOrTokenList.cs
src/Compilers/Core/Portable/Syntax/SyntaxNodeOrTokenList.cs
+2
-2
src/Compilers/Core/Portable/Syntax/SyntaxNodeOrTokenListBuilder.cs
...lers/Core/Portable/Syntax/SyntaxNodeOrTokenListBuilder.cs
+11
-1
src/Compilers/Core/Portable/Syntax/SyntaxToken.cs
src/Compilers/Core/Portable/Syntax/SyntaxToken.cs
+1
-1
src/Compilers/Core/Portable/Syntax/SyntaxTokenList.Enumerator.cs
...pilers/Core/Portable/Syntax/SyntaxTokenList.Enumerator.cs
+3
-3
src/Compilers/Core/Portable/Syntax/SyntaxTokenList.Reversed.cs
...ompilers/Core/Portable/Syntax/SyntaxTokenList.Reversed.cs
+8
-8
src/Compilers/Core/Portable/Syntax/SyntaxTokenList.cs
src/Compilers/Core/Portable/Syntax/SyntaxTokenList.cs
+4
-4
src/Compilers/Core/Portable/Syntax/SyntaxTrivia.cs
src/Compilers/Core/Portable/Syntax/SyntaxTrivia.cs
+2
-2
src/Compilers/Core/Portable/Syntax/SyntaxTriviaList.Enumerator.cs
...ilers/Core/Portable/Syntax/SyntaxTriviaList.Enumerator.cs
+10
-9
src/Compilers/Core/Portable/Syntax/SyntaxTriviaList.Reversed.cs
...mpilers/Core/Portable/Syntax/SyntaxTriviaList.Reversed.cs
+8
-8
src/Compilers/Core/Portable/Syntax/SyntaxTriviaList.cs
src/Compilers/Core/Portable/Syntax/SyntaxTriviaList.cs
+6
-6
src/Compilers/Core/Portable/Syntax/SyntaxTriviaListBuilder.cs
...Compilers/Core/Portable/Syntax/SyntaxTriviaListBuilder.cs
+2
-2
src/Compilers/Core/Portable/Syntax/SyntaxWalker.cs
src/Compilers/Core/Portable/Syntax/SyntaxWalker.cs
+2
-2
src/Compilers/Core/Portable/Text/LinePosition.cs
src/Compilers/Core/Portable/Text/LinePosition.cs
+1
-1
src/Compilers/Core/Portable/Text/LinePositionSpan.cs
src/Compilers/Core/Portable/Text/LinePositionSpan.cs
+1
-1
src/Compilers/Core/Portable/Text/TextChange.cs
src/Compilers/Core/Portable/Text/TextChange.cs
+1
-1
src/Compilers/Core/Portable/Text/TextChangeRange.cs
src/Compilers/Core/Portable/Text/TextChangeRange.cs
+1
-1
src/Compilers/Core/Portable/Text/TextLine.cs
src/Compilers/Core/Portable/Text/TextLine.cs
+1
-1
src/Compilers/Core/Portable/Text/TextSpan.cs
src/Compilers/Core/Portable/Text/TextSpan.cs
+1
-1
未找到文件。
build/Targets/Packages.props
浏览文件 @
d2d03c8c
...
...
@@ -55,7 +55,7 @@
<MicrosoftMSXMLVersion>
8.0.0.0-alpha
</MicrosoftMSXMLVersion>
<!-- Using a private build of Microsoft.Net.Test.SDK to work around issue https://github.com/Microsoft/vstest/issues/373 -->
<MicrosoftNETTestSdkVersion>
15.6.0-dev
</MicrosoftNETTestSdkVersion>
<MicrosoftNetCompilersVersion>
2.
6.1
</MicrosoftNetCompilersVersion>
<MicrosoftNetCompilersVersion>
2.
7.0
</MicrosoftNetCompilersVersion>
<MicrosoftNetRoslynDiagnosticsVersion>
2.6.1-beta1-62702-01
</MicrosoftNetRoslynDiagnosticsVersion>
<MicrosoftNetCoreILAsmVersion>
2.0.0
</MicrosoftNetCoreILAsmVersion>
<MicrosoftNETCoreCompilersVersion>
2.8.0-beta2-62712-07
</MicrosoftNETCoreCompilersVersion>
...
...
src/Compilers/CSharp/Portable/Parser/BlendedNode.cs
浏览文件 @
d2d03c8c
...
...
@@ -6,7 +6,7 @@
namespace
Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax
{
internal
struct
BlendedNode
internal
readonly
struct
BlendedNode
{
internal
readonly
CSharp
.
CSharpSyntaxNode
Node
;
internal
readonly
SyntaxToken
Token
;
...
...
src/Compilers/CSharp/Portable/Parser/Blender.cs
浏览文件 @
d2d03c8c
...
...
@@ -11,7 +11,7 @@
namespace
Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax
{
internal
partial
struct
Blender
internal
readonly
partial
struct
Blender
{
private
readonly
Lexer
_lexer
;
private
readonly
Cursor
_oldTreeCursor
;
...
...
src/Compilers/CSharp/Portable/Parser/SyntaxParser.cs
浏览文件 @
d2d03c8c
...
...
@@ -333,7 +333,7 @@ private void AddNewToken()
}
// adds token to end of current token array
private
void
AddToken
(
BlendedNode
tokenResult
)
private
void
AddToken
(
in
BlendedNode
tokenResult
)
{
Debug
.
Assert
(
tokenResult
.
Token
!=
null
);
if
(
_tokenCount
>=
_blendedTokens
.
Length
)
...
...
src/Compilers/Core/Portable/Diagnostic/SourceLocation.cs
浏览文件 @
d2d03c8c
...
...
@@ -26,17 +26,17 @@ public SourceLocation(SyntaxNode node)
{
}
public
SourceLocation
(
SyntaxToken
token
)
public
SourceLocation
(
in
SyntaxToken
token
)
:
this
(
token
.
SyntaxTree
,
token
.
Span
)
{
}
public
SourceLocation
(
SyntaxNodeOrToken
nodeOrToken
)
public
SourceLocation
(
in
SyntaxNodeOrToken
nodeOrToken
)
:
this
(
nodeOrToken
.
SyntaxTree
,
nodeOrToken
.
Span
)
{
}
public
SourceLocation
(
SyntaxTrivia
trivia
)
public
SourceLocation
(
in
SyntaxTrivia
trivia
)
:
this
(
trivia
.
SyntaxTree
,
trivia
.
Span
)
{
}
...
...
src/Compilers/Core/Portable/InternalUtilities/EnumField.cs
浏览文件 @
d2d03c8c
...
...
@@ -8,7 +8,7 @@
namespace
Roslyn.Utilities
{
[
DebuggerDisplay
(
"{GetDebuggerDisplay(), nq}"
)]
internal
struct
EnumField
internal
readonly
struct
EnumField
{
public
static
readonly
IComparer
<
EnumField
>
Comparer
=
new
EnumFieldComparer
();
...
...
src/Compilers/Core/Portable/InternalUtilities/TextKeyedCache.cs
浏览文件 @
d2d03c8c
...
...
@@ -15,26 +15,6 @@ namespace Roslyn.Utilities
{
internal
class
TextKeyedCache
<
T
>
where
T
:
class
{
// entry in the local cache
private
struct
LocalEntry
{
// full text of the item
public
string
Text
;
// hash code of the entry
public
int
HashCode
;
// item
public
T
Item
;
}
// entry in the shared cache
private
struct
SharedEntry
{
public
int
HashCode
;
public
SharedEntryValue
Entry
;
}
// immutable tuple - text and corresponding item
// reference type because we want atomic assignments
private
class
SharedEntryValue
...
...
@@ -71,17 +51,17 @@ public SharedEntryValue(string Text, T item)
// local cache
// simple fast and not threadsafe cache
// with limited size and "last add wins" expiration policy
private
readonly
LocalEntry
[]
_localTable
=
new
LocalEntry
[
LocalSize
];
private
readonly
(
string
Text
,
int
HashCode
,
T
Item
)[]
_localTable
=
new
(
string
Text
,
int
HashCode
,
T
Item
)
[
LocalSize
];
// shared threadsafe cache
// slightly slower than local cache
// we read this cache when having a miss in local cache
// writes to local cache will update shared cache as well.
private
static
readonly
SharedEntry
[]
s_sharedTable
=
new
SharedEntry
[
SharedSize
];
private
static
readonly
(
int
HashCode
,
SharedEntryValue
Entry
)[]
s_sharedTable
=
new
(
int
HashCode
,
SharedEntryValue
Entry
)
[
SharedSize
];
// store a reference to shared cache locally
// accessing a static field of a generic type could be nontrivial
private
readonly
SharedEntry
[]
_sharedTableInst
=
s_sharedTable
;
private
readonly
(
int
HashCode
,
SharedEntryValue
Entry
)
[]
_sharedTableInst
=
s_sharedTable
;
private
readonly
StringTable
_strings
;
...
...
@@ -131,31 +111,27 @@ public void Free()
internal
T
FindItem
(
char
[]
chars
,
int
start
,
int
len
,
int
hashCode
)
{
// capture array to avoid extra range checks
var
arr
=
_localTable
;
var
idx
=
LocalIdxFromHash
(
hashCode
);
// get direct element reference to avoid extra range checks
ref
var
localSlot
=
ref
_localTable
[
LocalIdxFromHash
(
hashCode
)];
var
text
=
arr
[
idx
]
.
Text
;
var
text
=
localSlot
.
Text
;
if
(
text
!=
null
&&
arr
[
idx
]
.
HashCode
==
hashCode
)
if
(
text
!=
null
&&
localSlot
.
HashCode
==
hashCode
)
{
if
(
StringTable
.
TextEquals
(
text
,
chars
,
start
,
len
))
{
return
arr
[
idx
]
.
Item
;
return
localSlot
.
Item
;
}
}
SharedEntryValue
e
=
FindSharedEntry
(
chars
,
start
,
len
,
hashCode
);
if
(
e
!=
null
)
{
// PERF: the following code does element-wise assignment of a struct
// because current JIT produces better code compared to
// arr[idx] = new LocalEntry(...)
arr
[
idx
].
HashCode
=
hashCode
;
arr
[
idx
].
Text
=
e
.
Text
;
localSlot
.
HashCode
=
hashCode
;
localSlot
.
Text
=
e
.
Text
;
var
tk
=
e
.
Item
;
arr
[
idx
]
.
Item
=
tk
;
localSlot
.
Item
=
tk
;
return
tk
;
}
...
...
@@ -169,12 +145,13 @@ private SharedEntryValue FindSharedEntry(char[] chars, int start, int len, int h
int
idx
=
SharedIdxFromHash
(
hashCode
);
SharedEntryValue
e
=
null
;
int
hash
;
// we use quadratic probing here
// bucket positions are (n^2 + n)/2 relative to the masked hashcode
for
(
int
i
=
1
;
i
<
SharedBucketSize
+
1
;
i
++)
{
e
=
arr
[
idx
].
Entry
;
int
hash
=
arr
[
idx
].
HashCode
;
(
hash
,
e
)
=
arr
[
idx
];
if
(
e
!=
null
)
{
...
...
@@ -207,11 +184,10 @@ internal void AddItem(char[] chars, int start, int len, int hashCode, T item)
AddSharedEntry
(
hashCode
,
e
);
// add to the local table too
var
arr
=
_localTable
;
var
idx
=
LocalIdxFromHash
(
hashCode
);
arr
[
idx
].
HashCode
=
hashCode
;
arr
[
idx
].
Text
=
text
;
arr
[
idx
].
Item
=
item
;
ref
var
localSlot
=
ref
_localTable
[
LocalIdxFromHash
(
hashCode
)];
localSlot
.
HashCode
=
hashCode
;
localSlot
.
Text
=
text
;
localSlot
.
Item
=
item
;
}
private
void
AddSharedEntry
(
int
hashCode
,
SharedEntryValue
e
)
...
...
src/Compilers/Core/Portable/Optional.cs
浏览文件 @
d2d03c8c
...
...
@@ -9,7 +9,7 @@ namespace Microsoft.CodeAnalysis
/// indicating whether or not that value is meaningful.
/// </summary>
/// <typeparam name="T">The type of the value.</typeparam>
public
struct
Optional
<
T
>
public
readonly
struct
Optional
<
T
>
{
private
readonly
bool
_hasValue
;
private
readonly
T
_value
;
...
...
src/Compilers/Core/Portable/PublicAPI.Shipped.txt
浏览文件 @
d2d03c8c
...
...
@@ -2210,7 +2210,6 @@ Microsoft.CodeAnalysis.SyntaxTokenList.Reverse() -> Microsoft.CodeAnalysis.Synta
Microsoft.CodeAnalysis.SyntaxTokenList.Reversed
Microsoft.CodeAnalysis.SyntaxTokenList.Reversed.Enumerator
Microsoft.CodeAnalysis.SyntaxTokenList.Reversed.Enumerator.Current.get -> Microsoft.CodeAnalysis.SyntaxToken
Microsoft.CodeAnalysis.SyntaxTokenList.Reversed.Enumerator.Enumerator(ref Microsoft.CodeAnalysis.SyntaxTokenList list) -> void
Microsoft.CodeAnalysis.SyntaxTokenList.Reversed.Enumerator.MoveNext() -> bool
Microsoft.CodeAnalysis.SyntaxTokenList.Reversed.Equals(Microsoft.CodeAnalysis.SyntaxTokenList.Reversed other) -> bool
Microsoft.CodeAnalysis.SyntaxTokenList.Reversed.GetEnumerator() -> Microsoft.CodeAnalysis.SyntaxTokenList.Reversed.Enumerator
...
...
@@ -2282,7 +2281,6 @@ Microsoft.CodeAnalysis.SyntaxTriviaList.Reverse() -> Microsoft.CodeAnalysis.Synt
Microsoft.CodeAnalysis.SyntaxTriviaList.Reversed
Microsoft.CodeAnalysis.SyntaxTriviaList.Reversed.Enumerator
Microsoft.CodeAnalysis.SyntaxTriviaList.Reversed.Enumerator.Current.get -> Microsoft.CodeAnalysis.SyntaxTrivia
Microsoft.CodeAnalysis.SyntaxTriviaList.Reversed.Enumerator.Enumerator(ref Microsoft.CodeAnalysis.SyntaxTriviaList list) -> void
Microsoft.CodeAnalysis.SyntaxTriviaList.Reversed.Enumerator.MoveNext() -> bool
Microsoft.CodeAnalysis.SyntaxTriviaList.Reversed.Equals(Microsoft.CodeAnalysis.SyntaxTriviaList.Reversed other) -> bool
Microsoft.CodeAnalysis.SyntaxTriviaList.Reversed.GetEnumerator() -> Microsoft.CodeAnalysis.SyntaxTriviaList.Reversed.Enumerator
...
...
src/Compilers/Core/Portable/Syntax/ChildSyntaxList.Enumerator.cs
浏览文件 @
d2d03c8c
...
...
@@ -62,10 +62,11 @@ public void Reset()
_childIndex
=
-
1
;
}
internal
bool
TryMoveNextAndGetCurrent
(
ref
SyntaxNodeOrToken
current
)
internal
bool
TryMoveNextAndGetCurrent
(
out
SyntaxNodeOrToken
current
)
{
if
(!
MoveNext
())
{
current
=
default
;
return
false
;
}
...
...
src/Compilers/Core/Portable/Syntax/ChildSyntaxList.Reversed.cs
浏览文件 @
d2d03c8c
...
...
@@ -11,9 +11,9 @@
namespace
Microsoft.CodeAnalysis
{
public
partial
struct
ChildSyntaxList
public
readonly
partial
struct
ChildSyntaxList
{
public
partial
struct
Reversed
:
IEnumerable
<
SyntaxNodeOrToken
>,
IEquatable
<
Reversed
>
public
readonly
partial
struct
Reversed
:
IEnumerable
<
SyntaxNodeOrToken
>,
IEquatable
<
Reversed
>
{
private
readonly
SyntaxNode
_node
;
private
readonly
int
_count
;
...
...
src/Compilers/Core/Portable/Syntax/ChildSyntaxList.cs
浏览文件 @
d2d03c8c
...
...
@@ -10,7 +10,7 @@
namespace
Microsoft.CodeAnalysis
{
public
partial
struct
ChildSyntaxList
:
IEquatable
<
ChildSyntaxList
>,
IReadOnlyList
<
SyntaxNodeOrToken
>
public
readonly
partial
struct
ChildSyntaxList
:
IEquatable
<
ChildSyntaxList
>,
IReadOnlyList
<
SyntaxNodeOrToken
>
{
private
readonly
SyntaxNode
_node
;
private
readonly
int
_count
;
...
...
src/Compilers/Core/Portable/Syntax/InternalSyntax/SeparatedSyntaxList.cs
浏览文件 @
d2d03c8c
...
...
@@ -73,12 +73,12 @@ public SyntaxList<GreenNode> GetWithSeparators()
return
_list
;
}
public
static
bool
operator
==(
SeparatedSyntaxList
<
TNode
>
left
,
SeparatedSyntaxList
<
TNode
>
right
)
public
static
bool
operator
==(
in
SeparatedSyntaxList
<
TNode
>
left
,
in
SeparatedSyntaxList
<
TNode
>
right
)
{
return
left
.
Equals
(
right
);
}
public
static
bool
operator
!=(
SeparatedSyntaxList
<
TNode
>
left
,
SeparatedSyntaxList
<
TNode
>
right
)
public
static
bool
operator
!=(
in
SeparatedSyntaxList
<
TNode
>
left
,
in
SeparatedSyntaxList
<
TNode
>
right
)
{
return
!
left
.
Equals
(
right
);
}
...
...
src/Compilers/Core/Portable/Syntax/InternalSyntax/SeparatedSyntaxListBuilder.cs
浏览文件 @
d2d03c8c
...
...
@@ -78,12 +78,12 @@ public void AddRange(TNode[] items, int offset, int length)
_builder
.
AddRange
(
items
,
offset
,
length
);
}
public
void
AddRange
(
SeparatedSyntaxList
<
TNode
>
nodes
)
public
void
AddRange
(
in
SeparatedSyntaxList
<
TNode
>
nodes
)
{
_builder
.
AddRange
(
nodes
.
GetWithSeparators
());
}
public
void
AddRange
(
SeparatedSyntaxList
<
TNode
>
nodes
,
int
count
)
public
void
AddRange
(
in
SeparatedSyntaxList
<
TNode
>
nodes
,
int
count
)
{
var
list
=
nodes
.
GetWithSeparators
();
this
.
_builder
.
AddRange
(
list
,
this
.
Count
,
Math
.
Min
(
count
*
2
,
list
.
Count
));
...
...
@@ -115,12 +115,12 @@ internal SyntaxListBuilder UnderlyingBuilder
get
{
return
_builder
;
}
}
public
static
implicit
operator
SeparatedSyntaxList
<
TNode
>(
SeparatedSyntaxListBuilder
<
TNode
>
builder
)
public
static
implicit
operator
SeparatedSyntaxList
<
TNode
>(
in
SeparatedSyntaxListBuilder
<
TNode
>
builder
)
{
return
builder
.
ToList
();
}
public
static
implicit
operator
SyntaxListBuilder
(
SeparatedSyntaxListBuilder
<
TNode
>
builder
)
public
static
implicit
operator
SyntaxListBuilder
(
in
SeparatedSyntaxListBuilder
<
TNode
>
builder
)
{
return
builder
.
_builder
;
}
...
...
src/Compilers/Core/Portable/Syntax/InternalSyntax/SyntaxListPool.cs
浏览文件 @
d2d03c8c
...
...
@@ -50,7 +50,7 @@ internal SyntaxListBuilder Allocate()
return
new
SeparatedSyntaxListBuilder
<
TNode
>(
this
.
Allocate
());
}
internal
void
Free
<
TNode
>(
SeparatedSyntaxListBuilder
<
TNode
>
item
)
where
TNode
:
GreenNode
internal
void
Free
<
TNode
>(
in
SeparatedSyntaxListBuilder
<
TNode
>
item
)
where
TNode
:
GreenNode
{
Free
(
item
.
UnderlyingBuilder
);
}
...
...
src/Compilers/Core/Portable/Syntax/SeparatedSyntaxList.Enumerator.cs
浏览文件 @
d2d03c8c
...
...
@@ -18,7 +18,7 @@ public struct Enumerator
private
readonly
SeparatedSyntaxList
<
TNode
>
_list
;
private
int
_index
;
internal
Enumerator
(
SeparatedSyntaxList
<
TNode
>
list
)
internal
Enumerator
(
in
SeparatedSyntaxList
<
TNode
>
list
)
{
_list
=
list
;
_index
=
-
1
;
...
...
@@ -65,9 +65,9 @@ private class EnumeratorImpl : IEnumerator<TNode>
{
private
Enumerator
_e
;
internal
EnumeratorImpl
(
SeparatedSyntaxList
<
TNode
>
list
)
internal
EnumeratorImpl
(
in
SeparatedSyntaxList
<
TNode
>
list
)
{
_e
=
new
Enumerator
(
list
);
_e
=
new
Enumerator
(
in
list
);
}
public
TNode
Current
...
...
src/Compilers/Core/Portable/Syntax/SeparatedSyntaxList.cs
浏览文件 @
d2d03c8c
...
...
@@ -10,7 +10,7 @@
namespace
Microsoft.CodeAnalysis
{
public
partial
struct
SeparatedSyntaxList
<
TNode
>
:
IEquatable
<
SeparatedSyntaxList
<
TNode
>>,
IReadOnlyList
<
TNode
>
where
TNode
:
SyntaxNode
public
readonly
partial
struct
SeparatedSyntaxList
<
TNode
>
:
IEquatable
<
SeparatedSyntaxList
<
TNode
>>,
IReadOnlyList
<
TNode
>
where
TNode
:
SyntaxNode
{
private
readonly
SyntaxNodeOrTokenList
_list
;
private
readonly
int
_count
;
...
...
@@ -414,7 +414,7 @@ public SeparatedSyntaxList<TNode> InsertRange(int index, IEnumerable<TNode> node
return
new
SeparatedSyntaxList
<
TNode
>(
nodesWithSeps
.
InsertRange
(
insertionIndex
,
nodesToInsertWithSeparators
));
}
private
static
bool
KeepSeparatorWithPreviousNode
(
SyntaxToken
separator
)
private
static
bool
KeepSeparatorWithPreviousNode
(
in
SyntaxToken
separator
)
{
// if the trivia after the separator contains an explicit end of line or a single line comment
// then it should stay associated with previous node
...
...
src/Compilers/Core/Portable/Syntax/SeparatedSyntaxListBuilder.cs
浏览文件 @
d2d03c8c
...
...
@@ -70,7 +70,7 @@ public SeparatedSyntaxListBuilder<TNode> Add(TNode node)
return
this
;
}
public
SeparatedSyntaxListBuilder
<
TNode
>
AddSeparator
(
SyntaxToken
separatorToken
)
public
SeparatedSyntaxListBuilder
<
TNode
>
AddSeparator
(
in
SyntaxToken
separatorToken
)
{
CheckExpectedSeparator
();
_expectedSeparator
=
false
;
...
...
@@ -78,7 +78,7 @@ public SeparatedSyntaxListBuilder<TNode> AddSeparator(SyntaxToken separatorToken
return
this
;
}
public
SeparatedSyntaxListBuilder
<
TNode
>
AddRange
(
SeparatedSyntaxList
<
TNode
>
nodes
)
public
SeparatedSyntaxListBuilder
<
TNode
>
AddRange
(
in
SeparatedSyntaxList
<
TNode
>
nodes
)
{
CheckExpectedElement
();
SyntaxNodeOrTokenList
list
=
nodes
.
GetWithSeparators
();
...
...
@@ -87,7 +87,7 @@ public SeparatedSyntaxListBuilder<TNode> AddRange(SeparatedSyntaxList<TNode> nod
return
this
;
}
public
SeparatedSyntaxListBuilder
<
TNode
>
AddRange
(
SeparatedSyntaxList
<
TNode
>
nodes
,
int
count
)
public
SeparatedSyntaxListBuilder
<
TNode
>
AddRange
(
in
SeparatedSyntaxList
<
TNode
>
nodes
,
int
count
)
{
CheckExpectedElement
();
SyntaxNodeOrTokenList
list
=
nodes
.
GetWithSeparators
();
...
...
@@ -116,12 +116,12 @@ public SeparatedSyntaxList<TNode> ToList()
return
_builder
.
ToSeparatedList
<
TDerived
>();
}
public
static
implicit
operator
SyntaxListBuilder
(
SeparatedSyntaxListBuilder
<
TNode
>
builder
)
public
static
implicit
operator
SyntaxListBuilder
(
in
SeparatedSyntaxListBuilder
<
TNode
>
builder
)
{
return
builder
.
_builder
;
}
public
static
implicit
operator
SeparatedSyntaxList
<
TNode
>(
SeparatedSyntaxListBuilder
<
TNode
>
builder
)
public
static
implicit
operator
SeparatedSyntaxList
<
TNode
>(
in
SeparatedSyntaxListBuilder
<
TNode
>
builder
)
{
if
(
builder
.
_builder
!=
null
)
{
...
...
src/Compilers/Core/Portable/Syntax/SyntaxDiffer.cs
浏览文件 @
d2d03c8c
...
...
@@ -336,7 +336,7 @@ private static void ReplaceFirstWithChildren(Stack<SyntaxNodeOrToken> stack)
}
}
private
void
FindBestMatch
(
Stack
<
SyntaxNodeOrToken
>
stack
,
SyntaxNodeOrToken
node
,
out
int
index
,
out
int
similarity
,
int
startIndex
=
0
)
private
void
FindBestMatch
(
Stack
<
SyntaxNodeOrToken
>
stack
,
in
SyntaxNodeOrToken
node
,
out
int
index
,
out
int
similarity
,
int
startIndex
=
0
)
{
index
=
-
1
;
similarity
=
-
1
;
...
...
@@ -419,7 +419,7 @@ private void FindBestMatch(Stack<SyntaxNodeOrToken> stack, SyntaxNodeOrToken nod
}
}
private
int
GetSimilarity
(
SyntaxNodeOrToken
node1
,
SyntaxNodeOrToken
node2
)
private
int
GetSimilarity
(
in
SyntaxNodeOrToken
node1
,
in
SyntaxNodeOrToken
node2
)
{
// count the characters in the common/identical nodes
int
w
=
0
;
...
...
@@ -495,12 +495,12 @@ private int GetSimilarity(SyntaxNodeOrToken node1, SyntaxNodeOrToken node2)
return
w
;
}
private
static
bool
AreIdentical
(
SyntaxNodeOrToken
node1
,
SyntaxNodeOrToken
node2
)
private
static
bool
AreIdentical
(
in
SyntaxNodeOrToken
node1
,
in
SyntaxNodeOrToken
node2
)
{
return
node1
.
UnderlyingNode
==
node2
.
UnderlyingNode
;
}
private
static
bool
AreSimilar
(
SyntaxNodeOrToken
node1
,
SyntaxNodeOrToken
node2
)
private
static
bool
AreSimilar
(
in
SyntaxNodeOrToken
node1
,
in
SyntaxNodeOrToken
node2
)
{
return
node1
.
RawKind
==
node2
.
RawKind
;
}
...
...
@@ -582,7 +582,7 @@ private void RecordChange(ChangeRecord change)
_changes
.
Add
(
change
);
}
private
void
RecordChange
(
TextChangeRange
textChangeRange
,
SyntaxNodeOrToken
removedNode
,
SyntaxNodeOrToken
insertedNode
)
private
void
RecordChange
(
TextChangeRange
textChangeRange
,
in
SyntaxNodeOrToken
removedNode
,
SyntaxNodeOrToken
insertedNode
)
{
if
(
_changes
.
Count
>
0
)
{
...
...
src/Compilers/Core/Portable/Syntax/SyntaxList`1.Enumerator.cs
浏览文件 @
d2d03c8c
...
...
@@ -7,12 +7,12 @@
namespace
Microsoft.CodeAnalysis
{
public
partial
struct
SyntaxList
<
TNode
>
public
readonly
partial
struct
SyntaxList
<
TNode
>
{
[
SuppressMessage
(
"Performance"
,
"CA1067"
,
Justification
=
"Equality not actually implemented"
)]
public
struct
Enumerator
{
private
SyntaxList
<
TNode
>
_list
;
private
readonly
SyntaxList
<
TNode
>
_list
;
private
int
_index
;
internal
Enumerator
(
SyntaxList
<
TNode
>
list
)
...
...
@@ -61,7 +61,7 @@ private class EnumeratorImpl : IEnumerator<TNode>
{
private
Enumerator
_e
;
internal
EnumeratorImpl
(
SyntaxList
<
TNode
>
list
)
internal
EnumeratorImpl
(
in
SyntaxList
<
TNode
>
list
)
{
_e
=
new
Enumerator
(
list
);
}
...
...
src/Compilers/Core/Portable/Syntax/SyntaxList`1.cs
浏览文件 @
d2d03c8c
...
...
@@ -14,7 +14,7 @@ namespace Microsoft.CodeAnalysis
/// <summary>
/// A list of <see cref="SyntaxNode"/>.
/// </summary>
public
partial
struct
SyntaxList
<
TNode
>
:
IReadOnlyList
<
TNode
>,
IEquatable
<
SyntaxList
<
TNode
>>
public
readonly
partial
struct
SyntaxList
<
TNode
>
:
IReadOnlyList
<
TNode
>,
IEquatable
<
SyntaxList
<
TNode
>>
where
TNode
:
SyntaxNode
{
private
readonly
SyntaxNode
_node
;
...
...
src/Compilers/Core/Portable/Syntax/SyntaxNavigator.cs
浏览文件 @
d2d03c8c
...
...
@@ -57,32 +57,32 @@ private static bool Matches(Func<SyntaxToken, bool> predicate, SyntaxToken token
return
predicate
==
null
||
ReferenceEquals
(
predicate
,
SyntaxToken
.
Any
)
||
predicate
(
token
);
}
internal
SyntaxToken
GetFirstToken
(
SyntaxNode
current
,
bool
includeZeroWidth
,
bool
includeSkipped
,
bool
includeDirectives
,
bool
includeDocumentationComments
)
internal
SyntaxToken
GetFirstToken
(
in
SyntaxNode
current
,
bool
includeZeroWidth
,
bool
includeSkipped
,
bool
includeDirectives
,
bool
includeDocumentationComments
)
{
return
GetFirstToken
(
current
,
GetPredicateFunction
(
includeZeroWidth
),
GetStepIntoFunction
(
includeSkipped
,
includeDirectives
,
includeDocumentationComments
));
}
internal
SyntaxToken
GetLastToken
(
SyntaxNode
current
,
bool
includeZeroWidth
,
bool
includeSkipped
,
bool
includeDirectives
,
bool
includeDocumentationComments
)
internal
SyntaxToken
GetLastToken
(
in
SyntaxNode
current
,
bool
includeZeroWidth
,
bool
includeSkipped
,
bool
includeDirectives
,
bool
includeDocumentationComments
)
{
return
GetLastToken
(
current
,
GetPredicateFunction
(
includeZeroWidth
),
GetStepIntoFunction
(
includeSkipped
,
includeDirectives
,
includeDocumentationComments
));
}
internal
SyntaxToken
GetPreviousToken
(
SyntaxToken
current
,
bool
includeZeroWidth
,
bool
includeSkipped
,
bool
includeDirectives
,
bool
includeDocumentationComments
)
internal
SyntaxToken
GetPreviousToken
(
in
SyntaxToken
current
,
bool
includeZeroWidth
,
bool
includeSkipped
,
bool
includeDirectives
,
bool
includeDocumentationComments
)
{
return
GetPreviousToken
(
current
,
GetPredicateFunction
(
includeZeroWidth
),
GetStepIntoFunction
(
includeSkipped
,
includeDirectives
,
includeDocumentationComments
));
}
internal
SyntaxToken
GetNextToken
(
SyntaxToken
current
,
bool
includeZeroWidth
,
bool
includeSkipped
,
bool
includeDirectives
,
bool
includeDocumentationComments
)
internal
SyntaxToken
GetNextToken
(
in
SyntaxToken
current
,
bool
includeZeroWidth
,
bool
includeSkipped
,
bool
includeDirectives
,
bool
includeDocumentationComments
)
{
return
GetNextToken
(
current
,
GetPredicateFunction
(
includeZeroWidth
),
GetStepIntoFunction
(
includeSkipped
,
includeDirectives
,
includeDocumentationComments
));
}
internal
SyntaxToken
GetPreviousToken
(
SyntaxToken
current
,
Func
<
SyntaxToken
,
bool
>
predicate
,
Func
<
SyntaxTrivia
,
bool
>
stepInto
)
internal
SyntaxToken
GetPreviousToken
(
in
SyntaxToken
current
,
Func
<
SyntaxToken
,
bool
>
predicate
,
Func
<
SyntaxTrivia
,
bool
>
stepInto
)
{
return
GetPreviousToken
(
current
,
predicate
,
stepInto
!=
null
,
stepInto
);
}
internal
SyntaxToken
GetNextToken
(
SyntaxToken
current
,
Func
<
SyntaxToken
,
bool
>
predicate
,
Func
<
SyntaxTrivia
,
bool
>
stepInto
)
internal
SyntaxToken
GetNextToken
(
in
SyntaxToken
current
,
Func
<
SyntaxToken
,
bool
>
predicate
,
Func
<
SyntaxTrivia
,
bool
>
stepInto
)
{
return
GetNextToken
(
current
,
predicate
,
stepInto
!=
null
,
stepInto
);
}
...
...
@@ -523,7 +523,7 @@ internal SyntaxToken GetLastToken(SyntaxNode current, Func<SyntaxToken, bool> pr
return
default
(
SyntaxToken
);
}
internal
SyntaxToken
GetNextToken
(
SyntaxToken
current
,
Func
<
SyntaxToken
,
bool
>
predicate
,
bool
searchInsideCurrentTokenTrailingTrivia
,
Func
<
SyntaxTrivia
,
bool
>
stepInto
)
internal
SyntaxToken
GetNextToken
(
in
SyntaxToken
current
,
Func
<
SyntaxToken
,
bool
>
predicate
,
bool
searchInsideCurrentTokenTrailingTrivia
,
Func
<
SyntaxTrivia
,
bool
>
stepInto
)
{
Debug
.
Assert
(
searchInsideCurrentTokenTrailingTrivia
==
false
||
stepInto
!=
null
);
if
(
current
.
Parent
!=
null
)
...
...
@@ -575,7 +575,7 @@ internal SyntaxToken GetNextToken(SyntaxToken current, Func<SyntaxToken, bool> p
return
default
(
SyntaxToken
);
}
internal
SyntaxToken
GetPreviousToken
(
SyntaxToken
current
,
Func
<
SyntaxToken
,
bool
>
predicate
,
bool
searchInsideCurrentTokenLeadingTrivia
,
internal
SyntaxToken
GetPreviousToken
(
in
SyntaxToken
current
,
Func
<
SyntaxToken
,
bool
>
predicate
,
bool
searchInsideCurrentTokenLeadingTrivia
,
Func
<
SyntaxTrivia
,
bool
>
stepInto
)
{
Debug
.
Assert
(
searchInsideCurrentTokenLeadingTrivia
==
false
||
stepInto
!=
null
);
...
...
src/Compilers/Core/Portable/Syntax/SyntaxNode.Iterators.cs
浏览文件 @
d2d03c8c
...
...
@@ -32,7 +32,7 @@ private IEnumerable<SyntaxTrivia> DescendantTriviaImpl(TextSpan span, Func<Synta
:
DescendantTriviaOnly
(
span
,
descendIntoChildren
);
}
private
static
bool
IsInSpan
(
ref
TextSpan
span
,
TextSpan
childSpan
)
private
static
bool
IsInSpan
(
in
TextSpan
span
,
TextSpan
childSpan
)
{
return
span
.
OverlapsWith
(
childSpan
)
// special case for zero-width tokens (OverlapsWith never returns true for these)
...
...
@@ -63,13 +63,11 @@ public ChildSyntaxListEnumeratorStack(SyntaxNode startingNode, Func<SyntaxNode,
public
bool
IsNotEmpty
{
get
{
return
_stackPtr
>=
0
;
}
}
public
bool
TryGetNextInSpan
(
ref
/*readonly*/
TextSpan
span
,
out
SyntaxNodeOrToken
value
)
public
bool
TryGetNextInSpan
(
in
TextSpan
span
,
out
SyntaxNodeOrToken
value
)
{
value
=
default
(
SyntaxNodeOrToken
);
while
(
_stack
[
_stackPtr
].
TryMoveNextAndGetCurrent
(
ref
value
))
while
(
_stack
[
_stackPtr
].
TryMoveNextAndGetCurrent
(
out
value
))
{
if
(
IsInSpan
(
ref
span
,
value
.
FullSpan
))
if
(
IsInSpan
(
in
span
,
value
.
FullSpan
))
{
return
true
;
}
...
...
@@ -79,12 +77,12 @@ public bool TryGetNextInSpan(ref /*readonly*/ TextSpan span, out SyntaxNodeOrTok
return
false
;
}
public
SyntaxNode
TryGetNextAsNodeInSpan
(
ref
/*readonly*/
TextSpan
span
)
public
SyntaxNode
TryGetNextAsNodeInSpan
(
in
TextSpan
span
)
{
SyntaxNode
nodeValue
;
while
((
nodeValue
=
_stack
[
_stackPtr
].
TryMoveNextAndGetCurrentAsNode
())
!=
null
)
{
if
(
IsInSpan
(
ref
span
,
nodeValue
.
FullSpan
))
if
(
IsInSpan
(
in
span
,
nodeValue
.
FullSpan
))
{
return
nodeValue
;
}
...
...
@@ -133,9 +131,7 @@ private struct TriviaListEnumeratorStack : IDisposable
public
bool
TryGetNext
(
out
SyntaxTrivia
value
)
{
value
=
default
(
SyntaxTrivia
);
if
(
_stack
[
_stackPtr
].
TryMoveNextAndGetCurrent
(
ref
value
))
if
(
_stack
[
_stackPtr
].
TryMoveNextAndGetCurrent
(
out
value
))
{
return
true
;
}
...
...
@@ -144,16 +140,16 @@ public bool TryGetNext(out SyntaxTrivia value)
return
false
;
}
public
void
PushLeadingTrivia
(
ref
SyntaxToken
token
)
public
void
PushLeadingTrivia
(
in
SyntaxToken
token
)
{
Grow
();
_stack
[
_stackPtr
].
InitializeFromLeadingTrivia
(
ref
token
);
_stack
[
_stackPtr
].
InitializeFromLeadingTrivia
(
in
token
);
}
public
void
PushTrailingTrivia
(
ref
SyntaxToken
token
)
public
void
PushTrailingTrivia
(
in
SyntaxToken
token
)
{
Grow
();
_stack
[
_stackPtr
].
InitializeFromTrailingTrivia
(
ref
token
);
_stack
[
_stackPtr
].
InitializeFromTrailingTrivia
(
in
token
);
}
private
void
Grow
()
...
...
@@ -216,9 +212,9 @@ public Which PeekNext()
return
_discriminatorStack
.
Peek
();
}
public
bool
TryGetNextInSpan
(
ref
TextSpan
span
,
out
SyntaxNodeOrToken
value
)
public
bool
TryGetNextInSpan
(
in
TextSpan
span
,
out
SyntaxNodeOrToken
value
)
{
if
(
_nodeStack
.
TryGetNextInSpan
(
ref
span
,
out
value
))
if
(
_nodeStack
.
TryGetNextInSpan
(
in
span
,
out
value
))
{
return
true
;
}
...
...
@@ -247,15 +243,15 @@ public void PushChildren(SyntaxNode node, Func<SyntaxNode, bool> descendIntoChil
}
}
public
void
PushLeadingTrivia
(
ref
SyntaxToken
token
)
public
void
PushLeadingTrivia
(
in
SyntaxToken
token
)
{
_triviaStack
.
PushLeadingTrivia
(
ref
token
);
_triviaStack
.
PushLeadingTrivia
(
in
token
);
_discriminatorStack
.
Push
(
Which
.
Trivia
);
}
public
void
PushTrailingTrivia
(
ref
SyntaxToken
token
)
public
void
PushTrailingTrivia
(
in
SyntaxToken
token
)
{
_triviaStack
.
PushTrailingTrivia
(
ref
token
);
_triviaStack
.
PushTrailingTrivia
(
in
token
);
_discriminatorStack
.
Push
(
Which
.
Trivia
);
}
...
...
@@ -305,9 +301,9 @@ public Which PeekNext()
return
_discriminatorStack
.
Peek
();
}
public
bool
TryGetNextInSpan
(
ref
TextSpan
span
,
out
SyntaxNodeOrToken
value
)
public
bool
TryGetNextInSpan
(
in
TextSpan
span
,
out
SyntaxNodeOrToken
value
)
{
if
(
_nodeStack
.
TryGetNextInSpan
(
ref
span
,
out
value
))
if
(
_nodeStack
.
TryGetNextInSpan
(
in
span
,
out
value
))
{
return
true
;
}
...
...
@@ -342,19 +338,19 @@ public void PushChildren(SyntaxNode node, Func<SyntaxNode, bool> descendIntoChil
}
}
public
void
PushLeadingTrivia
(
ref
SyntaxToken
token
)
public
void
PushLeadingTrivia
(
in
SyntaxToken
token
)
{
_triviaStack
.
PushLeadingTrivia
(
ref
token
);
_triviaStack
.
PushLeadingTrivia
(
in
token
);
_discriminatorStack
.
Push
(
Which
.
Trivia
);
}
public
void
PushTrailingTrivia
(
ref
SyntaxToken
token
)
public
void
PushTrailingTrivia
(
in
SyntaxToken
token
)
{
_triviaStack
.
PushTrailingTrivia
(
ref
token
);
_triviaStack
.
PushTrailingTrivia
(
in
token
);
_discriminatorStack
.
Push
(
Which
.
Trivia
);
}
public
void
PushToken
(
ref
SyntaxNodeOrToken
value
)
public
void
PushToken
(
in
SyntaxNodeOrToken
value
)
{
_tokenStack
.
Push
(
value
);
_discriminatorStack
.
Push
(
Which
.
Token
);
...
...
@@ -371,7 +367,7 @@ public void Dispose()
private
IEnumerable
<
SyntaxNode
>
DescendantNodesOnly
(
TextSpan
span
,
Func
<
SyntaxNode
,
bool
>
descendIntoChildren
,
bool
includeSelf
)
{
if
(
includeSelf
&&
IsInSpan
(
ref
span
,
this
.
FullSpan
))
if
(
includeSelf
&&
IsInSpan
(
in
span
,
this
.
FullSpan
))
{
yield
return
this
;
}
...
...
@@ -380,7 +376,7 @@ private IEnumerable<SyntaxNode> DescendantNodesOnly(TextSpan span, Func<SyntaxNo
{
while
(
stack
.
IsNotEmpty
)
{
SyntaxNode
nodeValue
=
stack
.
TryGetNextAsNodeInSpan
(
ref
span
);
SyntaxNode
nodeValue
=
stack
.
TryGetNextAsNodeInSpan
(
in
span
);
if
(
nodeValue
!=
null
)
{
// PERF: Push before yield return so that "nodeValue" is 'dead' after the yield
...
...
@@ -396,7 +392,7 @@ private IEnumerable<SyntaxNode> DescendantNodesOnly(TextSpan span, Func<SyntaxNo
private
IEnumerable
<
SyntaxNodeOrToken
>
DescendantNodesAndTokensOnly
(
TextSpan
span
,
Func
<
SyntaxNode
,
bool
>
descendIntoChildren
,
bool
includeSelf
)
{
if
(
includeSelf
&&
IsInSpan
(
ref
span
,
this
.
FullSpan
))
if
(
includeSelf
&&
IsInSpan
(
in
span
,
this
.
FullSpan
))
{
yield
return
this
;
}
...
...
@@ -406,7 +402,7 @@ private IEnumerable<SyntaxNodeOrToken> DescendantNodesAndTokensOnly(TextSpan spa
while
(
stack
.
IsNotEmpty
)
{
SyntaxNodeOrToken
value
;
if
(
stack
.
TryGetNextInSpan
(
ref
span
,
out
value
))
if
(
stack
.
TryGetNextInSpan
(
in
span
,
out
value
))
{
// PERF: Push before yield return so that "value" is 'dead' after the yield
// and therefore doesn't need to be stored in the iterator state machine. This
...
...
@@ -425,7 +421,7 @@ private IEnumerable<SyntaxNodeOrToken> DescendantNodesAndTokensOnly(TextSpan spa
private
IEnumerable
<
SyntaxNodeOrToken
>
DescendantNodesAndTokensIntoTrivia
(
TextSpan
span
,
Func
<
SyntaxNode
,
bool
>
descendIntoChildren
,
bool
includeSelf
)
{
if
(
includeSelf
&&
IsInSpan
(
ref
span
,
this
.
FullSpan
))
if
(
includeSelf
&&
IsInSpan
(
in
span
,
this
.
FullSpan
))
{
yield
return
this
;
}
...
...
@@ -438,7 +434,7 @@ private IEnumerable<SyntaxNodeOrToken> DescendantNodesAndTokensIntoTrivia(TextSp
{
case
ThreeEnumeratorListStack
.
Which
.
Node
:
SyntaxNodeOrToken
value
;
if
(
stack
.
TryGetNextInSpan
(
ref
span
,
out
value
))
if
(
stack
.
TryGetNextInSpan
(
in
span
,
out
value
))
{
// PERF: The following code has an unusual structure (note the 'break' out of
// the case statement from inside an if body) in order to convince the compiler
...
...
@@ -458,16 +454,16 @@ private IEnumerable<SyntaxNodeOrToken> DescendantNodesAndTokensIntoTrivia(TextSp
// trailing trivia comes last
if
(
token
.
HasTrailingTrivia
)
{
stack
.
PushTrailingTrivia
(
ref
token
);
stack
.
PushTrailingTrivia
(
in
token
);
}
// tokens come between leading and trailing trivia
stack
.
PushToken
(
ref
value
);
stack
.
PushToken
(
in
value
);
// leading trivia comes first
if
(
token
.
HasLeadingTrivia
)
{
stack
.
PushLeadingTrivia
(
ref
token
);
stack
.
PushLeadingTrivia
(
in
token
);
}
// Exit the case block without yielding (see PERF note above)
...
...
@@ -489,7 +485,7 @@ private IEnumerable<SyntaxNodeOrToken> DescendantNodesAndTokensIntoTrivia(TextSp
SyntaxTrivia
trivia
;
if
(
stack
.
TryGetNext
(
out
trivia
))
{
if
(
trivia
.
HasStructure
&&
IsInSpan
(
ref
span
,
trivia
.
FullSpan
))
if
(
trivia
.
HasStructure
&&
IsInSpan
(
in
span
,
trivia
.
FullSpan
))
{
var
structureNode
=
trivia
.
GetStructure
();
...
...
@@ -520,7 +516,7 @@ private IEnumerable<SyntaxTrivia> DescendantTriviaOnly(TextSpan span, Func<Synta
while
(
stack
.
IsNotEmpty
)
{
SyntaxNodeOrToken
value
;
if
(
stack
.
TryGetNextInSpan
(
ref
span
,
out
value
))
if
(
stack
.
TryGetNextInSpan
(
in
span
,
out
value
))
{
if
(
value
.
IsNode
)
{
...
...
@@ -534,7 +530,7 @@ private IEnumerable<SyntaxTrivia> DescendantTriviaOnly(TextSpan span, Func<Synta
foreach
(
var
trivia
in
token
.
LeadingTrivia
)
{
if
(
IsInSpan
(
ref
span
,
trivia
.
FullSpan
))
if
(
IsInSpan
(
in
span
,
trivia
.
FullSpan
))
{
yield
return
trivia
;
}
...
...
@@ -542,7 +538,7 @@ private IEnumerable<SyntaxTrivia> DescendantTriviaOnly(TextSpan span, Func<Synta
foreach
(
var
trivia
in
token
.
TrailingTrivia
)
{
if
(
IsInSpan
(
ref
span
,
trivia
.
FullSpan
))
if
(
IsInSpan
(
in
span
,
trivia
.
FullSpan
))
{
yield
return
trivia
;
}
...
...
@@ -563,7 +559,7 @@ private IEnumerable<SyntaxTrivia> DescendantTriviaIntoTrivia(TextSpan span, Func
{
case
TwoEnumeratorListStack
.
Which
.
Node
:
SyntaxNodeOrToken
value
;
if
(
stack
.
TryGetNextInSpan
(
ref
span
,
out
value
))
if
(
stack
.
TryGetNextInSpan
(
in
span
,
out
value
))
{
if
(
value
.
IsNode
)
{
...
...
@@ -576,12 +572,12 @@ private IEnumerable<SyntaxTrivia> DescendantTriviaIntoTrivia(TextSpan span, Func
if
(
token
.
HasTrailingTrivia
)
{
stack
.
PushTrailingTrivia
(
ref
token
);
stack
.
PushTrailingTrivia
(
in
token
);
}
if
(
token
.
HasLeadingTrivia
)
{
stack
.
PushLeadingTrivia
(
ref
token
);
stack
.
PushLeadingTrivia
(
in
token
);
}
}
}
...
...
@@ -602,7 +598,7 @@ private IEnumerable<SyntaxTrivia> DescendantTriviaIntoTrivia(TextSpan span, Func
stack
.
PushChildren
(
structureNode
,
descendIntoChildren
);
}
if
(
IsInSpan
(
ref
span
,
trivia
.
FullSpan
))
if
(
IsInSpan
(
in
span
,
trivia
.
FullSpan
))
{
yield
return
trivia
;
}
...
...
src/Compilers/Core/Portable/Syntax/SyntaxNode.cs
浏览文件 @
d2d03c8c
...
...
@@ -1368,7 +1368,7 @@ protected virtual SyntaxToken FindTokenCore(int position, Func<SyntaxTrivia, boo
return
token
;
}
internal
static
SyntaxTrivia
GetTriviaFromSyntaxToken
(
int
position
,
SyntaxToken
token
)
internal
static
SyntaxTrivia
GetTriviaFromSyntaxToken
(
int
position
,
in
SyntaxToken
token
)
{
var
span
=
token
.
Span
;
var
trivia
=
new
SyntaxTrivia
();
...
...
@@ -1384,7 +1384,7 @@ internal static SyntaxTrivia GetTriviaFromSyntaxToken(int position, SyntaxToken
return
trivia
;
}
internal
static
SyntaxTrivia
GetTriviaThatContainsPosition
(
SyntaxTriviaList
list
,
int
position
)
internal
static
SyntaxTrivia
GetTriviaThatContainsPosition
(
in
SyntaxTriviaList
list
,
int
position
)
{
foreach
(
var
trivia
in
list
)
{
...
...
src/Compilers/Core/Portable/Syntax/SyntaxNodeOrToken.cs
浏览文件 @
d2d03c8c
...
...
@@ -19,7 +19,7 @@ namespace Microsoft.CodeAnalysis
/// </remarks>
[
StructLayout
(
LayoutKind
.
Auto
)]
[
DebuggerDisplay
(
"{GetDebuggerDisplay(), nq}"
)]
public
struct
SyntaxNodeOrToken
:
IEquatable
<
SyntaxNodeOrToken
>
public
readonly
struct
SyntaxNodeOrToken
:
IEquatable
<
SyntaxNodeOrToken
>
{
// In a case if we are wrapping a SyntaxNode this is the SyntaxNode itself.
// In a case where we are wrapping a token, this is the token's parent.
...
...
@@ -801,7 +801,7 @@ internal IList<TDirective> GetDirectives<TDirective>(Func<TDirective, bool> filt
return
directives
??
SpecializedCollections
.
EmptyList
<
TDirective
>();
}
private
static
void
GetDirectives
<
TDirective
>(
SyntaxNodeOrToken
node
,
Func
<
TDirective
,
bool
>
filter
,
ref
List
<
TDirective
>
directives
)
private
static
void
GetDirectives
<
TDirective
>(
in
SyntaxNodeOrToken
node
,
Func
<
TDirective
,
bool
>
filter
,
ref
List
<
TDirective
>
directives
)
where
TDirective
:
SyntaxNode
{
if
(
node
.
_token
!=
null
)
...
...
@@ -836,7 +836,7 @@ private static void GetDirectives<TDirective>(SyntaxToken token, Func<TDirective
}
}
private
static
void
GetDirectives
<
TDirective
>(
SyntaxTriviaList
trivia
,
Func
<
TDirective
,
bool
>
filter
,
ref
List
<
TDirective
>
directives
)
private
static
void
GetDirectives
<
TDirective
>(
in
SyntaxTriviaList
trivia
,
Func
<
TDirective
,
bool
>
filter
,
ref
List
<
TDirective
>
directives
)
where
TDirective
:
SyntaxNode
{
foreach
(
var
tr
in
trivia
)
...
...
src/Compilers/Core/Portable/Syntax/SyntaxNodeOrTokenList.cs
浏览文件 @
d2d03c8c
...
...
@@ -15,7 +15,7 @@ namespace Microsoft.CodeAnalysis
/// <summary>
/// A list of <see cref="SyntaxNodeOrToken"/> structures.
/// </summary>
public
struct
SyntaxNodeOrTokenList
:
IEquatable
<
SyntaxNodeOrTokenList
>,
IReadOnlyCollection
<
SyntaxNodeOrToken
>
public
readonly
struct
SyntaxNodeOrTokenList
:
IEquatable
<
SyntaxNodeOrTokenList
>,
IReadOnlyCollection
<
SyntaxNodeOrToken
>
{
/// <summary>
/// The underlying field
...
...
@@ -500,7 +500,7 @@ public struct Enumerator : IEnumerator<SyntaxNodeOrToken>
private
SyntaxNodeOrTokenList
_list
;
private
int
_index
;
internal
Enumerator
(
SyntaxNodeOrTokenList
list
)
internal
Enumerator
(
in
SyntaxNodeOrTokenList
list
)
:
this
()
{
_list
=
list
;
...
...
src/Compilers/Core/Portable/Syntax/SyntaxNodeOrTokenListBuilder.cs
浏览文件 @
d2d03c8c
...
...
@@ -63,7 +63,17 @@ internal void Add(GreenNode item)
_nodes
[
_count
++]
=
item
;
}
public
void
Add
(
SyntaxNodeOrToken
item
)
public
void
Add
(
SyntaxNode
item
)
{
this
.
Add
(
item
.
Green
);
}
public
void
Add
(
in
SyntaxToken
item
)
{
this
.
Add
(
item
.
Node
);
}
public
void
Add
(
in
SyntaxNodeOrToken
item
)
{
this
.
Add
(
item
.
UnderlyingNode
);
}
...
...
src/Compilers/Core/Portable/Syntax/SyntaxToken.cs
浏览文件 @
d2d03c8c
...
...
@@ -18,7 +18,7 @@ namespace Microsoft.CodeAnalysis
#pragma warning restore CA1200 // Avoid using cref tags with a prefix
[
StructLayout
(
LayoutKind
.
Auto
)]
[
DebuggerDisplay
(
"{GetDebuggerDisplay(), nq}"
)]
public
struct
SyntaxToken
:
IEquatable
<
SyntaxToken
>
public
readonly
struct
SyntaxToken
:
IEquatable
<
SyntaxToken
>
{
private
static
readonly
Func
<
DiagnosticInfo
,
Diagnostic
>
s_createDiagnosticWithoutLocation
=
Diagnostic
.
Create
;
...
...
src/Compilers/Core/Portable/Syntax/SyntaxTokenList.Enumerator.cs
浏览文件 @
d2d03c8c
...
...
@@ -54,7 +54,7 @@ public struct Enumerator
private
GreenNode
_current
;
private
int
_position
;
internal
Enumerator
(
ref
SyntaxTokenList
list
)
internal
Enumerator
(
in
SyntaxTokenList
list
)
{
_parent
=
list
.
_parent
;
_singleNodeOrList
=
list
.
Node
;
...
...
@@ -129,9 +129,9 @@ private class EnumeratorImpl : IEnumerator<SyntaxToken>
private
Enumerator
_enumerator
;
// SyntaxTriviaList is a relatively big struct so is passed by ref
internal
EnumeratorImpl
(
ref
SyntaxTokenList
list
)
internal
EnumeratorImpl
(
in
SyntaxTokenList
list
)
{
_enumerator
=
new
Enumerator
(
ref
list
);
_enumerator
=
new
Enumerator
(
in
list
);
}
public
SyntaxToken
Current
=>
_enumerator
.
Current
;
...
...
src/Compilers/Core/Portable/Syntax/SyntaxTokenList.Reversed.cs
浏览文件 @
d2d03c8c
...
...
@@ -14,9 +14,9 @@ public partial struct SyntaxTokenList
/// <summary>
/// Reversed enumerable.
/// </summary>
public
struct
Reversed
:
IEnumerable
<
SyntaxToken
>,
IEquatable
<
Reversed
>
public
readonly
struct
Reversed
:
IEnumerable
<
SyntaxToken
>,
IEquatable
<
Reversed
>
{
private
SyntaxTokenList
_list
;
private
readonly
SyntaxTokenList
_list
;
public
Reversed
(
SyntaxTokenList
list
)
{
...
...
@@ -25,7 +25,7 @@ public Reversed(SyntaxTokenList list)
public
Enumerator
GetEnumerator
()
{
return
new
Enumerator
(
ref
_list
);
return
new
Enumerator
(
in
_list
);
}
IEnumerator
<
SyntaxToken
>
IEnumerable
<
SyntaxToken
>.
GetEnumerator
()
...
...
@@ -35,7 +35,7 @@ IEnumerator<SyntaxToken> IEnumerable<SyntaxToken>.GetEnumerator()
return
SpecializedCollections
.
EmptyEnumerator
<
SyntaxToken
>();
}
return
new
EnumeratorImpl
(
ref
_list
);
return
new
EnumeratorImpl
(
in
_list
);
}
IEnumerator
IEnumerable
.
GetEnumerator
()
...
...
@@ -45,7 +45,7 @@ IEnumerator IEnumerable.GetEnumerator()
return
SpecializedCollections
.
EmptyEnumerator
<
SyntaxToken
>();
}
return
new
EnumeratorImpl
(
ref
_list
);
return
new
EnumeratorImpl
(
in
_list
);
}
public
override
bool
Equals
(
object
obj
)
...
...
@@ -76,7 +76,7 @@ public struct Enumerator
private
GreenNode
_current
;
private
int
_position
;
public
Enumerator
(
ref
SyntaxTokenList
list
)
internal
Enumerator
(
in
SyntaxTokenList
list
)
:
this
()
{
if
(
list
.
Any
())
...
...
@@ -139,9 +139,9 @@ private class EnumeratorImpl : IEnumerator<SyntaxToken>
private
Enumerator
_enumerator
;
// SyntaxTriviaList is a relatively big struct so is passed as ref
internal
EnumeratorImpl
(
ref
SyntaxTokenList
list
)
internal
EnumeratorImpl
(
in
SyntaxTokenList
list
)
{
_enumerator
=
new
Enumerator
(
ref
list
);
_enumerator
=
new
Enumerator
(
in
list
);
}
public
SyntaxToken
Current
=>
_enumerator
.
Current
;
...
...
src/Compilers/Core/Portable/Syntax/SyntaxTokenList.cs
浏览文件 @
d2d03c8c
...
...
@@ -16,7 +16,7 @@ namespace Microsoft.CodeAnalysis
/// Represents a read-only list of <see cref="SyntaxToken"/>.
/// </summary>
[
StructLayout
(
LayoutKind
.
Auto
)]
public
partial
struct
SyntaxTokenList
:
IEquatable
<
SyntaxTokenList
>,
IReadOnlyList
<
SyntaxToken
>
public
readonly
partial
struct
SyntaxTokenList
:
IEquatable
<
SyntaxTokenList
>,
IReadOnlyList
<
SyntaxToken
>
{
private
readonly
SyntaxNode
_parent
;
private
readonly
int
_index
;
...
...
@@ -431,7 +431,7 @@ public SyntaxTokenList ReplaceRange(SyntaxToken tokenInList, IEnumerable<SyntaxT
/// </summary>
public
Enumerator
GetEnumerator
()
{
return
new
Enumerator
(
ref
this
);
return
new
Enumerator
(
in
this
);
}
IEnumerator
<
SyntaxToken
>
IEnumerable
<
SyntaxToken
>.
GetEnumerator
()
...
...
@@ -441,7 +441,7 @@ IEnumerator<SyntaxToken> IEnumerable<SyntaxToken>.GetEnumerator()
return
SpecializedCollections
.
EmptyEnumerator
<
SyntaxToken
>();
}
return
new
EnumeratorImpl
(
ref
this
);
return
new
EnumeratorImpl
(
in
this
);
}
IEnumerator
IEnumerable
.
GetEnumerator
()
...
...
@@ -451,7 +451,7 @@ IEnumerator IEnumerable.GetEnumerator()
return
SpecializedCollections
.
EmptyEnumerator
<
SyntaxToken
>();
}
return
new
EnumeratorImpl
(
ref
this
);
return
new
EnumeratorImpl
(
in
this
);
}
/// <summary>
...
...
src/Compilers/Core/Portable/Syntax/SyntaxTrivia.cs
浏览文件 @
d2d03c8c
...
...
@@ -17,11 +17,11 @@ namespace Microsoft.CodeAnalysis
#pragma warning restore CA1200 // Avoid using cref tags with a prefix
[
DebuggerDisplay
(
"{GetDebuggerDisplay(), nq}"
)]
[
StructLayout
(
LayoutKind
.
Auto
)]
public
struct
SyntaxTrivia
:
IEquatable
<
SyntaxTrivia
>
public
readonly
struct
SyntaxTrivia
:
IEquatable
<
SyntaxTrivia
>
{
internal
static
readonly
Func
<
SyntaxTrivia
,
bool
>
Any
=
t
=>
true
;
internal
SyntaxTrivia
(
SyntaxToken
token
,
GreenNode
triviaNode
,
int
position
,
int
index
)
internal
SyntaxTrivia
(
in
SyntaxToken
token
,
GreenNode
triviaNode
,
int
position
,
int
index
)
{
Token
=
token
;
UnderlyingNode
=
triviaNode
;
...
...
src/Compilers/Core/Portable/Syntax/SyntaxTriviaList.Enumerator.cs
浏览文件 @
d2d03c8c
...
...
@@ -21,7 +21,7 @@ public struct Enumerator
private
GreenNode
_current
;
private
int
_position
;
internal
Enumerator
(
ref
SyntaxTriviaList
list
)
internal
Enumerator
(
in
SyntaxTriviaList
list
)
{
_token
=
list
.
Token
;
_singleNodeOrList
=
list
.
Node
;
...
...
@@ -34,7 +34,7 @@ internal Enumerator(ref SyntaxTriviaList list)
}
// PERF: Passing SyntaxToken by ref since it's a non-trivial struct
private
void
InitializeFrom
(
ref
SyntaxToken
token
,
GreenNode
greenNode
,
int
index
,
int
position
)
private
void
InitializeFrom
(
in
SyntaxToken
token
,
GreenNode
greenNode
,
int
index
,
int
position
)
{
_token
=
token
;
_singleNodeOrList
=
greenNode
;
...
...
@@ -49,15 +49,15 @@ private void InitializeFrom(ref SyntaxToken token, GreenNode greenNode, int inde
// PERF: Used to initialize an enumerator for leading trivia directly from a token.
// This saves constructing an intermediate SyntaxTriviaList. Also, passing token
// by ref since it's a non-trivial struct
internal
void
InitializeFromLeadingTrivia
(
ref
SyntaxToken
token
)
internal
void
InitializeFromLeadingTrivia
(
in
SyntaxToken
token
)
{
InitializeFrom
(
ref
token
,
token
.
Node
.
GetLeadingTriviaCore
(),
0
,
token
.
Position
);
InitializeFrom
(
in
token
,
token
.
Node
.
GetLeadingTriviaCore
(),
0
,
token
.
Position
);
}
// PERF: Used to initialize an enumerator for trailing trivia directly from a token.
// This saves constructing an intermediate SyntaxTriviaList. Also, passing token
// by ref since it's a non-trivial struct
internal
void
InitializeFromTrailingTrivia
(
ref
SyntaxToken
token
)
internal
void
InitializeFromTrailingTrivia
(
in
SyntaxToken
token
)
{
var
leading
=
token
.
Node
.
GetLeadingTriviaCore
();
int
index
=
0
;
...
...
@@ -73,7 +73,7 @@ internal void InitializeFromTrailingTrivia(ref SyntaxToken token)
trailingPosition
-=
trailingGreen
.
FullWidth
;
}
InitializeFrom
(
ref
token
,
trailingGreen
,
index
,
trailingPosition
);
InitializeFrom
(
in
token
,
trailingGreen
,
index
,
trailingPosition
);
}
public
bool
MoveNext
()
...
...
@@ -110,10 +110,11 @@ public SyntaxTrivia Current
}
}
internal
bool
TryMoveNextAndGetCurrent
(
ref
SyntaxTrivia
current
)
internal
bool
TryMoveNextAndGetCurrent
(
out
SyntaxTrivia
current
)
{
if
(!
MoveNext
())
{
current
=
default
;
return
false
;
}
...
...
@@ -127,9 +128,9 @@ private class EnumeratorImpl : IEnumerator<SyntaxTrivia>
private
Enumerator
_enumerator
;
// SyntaxTriviaList is a relatively big struct so is passed as ref
internal
EnumeratorImpl
(
ref
SyntaxTriviaList
list
)
internal
EnumeratorImpl
(
in
SyntaxTriviaList
list
)
{
_enumerator
=
new
Enumerator
(
ref
list
);
_enumerator
=
new
Enumerator
(
in
list
);
}
public
SyntaxTrivia
Current
=>
_enumerator
.
Current
;
...
...
src/Compilers/Core/Portable/Syntax/SyntaxTriviaList.Reversed.cs
浏览文件 @
d2d03c8c
...
...
@@ -13,9 +13,9 @@ public partial struct SyntaxTriviaList
/// <summary>
/// Reversed enumerable.
/// </summary>
public
struct
Reversed
:
IEnumerable
<
SyntaxTrivia
>,
IEquatable
<
Reversed
>
public
readonly
struct
Reversed
:
IEnumerable
<
SyntaxTrivia
>,
IEquatable
<
Reversed
>
{
private
SyntaxTriviaList
_list
;
private
readonly
SyntaxTriviaList
_list
;
public
Reversed
(
SyntaxTriviaList
list
)
{
...
...
@@ -24,7 +24,7 @@ public Reversed(SyntaxTriviaList list)
public
Enumerator
GetEnumerator
()
{
return
new
Enumerator
(
ref
_list
);
return
new
Enumerator
(
in
_list
);
}
IEnumerator
<
SyntaxTrivia
>
IEnumerable
<
SyntaxTrivia
>.
GetEnumerator
()
...
...
@@ -34,7 +34,7 @@ IEnumerator<SyntaxTrivia> IEnumerable<SyntaxTrivia>.GetEnumerator()
return
SpecializedCollections
.
EmptyEnumerator
<
SyntaxTrivia
>();
}
return
new
ReversedEnumeratorImpl
(
ref
_list
);
return
new
ReversedEnumeratorImpl
(
in
_list
);
}
IEnumerator
...
...
@@ -45,7 +45,7 @@ IEnumerator<SyntaxTrivia> IEnumerable<SyntaxTrivia>.GetEnumerator()
return
SpecializedCollections
.
EmptyEnumerator
<
SyntaxTrivia
>();
}
return
new
ReversedEnumeratorImpl
(
ref
_list
);
return
new
ReversedEnumeratorImpl
(
in
_list
);
}
public
override
int
GetHashCode
()
...
...
@@ -75,7 +75,7 @@ public struct Enumerator
private
GreenNode
_current
;
private
int
_position
;
public
Enumerator
(
ref
SyntaxTriviaList
list
)
internal
Enumerator
(
in
SyntaxTriviaList
list
)
:
this
()
{
if
(
list
.
Any
())
...
...
@@ -128,9 +128,9 @@ private class ReversedEnumeratorImpl : IEnumerator<SyntaxTrivia>
private
Enumerator
_enumerator
;
// SyntaxTriviaList is a relatively big struct so is passed as ref
internal
ReversedEnumeratorImpl
(
ref
SyntaxTriviaList
list
)
internal
ReversedEnumeratorImpl
(
in
SyntaxTriviaList
list
)
{
_enumerator
=
new
Enumerator
(
ref
list
);
_enumerator
=
new
Enumerator
(
in
list
);
}
public
SyntaxTrivia
Current
=>
_enumerator
.
Current
;
...
...
src/Compilers/Core/Portable/Syntax/SyntaxTriviaList.cs
浏览文件 @
d2d03c8c
...
...
@@ -17,11 +17,11 @@ namespace Microsoft.CodeAnalysis
/// Represents a read-only list of <see cref="SyntaxTrivia"/>.
/// </summary>
[
StructLayout
(
LayoutKind
.
Auto
)]
public
partial
struct
SyntaxTriviaList
:
IEquatable
<
SyntaxTriviaList
>,
IReadOnlyList
<
SyntaxTrivia
>
public
readonly
partial
struct
SyntaxTriviaList
:
IEquatable
<
SyntaxTriviaList
>,
IReadOnlyList
<
SyntaxTrivia
>
{
public
static
SyntaxTriviaList
Empty
=>
default
(
SyntaxTriviaList
);
internal
SyntaxTriviaList
(
SyntaxToken
token
,
GreenNode
node
,
int
position
,
int
index
=
0
)
internal
SyntaxTriviaList
(
in
SyntaxToken
token
,
GreenNode
node
,
int
position
,
int
index
=
0
)
{
Token
=
token
;
Node
=
node
;
...
...
@@ -29,7 +29,7 @@ internal SyntaxTriviaList(SyntaxToken token, GreenNode node, int position, int i
Index
=
index
;
}
internal
SyntaxTriviaList
(
SyntaxToken
token
,
GreenNode
node
)
internal
SyntaxTriviaList
(
in
SyntaxToken
token
,
GreenNode
node
)
{
Token
=
token
;
Node
=
node
;
...
...
@@ -205,7 +205,7 @@ public Reversed Reverse()
public
Enumerator
GetEnumerator
()
{
return
new
Enumerator
(
ref
this
);
return
new
Enumerator
(
in
this
);
}
public
int
IndexOf
(
SyntaxTrivia
triviaInList
)
...
...
@@ -411,7 +411,7 @@ IEnumerator<SyntaxTrivia> IEnumerable<SyntaxTrivia>.GetEnumerator()
return
SpecializedCollections
.
EmptyEnumerator
<
SyntaxTrivia
>();
}
return
new
EnumeratorImpl
(
ref
this
);
return
new
EnumeratorImpl
(
in
this
);
}
IEnumerator
IEnumerable
.
GetEnumerator
()
...
...
@@ -421,7 +421,7 @@ IEnumerator IEnumerable.GetEnumerator()
return
SpecializedCollections
.
EmptyEnumerator
<
SyntaxTrivia
>();
}
return
new
EnumeratorImpl
(
ref
this
);
return
new
EnumeratorImpl
(
in
this
);
}
/// <summary>
...
...
src/Compilers/Core/Portable/Syntax/SyntaxTriviaListBuilder.cs
浏览文件 @
d2d03c8c
...
...
@@ -94,12 +94,12 @@ public void Add(SyntaxTrivia[] items, int offset, int length)
_count
+=
length
;
}
public
void
Add
(
SyntaxTriviaList
list
)
public
void
Add
(
in
SyntaxTriviaList
list
)
{
this
.
Add
(
list
,
0
,
list
.
Count
);
}
public
void
Add
(
SyntaxTriviaList
list
,
int
offset
,
int
length
)
public
void
Add
(
in
SyntaxTriviaList
list
,
int
offset
,
int
length
)
{
if
(
_nodes
==
null
||
_count
+
length
>
_nodes
.
Length
)
{
...
...
src/Compilers/Core/Portable/Syntax/SyntaxWalker.cs
浏览文件 @
d2d03c8c
...
...
@@ -66,7 +66,7 @@ protected virtual void VisitToken(SyntaxToken token)
}
}
private
void
VisitLeadingTrivia
(
SyntaxToken
token
)
private
void
VisitLeadingTrivia
(
in
SyntaxToken
token
)
{
if
(
token
.
HasLeadingTrivia
)
{
...
...
@@ -77,7 +77,7 @@ private void VisitLeadingTrivia(SyntaxToken token)
}
}
private
void
VisitTrailingTrivia
(
SyntaxToken
token
)
private
void
VisitTrailingTrivia
(
in
SyntaxToken
token
)
{
if
(
token
.
HasTrailingTrivia
)
{
...
...
src/Compilers/Core/Portable/Text/LinePosition.cs
浏览文件 @
d2d03c8c
...
...
@@ -8,7 +8,7 @@ namespace Microsoft.CodeAnalysis.Text
/// <summary>
/// Immutable representation of a line number and position within a SourceText instance.
/// </summary>
public
struct
LinePosition
:
IEquatable
<
LinePosition
>,
IComparable
<
LinePosition
>
public
readonly
struct
LinePosition
:
IEquatable
<
LinePosition
>,
IComparable
<
LinePosition
>
{
/// <summary>
/// A <see cref="LinePosition"/> that represents position 0 at line 0.
...
...
src/Compilers/Core/Portable/Text/LinePositionSpan.cs
浏览文件 @
d2d03c8c
...
...
@@ -8,7 +8,7 @@ namespace Microsoft.CodeAnalysis.Text
/// <summary>
/// Immutable span represented by a pair of line number and index within the line.
/// </summary>
public
struct
LinePositionSpan
:
IEquatable
<
LinePositionSpan
>
public
readonly
struct
LinePositionSpan
:
IEquatable
<
LinePositionSpan
>
{
private
readonly
LinePosition
_start
;
private
readonly
LinePosition
_end
;
...
...
src/Compilers/Core/Portable/Text/TextChange.cs
浏览文件 @
d2d03c8c
...
...
@@ -10,7 +10,7 @@ namespace Microsoft.CodeAnalysis.Text
/// <summary>
/// Describes a single change when a particular span is replaced with a new text.
/// </summary>
public
struct
TextChange
:
IEquatable
<
TextChange
>
public
readonly
struct
TextChange
:
IEquatable
<
TextChange
>
{
/// <summary>
/// The original span of the changed text.
...
...
src/Compilers/Core/Portable/Text/TextChangeRange.cs
浏览文件 @
d2d03c8c
...
...
@@ -10,7 +10,7 @@ namespace Microsoft.CodeAnalysis.Text
/// <summary>
/// Represents the change to a span of text.
/// </summary>
public
struct
TextChangeRange
:
IEquatable
<
TextChangeRange
>
public
readonly
struct
TextChangeRange
:
IEquatable
<
TextChangeRange
>
{
/// <summary>
/// The span of text before the edit which is being changed
...
...
src/Compilers/Core/Portable/Text/TextLine.cs
浏览文件 @
d2d03c8c
...
...
@@ -8,7 +8,7 @@ namespace Microsoft.CodeAnalysis.Text
/// <summary>
/// Information about the character boundaries of a single line of text.
/// </summary>
public
struct
TextLine
:
IEquatable
<
TextLine
>
public
readonly
struct
TextLine
:
IEquatable
<
TextLine
>
{
private
readonly
SourceText
_text
;
private
readonly
int
_start
;
...
...
src/Compilers/Core/Portable/Text/TextSpan.cs
浏览文件 @
d2d03c8c
...
...
@@ -9,7 +9,7 @@ namespace Microsoft.CodeAnalysis.Text
/// Immutable abstract representation of a span of text. For example, in an error diagnostic that reports a
/// location, it could come from a parsed string, text from a tool editor buffer, etc.
/// </summary>
public
struct
TextSpan
:
IEquatable
<
TextSpan
>,
IComparable
<
TextSpan
>
public
readonly
struct
TextSpan
:
IEquatable
<
TextSpan
>,
IComparable
<
TextSpan
>
{
/// <summary>
/// Creates a TextSpan instance beginning with the position Start and having the Length
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录