From 7e46750fff2a57ce72381579dab50992a884b2a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Amaury=20Lev=C3=A9?= Date: Thu, 12 Dec 2019 10:50:27 +0100 Subject: [PATCH] Add xml documentation for IsKind and Kind extension methods --- .../CSharp/Portable/CSharpExtensions.cs | 44 ++++++++++++++++++- .../Portable/VisualBasicExtensions.vb | 43 ++++++++++-------- 2 files changed, 66 insertions(+), 21 deletions(-) diff --git a/src/Compilers/CSharp/Portable/CSharpExtensions.cs b/src/Compilers/CSharp/Portable/CSharpExtensions.cs index 8c44283402f..06da90f727a 100644 --- a/src/Compilers/CSharp/Portable/CSharpExtensions.cs +++ b/src/Compilers/CSharp/Portable/CSharpExtensions.cs @@ -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 { + /// + /// Determines if is of a specified kind. + /// + /// The source token. + /// The syntax kind to test for. + /// true if token is of specified kind; false otherwise. public static bool IsKind(this SyntaxToken token, SyntaxKind kind) { return token.RawKind == (int)kind; } + /// + /// Determines if is of a specified kind. + /// + /// The source trivia. + /// The syntax kind to test for. + /// true if trivia is of specified kind; false otherwise. public static bool IsKind(this SyntaxTrivia trivia, SyntaxKind kind) { return trivia.RawKind == (int)kind; } + /// + /// Determines if is of a specified kind. + /// + /// The source node. + /// The syntax kind to test for. + /// true if node is of specified kind; false otherwise. public static bool IsKind(this SyntaxNode node, SyntaxKind kind) { return node?.RawKind == (int)kind; } + /// + /// Determines if is of a specified kind. + /// + /// The source node or token. + /// The syntax kind to test for. + /// true if node or token is of specified kind; false otherwise. 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 { + /// + /// Determines if the given raw kind value belongs to the C# enumeration. + /// + /// The raw value to test. + /// true when the raw value belongs to the C# syntax kind; false otherwise. 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); } + /// + /// Returns for from property. + /// public static SyntaxKind Kind(this SyntaxToken token) { var rawKind = token.RawKind; return IsCSharpKind(rawKind) ? (SyntaxKind)rawKind : SyntaxKind.None; } + /// + /// Returns for from property. + /// public static SyntaxKind Kind(this SyntaxTrivia trivia) { var rawKind = trivia.RawKind; return IsCSharpKind(rawKind) ? (SyntaxKind)rawKind : SyntaxKind.None; } + /// + /// Returns for from property. + /// public static SyntaxKind Kind(this SyntaxNode node) { var rawKind = node.RawKind; return IsCSharpKind(rawKind) ? (SyntaxKind)rawKind : SyntaxKind.None; } + /// + /// Returns for from property. + /// public static SyntaxKind Kind(this SyntaxNodeOrToken nodeOrToken) { var rawKind = nodeOrToken.RawKind; diff --git a/src/Compilers/VisualBasic/Portable/VisualBasicExtensions.vb b/src/Compilers/VisualBasic/Portable/VisualBasicExtensions.vb index 629342c9304..bf579208089 100644 --- a/src/Compilers/VisualBasic/Portable/VisualBasicExtensions.vb +++ b/src/Compilers/VisualBasic/Portable/VisualBasicExtensions.vb @@ -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 ''' - ''' Determines if SyntaxTrivia is a specified kind. + ''' Determines if is of a specified kind. ''' - '''The Source SyntaxTrivia. - ''' The SyntaxKind to test for. + ''' The source trivia. + ''' The syntax kind to test for. + ''' true if triviq is of specified kind; false otherwise. Public Function IsKind(trivia As SyntaxTrivia, kind As SyntaxKind) As Boolean Return trivia.RawKind = kind End Function ''' - ''' Determines if SyntaxToken is a specified kind. + ''' Determines if is of a specified kind. ''' - '''The Source SyntaxToken. - ''' The SyntaxKind to test for. + ''' The source token. + ''' The syntax kind to test for. + ''' true if token is of specified kind; false otherwise. Public Function IsKind(token As SyntaxToken, kind As SyntaxKind) As Boolean Return token.RawKind = kind End Function ''' - ''' Determines if SyntaxNode is a specified kind. + ''' Determines if is of a specified kind. ''' - ''' The Source SyntaxNode. - ''' The SyntaxKind to test for. - ''' A boolean value if node is of specified kind; otherwise false. + ''' The Source node. + ''' The syntax kind to test for. + ''' true if node is of specified kind; false otherwise. Public Function IsKind(node As SyntaxNode, kind As SyntaxKind) As Boolean Return node IsNot Nothing AndAlso node.RawKind = kind End Function ''' - ''' Determines if a SyntaxNodeOrToken is a specified kind. + ''' Determines if is of a specified kind. ''' - ''' The source SyntaxNodeOrToken. - ''' The SyntaxKind to test for. - ''' A boolean value if nodeOrToken is of specified kind; otherwise false. + ''' The source node or token. + ''' The syntax kind to test for. + ''' true if node or token is of specified kind; false otherwise. 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 + ''' + ''' Determines if the given raw kind value belongs to the Visual Basic enumeration. + ''' + ''' The raw value to test. + ''' true when the raw value belongs to the Visual Basic syntax kind; false otherwise. Friend Function IsVisualBasicKind(rawKind As Integer) As Boolean Const LastPossibleVisualBasicKind As Integer = 8192 @@ -171,7 +176,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic End Function ''' - ''' Returns for nodes. + ''' Returns for from property. ''' Public Function Kind(trivia As SyntaxTrivia) As SyntaxKind @@ -189,7 +194,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic End Function ''' - ''' Returns for from property. + ''' Returns for from property. ''' Public Function Kind(node As SyntaxNode) As SyntaxKind @@ -198,7 +203,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic End Function ''' - ''' Returns for from property. + ''' Returns for from property. ''' Public Function Kind(nodeOrToken As SyntaxNodeOrToken) As SyntaxKind -- GitLab