Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
7e46750f
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,发现更多精彩内容 >>
提交
7e46750f
编写于
12月 12, 2019
作者:
A
Amaury Levé
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add xml documentation for IsKind and Kind extension methods
上级
bbe84f5b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
66 addition
and
21 deletion
+66
-21
src/Compilers/CSharp/Portable/CSharpExtensions.cs
src/Compilers/CSharp/Portable/CSharpExtensions.cs
+42
-2
src/Compilers/VisualBasic/Portable/VisualBasicExtensions.vb
src/Compilers/VisualBasic/Portable/VisualBasicExtensions.vb
+24
-19
未找到文件。
src/Compilers/CSharp/Portable/CSharpExtensions.cs
浏览文件 @
7e46750f
...
...
@@ -6,29 +6,52 @@
using
System.Threading
;
using
Microsoft.CodeAnalysis.CSharp
;
using
Microsoft.CodeAnalysis.CSharp.Syntax
;
using
Microsoft.CodeAnalysis.CSharp.Symbols
;
using
Microsoft.CodeAnalysis.Syntax
;
using
Microsoft.CodeAnalysis.Operations
;
using
Microsoft.CodeAnalysis.Syntax
;
namespace
Microsoft.CodeAnalysis
{
public
static
class
CSharpExtensions
{
/// <summary>
/// Determines if <see cref="SyntaxToken"/> is of a specified kind.
/// </summary>
/// <param name="token">The source token.</param>
/// <param name="kind">The syntax kind to test for.</param>
/// <returns><c>true</c> if token is of specified kind; <c>false</c> otherwise.</returns>
public
static
bool
IsKind
(
this
SyntaxToken
token
,
SyntaxKind
kind
)
{
return
token
.
RawKind
==
(
int
)
kind
;
}
/// <summary>
/// Determines if <see cref="SyntaxTrivia"/> is of a specified kind.
/// </summary>
/// <param name="trivia">The source trivia.</param>
/// <param name="kind">The syntax kind to test for.</param>
/// <returns><c>true</c> if trivia is of specified kind; <c>false</c> otherwise.</returns>
public
static
bool
IsKind
(
this
SyntaxTrivia
trivia
,
SyntaxKind
kind
)
{
return
trivia
.
RawKind
==
(
int
)
kind
;
}
/// <summary>
/// Determines if <see cref="SyntaxNode"/> is of a specified kind.
/// </summary>
/// <param name="node">The source node.</param>
/// <param name="kind">The syntax kind to test for.</param>
/// <returns><c>true</c> if node is of specified kind; <c>false</c> otherwise.</returns>
public
static
bool
IsKind
(
this
SyntaxNode
node
,
SyntaxKind
kind
)
{
return
node
?.
RawKind
==
(
int
)
kind
;
}
/// <summary>
/// Determines if <see cref="SyntaxNodeOrToken"/> is of a specified kind.
/// </summary>
/// <param name="nodeOrToken">The source node or token.</param>
/// <param name="kind">The syntax kind to test for.</param>
/// <returns><c>true</c> if node or token is of specified kind; <c>false</c> otherwise.</returns>
public
static
bool
IsKind
(
this
SyntaxNodeOrToken
nodeOrToken
,
SyntaxKind
kind
)
{
return
nodeOrToken
.
RawKind
==
(
int
)
kind
;
...
...
@@ -139,6 +162,11 @@ namespace Microsoft.CodeAnalysis.CSharp
{
public
static
class
CSharpExtensions
{
/// <summary>
/// Determines if the given raw kind value belongs to the C# <see cref="SyntaxKind"/> enumeration.
/// </summary>
/// <param name="rawKind">The raw value to test.</param>
/// <returns><c>true</c> when the raw value belongs to the C# syntax kind; <c>false</c> otherwise.</returns>
internal
static
bool
IsCSharpKind
(
int
rawKind
)
{
const
int
FirstVisualBasicKind
=
(
int
)
SyntaxKind
.
List
+
1
;
...
...
@@ -148,24 +176,36 @@ internal static bool IsCSharpKind(int rawKind)
return
unchecked
((
uint
)(
rawKind
-
FirstVisualBasicKind
))
>
(
FirstCSharpKind
-
1
-
FirstVisualBasicKind
);
}
/// <summary>
/// Returns <see cref="SyntaxKind"/> for <see cref="SyntaxToken"/> from <see cref="SyntaxToken.RawKind"/> property.
/// </summary>
public
static
SyntaxKind
Kind
(
this
SyntaxToken
token
)
{
var
rawKind
=
token
.
RawKind
;
return
IsCSharpKind
(
rawKind
)
?
(
SyntaxKind
)
rawKind
:
SyntaxKind
.
None
;
}
/// <summary>
/// Returns <see cref="SyntaxKind"/> for <see cref="SyntaxTrivia"/> from <see cref="SyntaxTrivia.RawKind"/> property.
/// </summary>
public
static
SyntaxKind
Kind
(
this
SyntaxTrivia
trivia
)
{
var
rawKind
=
trivia
.
RawKind
;
return
IsCSharpKind
(
rawKind
)
?
(
SyntaxKind
)
rawKind
:
SyntaxKind
.
None
;
}
/// <summary>
/// Returns <see cref="SyntaxKind"/> for <see cref="SyntaxNode"/> from <see cref="SyntaxNode.RawKind"/> property.
/// </summary>
public
static
SyntaxKind
Kind
(
this
SyntaxNode
node
)
{
var
rawKind
=
node
.
RawKind
;
return
IsCSharpKind
(
rawKind
)
?
(
SyntaxKind
)
rawKind
:
SyntaxKind
.
None
;
}
/// <summary>
/// Returns <see cref="SyntaxKind"/> for <see cref="SyntaxNode"/> from <see cref="SyntaxNodeOrToken.RawKind"/> property.
/// </summary>
public
static
SyntaxKind
Kind
(
this
SyntaxNodeOrToken
nodeOrToken
)
{
var
rawKind
=
nodeOrToken
.
RawKind
;
...
...
src/Compilers/VisualBasic/Portable/VisualBasicExtensions.vb
浏览文件 @
7e46750f
...
...
@@ -2,8 +2,6 @@
Imports
System.Collections.Immutable
Imports
System.Collections.ObjectModel
Imports
System.ComponentModel
Imports
System.IO
Imports
System.Runtime.CompilerServices
Imports
System.Runtime.InteropServices
Imports
System.Threading
...
...
@@ -20,42 +18,44 @@ Namespace Microsoft.CodeAnalysis
Public
Module
VisualBasicExtensions
''' <summary>
''' Determines if
SyntaxTrivia is
a specified kind.
''' Determines if
<see cref="SyntaxTrivia"/> is of
a specified kind.
''' </summary>
'''<param name="trivia">The Source SyntaxTrivia.</param>
''' <param name="kind">The SyntaxKind to test for.</param>
''' <param name="trivia">The source trivia.</param>
''' <param name="kind">The syntax kind to test for.</param>
''' <returns><c>true</c> if triviq is of specified kind; <c>false</c> otherwise.</returns>
<
Extension
>
Public
Function
IsKind
(
trivia
As
SyntaxTrivia
,
kind
As
SyntaxKind
)
As
Boolean
Return
trivia
.
RawKind
=
kind
End
Function
''' <summary>
''' Determines if
SyntaxToken is
a specified kind.
''' Determines if
<see cref="SyntaxToken"/> is of
a specified kind.
''' </summary>
'''<param name="token">The Source SyntaxToken.</param>
''' <param name="kind">The SyntaxKind to test for.</param>
''' <param name="token">The source token.</param>
''' <param name="kind">The syntax kind to test for.</param>
''' <returns><c>true</c> if token is of specified kind; <c>false</c> otherwise.</returns>
<
Extension
>
Public
Function
IsKind
(
token
As
SyntaxToken
,
kind
As
SyntaxKind
)
As
Boolean
Return
token
.
RawKind
=
kind
End
Function
''' <summary>
''' Determines if
SyntaxNode is
a specified kind.
''' Determines if
<see cref="SyntaxNode"/> is of
a specified kind.
''' </summary>
''' <param name="node">The Source
SyntaxN
ode.</param>
''' <param name="kind">The
SyntaxKind
to test for.</param>
''' <returns>
A boolean value if node is of specified kind; otherwise fal
se.</returns>
''' <param name="node">The Source
n
ode.</param>
''' <param name="kind">The
syntax kind
to test for.</param>
''' <returns>
<c>true</c> if node is of specified kind; <c>false</c> otherwi
se.</returns>
<
Extension
>
Public
Function
IsKind
(
node
As
SyntaxNode
,
kind
As
SyntaxKind
)
As
Boolean
Return
node
IsNot
Nothing
AndAlso
node
.
RawKind
=
kind
End
Function
''' <summary>
''' Determines if
a SyntaxNodeOrToken is
a specified kind.
''' Determines if
<see cref="SyntaxNodeOrToken"/> is of
a specified kind.
''' </summary>
''' <param name="nodeOrToken">The source
SyntaxNodeOrT
oken.</param>
''' <param name="kind">The
SyntaxK
ind to test for.</param>
''' <returns>
A boolean value if nodeOrToken is of specified kind; otherwise fal
se.</returns>
''' <param name="nodeOrToken">The source
node or t
oken.</param>
''' <param name="kind">The
syntax k
ind to test for.</param>
''' <returns>
<c>true</c> if node or token is of specified kind; <c>false</c> otherwi
se.</returns>
<
Extension
>
Public
Function
IsKind
(
nodeOrToken
As
SyntaxNodeOrToken
,
kind
As
SyntaxKind
)
As
Boolean
Return
nodeOrToken
.
RawKind
=
kind
...
...
@@ -164,6 +164,11 @@ End Namespace
Namespace
Microsoft.CodeAnalysis.VisualBasic
Public
Module
VisualBasicExtensions
''' <summary>
''' Determines if the given raw kind value belongs to the Visual Basic <see cref="SyntaxKind"/> enumeration.
''' </summary>
''' <param name="rawKind">The raw value to test.</param>
''' <returns><c>true</c> when the raw value belongs to the Visual Basic syntax kind; <c>false</c> otherwise.</returns>
Friend
Function
IsVisualBasicKind
(
rawKind
As
Integer
)
As
Boolean
Const
LastPossibleVisualBasicKind
As
Integer
=
8192
...
...
@@ -171,7 +176,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
End
Function
''' <summary>
''' Returns <see cref="SyntaxKind"/> for <see cref="SyntaxTrivia"/>
nodes
.
''' Returns <see cref="SyntaxKind"/> for <see cref="SyntaxTrivia"/>
from <see cref="SyntaxTrivia.RawKind"/> property
.
''' </summary>
<
Extension
>
Public
Function
Kind
(
trivia
As
SyntaxTrivia
)
As
SyntaxKind
...
...
@@ -189,7 +194,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
End
Function
''' <summary>
''' Returns <see cref="SyntaxKind"/> for <see cref="SyntaxNode"/> from <see cref="Syntax
Token
.RawKind"/> property.
''' Returns <see cref="SyntaxKind"/> for <see cref="SyntaxNode"/> from <see cref="Syntax
Node
.RawKind"/> property.
''' </summary>
<
Extension
>
Public
Function
Kind
(
node
As
SyntaxNode
)
As
SyntaxKind
...
...
@@ -198,7 +203,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
End
Function
''' <summary>
''' Returns <see cref="SyntaxKind"/> for <see cref="SyntaxNodeOrToken"/> from <see cref="SyntaxToken.RawKind"/> property.
''' Returns <see cref="SyntaxKind"/> for <see cref="SyntaxNodeOrToken"/> from <see cref="Syntax
NodeOr
Token.RawKind"/> property.
''' </summary>
<
Extension
>
Public
Function
Kind
(
nodeOrToken
As
SyntaxNodeOrToken
)
As
SyntaxKind
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录