|
| 1 | +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. |
| 2 | +// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. |
| 3 | + |
| 4 | +namespace StyleCop.Analyzers.Helpers |
| 5 | +{ |
| 6 | + using System.Collections.Immutable; |
| 7 | + using Microsoft.CodeAnalysis.CSharp; |
| 8 | + using Microsoft.CodeAnalysis.CSharp.Syntax; |
| 9 | + |
| 10 | + internal static class SyntaxKinds |
| 11 | + { |
| 12 | + /// <summary> |
| 13 | + /// Gets a collection of <see cref="SyntaxKind"/> values which appear in the syntax tree as a |
| 14 | + /// <see cref="BaseTypeDeclarationSyntax"/>. |
| 15 | + /// </summary> |
| 16 | + /// <value> |
| 17 | + /// A collection of <see cref="SyntaxKind"/> values which appear in the syntax tree as a |
| 18 | + /// <see cref="BaseTypeDeclarationSyntax"/>. |
| 19 | + /// </value> |
| 20 | + public static ImmutableArray<SyntaxKind> BaseTypeDeclaration { get; } = |
| 21 | + ImmutableArray.Create( |
| 22 | + SyntaxKind.ClassDeclaration, |
| 23 | + SyntaxKind.StructDeclaration, |
| 24 | + SyntaxKind.InterfaceDeclaration, |
| 25 | + SyntaxKind.EnumDeclaration); |
| 26 | + |
| 27 | + /// <summary> |
| 28 | + /// Gets a collection of <see cref="SyntaxKind"/> values which appear in the syntax tree as a |
| 29 | + /// <see cref="TypeDeclarationSyntax"/>. |
| 30 | + /// </summary> |
| 31 | + /// <value> |
| 32 | + /// A collection of <see cref="SyntaxKind"/> values which appear in the syntax tree as a |
| 33 | + /// <see cref="TypeDeclarationSyntax"/>. |
| 34 | + /// </value> |
| 35 | + public static ImmutableArray<SyntaxKind> TypeDeclaration { get; } = |
| 36 | + ImmutableArray.Create( |
| 37 | + SyntaxKind.ClassDeclaration, |
| 38 | + SyntaxKind.StructDeclaration, |
| 39 | + SyntaxKind.InterfaceDeclaration); |
| 40 | + |
| 41 | + /// <summary> |
| 42 | + /// Gets a collection of <see cref="SyntaxKind"/> values which appear in the syntax tree as a |
| 43 | + /// <see cref="BaseFieldDeclarationSyntax"/>. |
| 44 | + /// </summary> |
| 45 | + /// <value> |
| 46 | + /// A collection of <see cref="SyntaxKind"/> values which appear in the syntax tree as a |
| 47 | + /// <see cref="BaseFieldDeclarationSyntax"/>. |
| 48 | + /// </value> |
| 49 | + public static ImmutableArray<SyntaxKind> BaseFieldDeclaration { get; } = |
| 50 | + ImmutableArray.Create( |
| 51 | + SyntaxKind.FieldDeclaration, |
| 52 | + SyntaxKind.EventFieldDeclaration); |
| 53 | + |
| 54 | + /// <summary> |
| 55 | + /// Gets a collection of <see cref="SyntaxKind"/> values which appear in the syntax tree as a |
| 56 | + /// <see cref="BaseMethodDeclarationSyntax"/>. |
| 57 | + /// </summary> |
| 58 | + /// <value> |
| 59 | + /// A collection of <see cref="SyntaxKind"/> values which appear in the syntax tree as a |
| 60 | + /// <see cref="BaseMethodDeclarationSyntax"/>. |
| 61 | + /// </value> |
| 62 | + public static ImmutableArray<SyntaxKind> BaseMethodDeclaration { get; } = |
| 63 | + ImmutableArray.Create( |
| 64 | + SyntaxKind.MethodDeclaration, |
| 65 | + SyntaxKind.ConstructorDeclaration, |
| 66 | + SyntaxKind.DestructorDeclaration, |
| 67 | + SyntaxKind.OperatorDeclaration, |
| 68 | + SyntaxKind.ConversionOperatorDeclaration); |
| 69 | + |
| 70 | + /// <summary> |
| 71 | + /// Gets a collection of <see cref="SyntaxKind"/> values which appear in the syntax tree as a |
| 72 | + /// <see cref="BasePropertyDeclarationSyntax"/>. |
| 73 | + /// </summary> |
| 74 | + /// <value> |
| 75 | + /// A collection of <see cref="SyntaxKind"/> values which appear in the syntax tree as a |
| 76 | + /// <see cref="BasePropertyDeclarationSyntax"/>. |
| 77 | + /// </value> |
| 78 | + public static ImmutableArray<SyntaxKind> BasePropertyDeclaration { get; } = |
| 79 | + ImmutableArray.Create( |
| 80 | + SyntaxKind.PropertyDeclaration, |
| 81 | + SyntaxKind.EventDeclaration, |
| 82 | + SyntaxKind.IndexerDeclaration); |
| 83 | + |
| 84 | + /// <summary> |
| 85 | + /// Gets a collection of <see cref="SyntaxKind"/> values which appear in the syntax tree as an |
| 86 | + /// <see cref="AccessorDeclarationSyntax"/>. |
| 87 | + /// </summary> |
| 88 | + /// <value> |
| 89 | + /// A collection of <see cref="SyntaxKind"/> values which appear in the syntax tree as an |
| 90 | + /// <see cref="AccessorDeclarationSyntax"/>. |
| 91 | + /// </value> |
| 92 | + public static ImmutableArray<SyntaxKind> AccessorDeclaration { get; } = |
| 93 | + ImmutableArray.Create( |
| 94 | + SyntaxKind.GetAccessorDeclaration, |
| 95 | + SyntaxKind.SetAccessorDeclaration, |
| 96 | + SyntaxKind.AddAccessorDeclaration, |
| 97 | + SyntaxKind.RemoveAccessorDeclaration, |
| 98 | + SyntaxKind.UnknownAccessorDeclaration); |
| 99 | + |
| 100 | + /// <summary> |
| 101 | + /// Gets a collection of <see cref="SyntaxKind"/> values which appear in the syntax tree as an |
| 102 | + /// <see cref="InitializerExpressionSyntax"/>. |
| 103 | + /// </summary> |
| 104 | + /// <value> |
| 105 | + /// A collection of <see cref="SyntaxKind"/> values which appear in the syntax tree as an |
| 106 | + /// <see cref="InitializerExpressionSyntax"/>. |
| 107 | + /// </value> |
| 108 | + public static ImmutableArray<SyntaxKind> InitializerExpression { get; } = |
| 109 | + ImmutableArray.Create( |
| 110 | + SyntaxKind.ArrayInitializerExpression, |
| 111 | + SyntaxKind.CollectionInitializerExpression, |
| 112 | + SyntaxKind.ComplexElementInitializerExpression, |
| 113 | + SyntaxKind.ObjectInitializerExpression); |
| 114 | + |
| 115 | + /// <summary> |
| 116 | + /// Gets a collection of <see cref="SyntaxKind"/> values which appear in the syntax tree as a |
| 117 | + /// <see cref="DocumentationCommentTriviaSyntax"/>. |
| 118 | + /// </summary> |
| 119 | + /// <value> |
| 120 | + /// A collection of <see cref="SyntaxKind"/> values which appear in the syntax tree as a |
| 121 | + /// <see cref="DocumentationCommentTriviaSyntax"/>. |
| 122 | + /// </value> |
| 123 | + public static ImmutableArray<SyntaxKind> DocumentationComment { get; } = |
| 124 | + ImmutableArray.Create( |
| 125 | + SyntaxKind.SingleLineDocumentationCommentTrivia, |
| 126 | + SyntaxKind.MultiLineDocumentationCommentTrivia); |
| 127 | + |
| 128 | + /// <summary> |
| 129 | + /// Gets a collection of <see cref="SyntaxKind"/> values which appear in the syntax tree as a |
| 130 | + /// <see cref="ConstructorInitializerSyntax"/>. |
| 131 | + /// </summary> |
| 132 | + /// <value> |
| 133 | + /// A collection of <see cref="SyntaxKind"/> values which appear in the syntax tree as a |
| 134 | + /// <see cref="ConstructorInitializerSyntax"/>. |
| 135 | + /// </value> |
| 136 | + public static ImmutableArray<SyntaxKind> ConstructorInitializer { get; } = |
| 137 | + ImmutableArray.Create( |
| 138 | + SyntaxKind.BaseConstructorInitializer, |
| 139 | + SyntaxKind.ThisConstructorInitializer); |
| 140 | + |
| 141 | + /// <summary> |
| 142 | + /// Gets a collection of <see cref="SyntaxKind"/> values which appear in the syntax tree as a |
| 143 | + /// <see cref="LambdaExpressionSyntax"/>. |
| 144 | + /// </summary> |
| 145 | + /// <value> |
| 146 | + /// A collection of <see cref="SyntaxKind"/> values which appear in the syntax tree as a |
| 147 | + /// <see cref="LambdaExpressionSyntax"/>. |
| 148 | + /// </value> |
| 149 | + public static ImmutableArray<SyntaxKind> LambdaExpression { get; } = |
| 150 | + ImmutableArray.Create( |
| 151 | + SyntaxKind.ParenthesizedLambdaExpression, |
| 152 | + SyntaxKind.SimpleLambdaExpression); |
| 153 | + |
| 154 | + /// <summary> |
| 155 | + /// Gets a collection of <see cref="SyntaxKind"/> values which appear in the syntax tree as an |
| 156 | + /// <see cref="AnonymousFunctionExpressionSyntax"/>. |
| 157 | + /// </summary> |
| 158 | + /// <value> |
| 159 | + /// A collection of <see cref="SyntaxKind"/> values which appear in the syntax tree as an |
| 160 | + /// <see cref="AnonymousFunctionExpressionSyntax"/>. |
| 161 | + /// </value> |
| 162 | + public static ImmutableArray<SyntaxKind> AnonymousFunctionExpression { get; } = |
| 163 | + ImmutableArray.Create( |
| 164 | + SyntaxKind.ParenthesizedLambdaExpression, |
| 165 | + SyntaxKind.SimpleLambdaExpression, |
| 166 | + SyntaxKind.AnonymousMethodExpression); |
| 167 | + |
| 168 | + /// <summary> |
| 169 | + /// Gets a collection of <see cref="SyntaxKind"/> values which appear in the syntax tree as a |
| 170 | + /// <see cref="SimpleNameSyntax"/>. |
| 171 | + /// </summary> |
| 172 | + /// <value> |
| 173 | + /// A collection of <see cref="SyntaxKind"/> values which appear in the syntax tree as a |
| 174 | + /// <see cref="SimpleNameSyntax"/>. |
| 175 | + /// </value> |
| 176 | + public static ImmutableArray<SyntaxKind> SimpleName { get; } = |
| 177 | + ImmutableArray.Create( |
| 178 | + SyntaxKind.GenericName, |
| 179 | + SyntaxKind.IdentifierName); |
| 180 | + |
| 181 | + /// <summary> |
| 182 | + /// Gets a collection of <see cref="SyntaxKind"/> values which appear in the syntax tree as a |
| 183 | + /// <see cref="BaseParameterListSyntax"/>. |
| 184 | + /// </summary> |
| 185 | + /// <value> |
| 186 | + /// A collection of <see cref="SyntaxKind"/> values which appear in the syntax tree as a |
| 187 | + /// <see cref="BaseParameterListSyntax"/>. |
| 188 | + /// </value> |
| 189 | + public static ImmutableArray<SyntaxKind> BaseParameterList { get; } = |
| 190 | + ImmutableArray.Create( |
| 191 | + SyntaxKind.ParameterList, |
| 192 | + SyntaxKind.BracketedParameterList); |
| 193 | + |
| 194 | + /// <summary> |
| 195 | + /// Gets a collection of <see cref="SyntaxKind"/> values which appear in the syntax tree as a |
| 196 | + /// <see cref="BaseArgumentListSyntax"/>. |
| 197 | + /// </summary> |
| 198 | + /// <value> |
| 199 | + /// A collection of <see cref="SyntaxKind"/> values which appear in the syntax tree as a |
| 200 | + /// <see cref="BaseArgumentListSyntax"/>. |
| 201 | + /// </value> |
| 202 | + public static ImmutableArray<SyntaxKind> BaseArgumentList { get; } = |
| 203 | + ImmutableArray.Create( |
| 204 | + SyntaxKind.ArgumentList, |
| 205 | + SyntaxKind.BracketedArgumentList); |
| 206 | + } |
| 207 | +} |
0 commit comments