202 references to DeclarationKind
Microsoft.CodeAnalysis.CSharp.Workspaces (49)
CodeGeneration\CSharpSyntaxGenerator.cs (8)
1877
public override
DeclarationKind
GetDeclarationKind(SyntaxNode declaration)
2103
case
DeclarationKind
.Class:
2104
case
DeclarationKind
.Interface:
2105
case
DeclarationKind
.Struct:
2106
case
DeclarationKind
.Enum:
2107
case
DeclarationKind
.Namespace:
2108
case
DeclarationKind
.CompilationUnit:
2117
case
DeclarationKind
.Attribute:
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpAccessibilityFacts.cs (41)
50
var
declarationKind = GetDeclarationKind(declaration);
51
return declarationKind is
DeclarationKind
.Field or
DeclarationKind
.Event;
153
public static
DeclarationKind
GetDeclarationKind(SyntaxNode declaration)
159
return
DeclarationKind
.Class;
162
return
DeclarationKind
.Struct;
164
return
DeclarationKind
.Interface;
166
return
DeclarationKind
.Enum;
168
return
DeclarationKind
.Delegate;
171
return
DeclarationKind
.Method;
173
return
DeclarationKind
.Operator;
175
return
DeclarationKind
.ConversionOperator;
177
return
DeclarationKind
.Constructor;
179
return
DeclarationKind
.Destructor;
182
return
DeclarationKind
.Property;
184
return
DeclarationKind
.Indexer;
186
return
DeclarationKind
.CustomEvent;
188
return
DeclarationKind
.EnumMember;
190
return
DeclarationKind
.CompilationUnit;
193
return
DeclarationKind
.Namespace;
195
return
DeclarationKind
.NamespaceImport;
197
return
DeclarationKind
.Parameter;
201
return
DeclarationKind
.LambdaExpression;
208
return
DeclarationKind
.Field;
212
return
DeclarationKind
.None;
220
return
DeclarationKind
.Event;
224
return
DeclarationKind
.None;
232
return
DeclarationKind
.Variable;
236
return
DeclarationKind
.None;
245
return
DeclarationKind
.Variable;
249
return
DeclarationKind
.None;
262
return
DeclarationKind
.Field;
266
return
DeclarationKind
.Event;
270
return
DeclarationKind
.Variable;
281
return
DeclarationKind
.Attribute;
289
return
DeclarationKind
.Attribute;
295
return
DeclarationKind
.GetAccessor;
298
return
DeclarationKind
.SetAccessor;
300
return
DeclarationKind
.AddAccessor;
302
return
DeclarationKind
.RemoveAccessor;
305
return
DeclarationKind
.None;
Microsoft.CodeAnalysis.CSharp.Workspaces.UnitTests (44)
CodeGeneration\SyntaxGeneratorTests.cs (44)
1960
CheckAddRemoveAttribute(Generator.GetAccessor(prop,
DeclarationKind
.GetAccessor));
1961
CheckAddRemoveAttribute(Generator.GetAccessor(prop,
DeclarationKind
.SetAccessor));
1962
CheckAddRemoveAttribute(Generator.GetAccessor(evnt,
DeclarationKind
.AddAccessor));
1963
CheckAddRemoveAttribute(Generator.GetAccessor(evnt,
DeclarationKind
.RemoveAccessor));
2873
Assert.Equal(
DeclarationKind
.CompilationUnit, Generator.GetDeclarationKind(Generator.CompilationUnit()));
2874
Assert.Equal(
DeclarationKind
.Class, Generator.GetDeclarationKind(Generator.ClassDeclaration("c")));
2875
Assert.Equal(
DeclarationKind
.Struct, Generator.GetDeclarationKind(Generator.StructDeclaration("s")));
2876
Assert.Equal(
DeclarationKind
.Interface, Generator.GetDeclarationKind(Generator.InterfaceDeclaration("i")));
2877
Assert.Equal(
DeclarationKind
.Enum, Generator.GetDeclarationKind(Generator.EnumDeclaration("e")));
2878
Assert.Equal(
DeclarationKind
.Delegate, Generator.GetDeclarationKind(Generator.DelegateDeclaration("d")));
2879
Assert.Equal(
DeclarationKind
.Method, Generator.GetDeclarationKind(Generator.MethodDeclaration("m")));
2880
Assert.Equal(
DeclarationKind
.Constructor, Generator.GetDeclarationKind(Generator.ConstructorDeclaration()));
2881
Assert.Equal(
DeclarationKind
.Parameter, Generator.GetDeclarationKind(Generator.ParameterDeclaration("p")));
2882
Assert.Equal(
DeclarationKind
.Property, Generator.GetDeclarationKind(Generator.PropertyDeclaration("p", Generator.IdentifierName("t"))));
2883
Assert.Equal(
DeclarationKind
.Indexer, Generator.GetDeclarationKind(Generator.IndexerDeclaration([Generator.ParameterDeclaration("i")], Generator.IdentifierName("t"))));
2884
Assert.Equal(
DeclarationKind
.Field, Generator.GetDeclarationKind(Generator.FieldDeclaration("f", Generator.IdentifierName("t"))));
2885
Assert.Equal(
DeclarationKind
.EnumMember, Generator.GetDeclarationKind(Generator.EnumMember("v")));
2886
Assert.Equal(
DeclarationKind
.Event, Generator.GetDeclarationKind(Generator.EventDeclaration("ef", Generator.IdentifierName("t"))));
2887
Assert.Equal(
DeclarationKind
.CustomEvent, Generator.GetDeclarationKind(Generator.CustomEventDeclaration("e", Generator.IdentifierName("t"))));
2888
Assert.Equal(
DeclarationKind
.Namespace, Generator.GetDeclarationKind(Generator.NamespaceDeclaration("n")));
2889
Assert.Equal(
DeclarationKind
.NamespaceImport, Generator.GetDeclarationKind(Generator.NamespaceImportDeclaration("u")));
2890
Assert.Equal(
DeclarationKind
.Variable, Generator.GetDeclarationKind(Generator.LocalDeclarationStatement(Generator.IdentifierName("t"), "loc")));
2891
Assert.Equal(
DeclarationKind
.Attribute, Generator.GetDeclarationKind(Generator.Attribute("a")));
3356
var getAccessor = Generator.GetAccessor(prop,
DeclarationKind
.GetAccessor);
3365
var setAccessor = Generator.GetAccessor(prop,
DeclarationKind
.SetAccessor);
3370
Assert.Null(Generator.GetAccessor(Generator.RemoveNode(prop, getAccessor),
DeclarationKind
.GetAccessor));
3371
Assert.Null(Generator.GetAccessor(Generator.RemoveNode(prop, setAccessor),
DeclarationKind
.SetAccessor));
3393
Assert.Equal(Accessibility.Public, Generator.GetAccessibility(Generator.GetAccessor(newProp,
DeclarationKind
.GetAccessor)));
3396
Assert.Equal(Accessibility.Public, Generator.GetAccessibility(Generator.GetAccessor(newProp,
DeclarationKind
.SetAccessor)));
3456
var y2 = Generator.AddAccessors(y, [Generator.GetAccessor(x,
DeclarationKind
.GetAccessor)]);
3477
var y2 = Generator.AddAccessors(y, [Generator.GetAccessor(x,
DeclarationKind
.GetAccessor)]);
3792
Assert.Equal(
DeclarationKind
.Field, Generator.GetDeclarationKind(declX));
3793
Assert.Equal(
DeclarationKind
.Field, Generator.GetDeclarationKind(declY));
3794
Assert.Equal(
DeclarationKind
.Field, Generator.GetDeclarationKind(declZ));
3815
Assert.Equal(
DeclarationKind
.Field, Generator.GetDeclarationKind(xTypedT));
3820
Assert.Equal(
DeclarationKind
.Field, Generator.GetDeclarationKind(xNamedQ));
3825
Assert.Equal(
DeclarationKind
.Field, Generator.GetDeclarationKind(xInitialized));
3830
Assert.Equal(
DeclarationKind
.Field, Generator.GetDeclarationKind(xPrivate));
3835
Assert.Equal(
DeclarationKind
.Field, Generator.GetDeclarationKind(xReadOnly));
3840
Assert.Equal(
DeclarationKind
.Field, Generator.GetDeclarationKind(xAttributed));
4143
Assert.Equal(
DeclarationKind
.Attribute, Generator.GetDeclarationKind(xNamedQ));
4148
Assert.Equal(
DeclarationKind
.Attribute, Generator.GetDeclarationKind(xWithArg));
4323
Assert.Equal(
DeclarationKind
.Attribute, Generator.GetDeclarationKind(xNamedQ));
4328
Assert.Equal(
DeclarationKind
.Attribute, Generator.GetDeclarationKind(xWithArg));
Microsoft.CodeAnalysis.VisualBasic.CodeStyle.Fixes (4)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\LanguageServices\VisualBasicSyntaxGeneratorInternal.vb (4)
210
modifiers:=GetModifierList(accessibility, modifiers And GetAllowedModifiers(SyntaxKind.EventStatement), declaration:=Nothing,
DeclarationKind
.Event),
364
Friend Shared Function GetModifierList(accessibility As Accessibility, modifiers As DeclarationModifiers, declaration As SyntaxNode, kind As
DeclarationKind
, Optional isDefault As Boolean = False) As SyntaxTokenList
395
Dim isClass = kind =
DeclarationKind
.Class OrElse declaration.IsKind(SyntaxKind.ClassStatement)
453
If (kind =
DeclarationKind
.Field AndAlso _list.Count = 0) Then
Microsoft.CodeAnalysis.VisualBasic.Workspaces (54)
CodeGeneration\VisualBasicSyntaxGenerator.vb (50)
681
modifiers:=GetModifierList(accessibility, modifiers And VisualBasicSyntaxGeneratorInternal.s_fieldModifiers, declaration:=Nothing,
DeclarationKind
.Field),
697
modifiers:=GetModifierList(accessibility, modifiers And VisualBasicSyntaxGeneratorInternal.s_methodModifiers, declaration:=Nothing,
DeclarationKind
.Method),
733
Dim modifierList As SyntaxTokenList = GetModifierList(accessibility, modifiers And VisualBasicSyntaxGeneratorInternal.s_methodModifiers, declaration:=Nothing,
DeclarationKind
.Operator)
854
SyntaxFactory.GetAccessorStatement().WithModifiers(GetModifierList(accessibility, DeclarationModifiers.None, declaration:=Nothing,
DeclarationKind
.Property)),
860
SyntaxFactory.SetAccessorStatement().WithModifiers(GetModifierList(accessibility, DeclarationModifiers.None, declaration:=Nothing,
DeclarationKind
.Property)),
931
modifiers:=GetModifierList(accessibility, modifiers And VisualBasicSyntaxGeneratorInternal.s_propertyModifiers, declaration:=Nothing,
DeclarationKind
.Property),
964
modifiers:=GetModifierList(accessibility, modifiers And VisualBasicSyntaxGeneratorInternal.s_indexerModifiers, declaration:=Nothing,
DeclarationKind
.Indexer, isDefault:=True),
1211
modifiers:=GetModifierList(accessibility, modifiers And VisualBasicSyntaxGeneratorInternal.s_constructorModifiers, declaration:=Nothing,
DeclarationKind
.Constructor),
1248
modifiers:=GetModifierList(accessibility, modifiers And VisualBasicSyntaxGeneratorInternal.s_classModifiers, declaration:=Nothing,
DeclarationKind
.Class),
1285
modifiers:=GetModifierList(accessibility, modifiers And VisualBasicSyntaxGeneratorInternal.s_structModifiers, declaration:=Nothing,
DeclarationKind
.Struct),
1308
modifiers:=GetModifierList(accessibility, DeclarationModifiers.None, declaration:=Nothing,
DeclarationKind
.Interface),
1371
modifiers:=GetModifierList(accessibility, modifiers And GetAllowedModifiers(SyntaxKind.EnumStatement), declaration:=Nothing,
DeclarationKind
.Enum),
1423
modifiers:=GetModifierList(accessibility, modifiers And GetAllowedModifiers(kind), declaration:=Nothing,
DeclarationKind
.Delegate),
1756
Public Overrides Function GetDeclarationKind(declaration As SyntaxNode) As
DeclarationKind
1759
Return
DeclarationKind
.CompilationUnit
1761
Return
DeclarationKind
.Namespace
1763
Return
DeclarationKind
.NamespaceImport
1765
Return
DeclarationKind
.Class
1767
Return
DeclarationKind
.Struct
1769
Return
DeclarationKind
.Interface
1771
Return
DeclarationKind
.Enum
1773
Return
DeclarationKind
.EnumMember
1776
Return
DeclarationKind
.Delegate
1779
Return
DeclarationKind
.Method
1782
Return
DeclarationKind
.Method
1786
Return
DeclarationKind
.Method
1789
Return
DeclarationKind
.Constructor
1792
Return
DeclarationKind
.Indexer
1794
Return
DeclarationKind
.Property
1799
Return
DeclarationKind
.Indexer
1801
Return
DeclarationKind
.Property
1805
Return
DeclarationKind
.Operator
1808
Return
DeclarationKind
.Operator
1811
Return
DeclarationKind
.CustomEvent
1814
Return
DeclarationKind
.Event
1817
Return
DeclarationKind
.Parameter
1819
Return
DeclarationKind
.Field
1822
Return
DeclarationKind
.Variable
1827
Return
DeclarationKind
.Field
1829
Return
DeclarationKind
.Variable
1835
Return
DeclarationKind
.Attribute
1840
Return
DeclarationKind
.Attribute
1843
Return
DeclarationKind
.GetAccessor
1845
Return
DeclarationKind
.SetAccessor
1847
Return
DeclarationKind
.AddAccessor
1849
Return
DeclarationKind
.RemoveAccessor
1851
Return
DeclarationKind
.RaiseAccessor
1854
Return
DeclarationKind
.None
2551
Friend Shared Function GetModifierList(accessibility As Accessibility, modifiers As DeclarationModifiers, declaration As SyntaxNode, kind As
DeclarationKind
, Optional isDefault As Boolean = False) As SyntaxTokenList
3214
modifiers:=GetModifierList(accessibility, modifiers And GetAllowedModifiers(SyntaxKind.EventStatement), declaration:=Nothing,
DeclarationKind
.Event),
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\LanguageServices\VisualBasicSyntaxGeneratorInternal.vb (4)
210
modifiers:=GetModifierList(accessibility, modifiers And GetAllowedModifiers(SyntaxKind.EventStatement), declaration:=Nothing,
DeclarationKind
.Event),
364
Friend Shared Function GetModifierList(accessibility As Accessibility, modifiers As DeclarationModifiers, declaration As SyntaxNode, kind As
DeclarationKind
, Optional isDefault As Boolean = False) As SyntaxTokenList
395
Dim isClass = kind =
DeclarationKind
.Class OrElse declaration.IsKind(SyntaxKind.ClassStatement)
453
If (kind =
DeclarationKind
.Field AndAlso _list.Count = 0) Then
Microsoft.CodeAnalysis.VisualBasic.Workspaces.UnitTests (45)
CodeGeneration\SyntaxGeneratorTests.vb (45)
2279
CheckAddRemoveAttribute(Generator.GetAccessor(prop,
DeclarationKind
.GetAccessor))
2280
CheckAddRemoveAttribute(Generator.GetAccessor(prop,
DeclarationKind
.SetAccessor))
2281
CheckAddRemoveAttribute(Generator.GetAccessor(evnt,
DeclarationKind
.AddAccessor))
2282
CheckAddRemoveAttribute(Generator.GetAccessor(evnt,
DeclarationKind
.RemoveAccessor))
2283
CheckAddRemoveAttribute(Generator.GetAccessor(evnt,
DeclarationKind
.RaiseAccessor))
2565
Assert.Equal(
DeclarationKind
.CompilationUnit, Generator.GetDeclarationKind(Generator.CompilationUnit()))
2566
Assert.Equal(
DeclarationKind
.Class, Generator.GetDeclarationKind(Generator.ClassDeclaration("c")))
2567
Assert.Equal(
DeclarationKind
.Struct, Generator.GetDeclarationKind(Generator.StructDeclaration("s")))
2568
Assert.Equal(
DeclarationKind
.Interface, Generator.GetDeclarationKind(Generator.InterfaceDeclaration("i")))
2569
Assert.Equal(
DeclarationKind
.Enum, Generator.GetDeclarationKind(Generator.EnumDeclaration("e")))
2570
Assert.Equal(
DeclarationKind
.Delegate, Generator.GetDeclarationKind(Generator.DelegateDeclaration("d")))
2571
Assert.Equal(
DeclarationKind
.Method, Generator.GetDeclarationKind(Generator.MethodDeclaration("m")))
2572
Assert.Equal(
DeclarationKind
.Method, Generator.GetDeclarationKind(Generator.MethodDeclaration("m", modifiers:=DeclarationModifiers.Abstract)))
2573
Assert.Equal(
DeclarationKind
.Constructor, Generator.GetDeclarationKind(Generator.ConstructorDeclaration()))
2574
Assert.Equal(
DeclarationKind
.Parameter, Generator.GetDeclarationKind(Generator.ParameterDeclaration("p")))
2575
Assert.Equal(
DeclarationKind
.Property, Generator.GetDeclarationKind(Generator.PropertyDeclaration("p", Generator.IdentifierName("t"))))
2576
Assert.Equal(
DeclarationKind
.Property, Generator.GetDeclarationKind(Generator.PropertyDeclaration("p", Generator.IdentifierName("t"), modifiers:=DeclarationModifiers.Abstract)))
2577
Assert.Equal(
DeclarationKind
.Indexer, Generator.GetDeclarationKind(Generator.IndexerDeclaration({Generator.ParameterDeclaration("i")}, Generator.IdentifierName("t"))))
2578
Assert.Equal(
DeclarationKind
.Indexer, Generator.GetDeclarationKind(Generator.IndexerDeclaration({Generator.ParameterDeclaration("i")}, Generator.IdentifierName("t"), modifiers:=DeclarationModifiers.Abstract)))
2579
Assert.Equal(
DeclarationKind
.Field, Generator.GetDeclarationKind(Generator.FieldDeclaration("f", Generator.IdentifierName("t"))))
2580
Assert.Equal(
DeclarationKind
.EnumMember, Generator.GetDeclarationKind(Generator.EnumMember("v")))
2581
Assert.Equal(
DeclarationKind
.Event, Generator.GetDeclarationKind(Generator.EventDeclaration("e", Generator.IdentifierName("t"))))
2582
Assert.Equal(
DeclarationKind
.CustomEvent, Generator.GetDeclarationKind(Generator.CustomEventDeclaration("ce", Generator.IdentifierName("t"))))
2583
Assert.Equal(
DeclarationKind
.Namespace, Generator.GetDeclarationKind(Generator.NamespaceDeclaration("n")))
2584
Assert.Equal(
DeclarationKind
.NamespaceImport, Generator.GetDeclarationKind(Generator.NamespaceImportDeclaration("u")))
2585
Assert.Equal(
DeclarationKind
.Variable, Generator.GetDeclarationKind(Generator.LocalDeclarationStatement(Generator.IdentifierName("t"), "loc")))
2586
Assert.Equal(
DeclarationKind
.Attribute, Generator.GetDeclarationKind(Generator.Attribute("a")))
3059
Dim getAccessor = _g.GetAccessor(prop,
DeclarationKind
.GetAccessor)
3069
Dim setAccessor = _g.GetAccessor(prop,
DeclarationKind
.SetAccessor)
3074
Assert.Null(_g.GetAccessor(_g.RemoveNode(prop, getAccessor),
DeclarationKind
.GetAccessor))
3075
Assert.Null(_g.GetAccessor(_g.RemoveNode(prop, setAccessor),
DeclarationKind
.SetAccessor))
3092
Assert.Equal(Accessibility.Public, _g.GetAccessibility(_g.GetAccessor(newProp,
DeclarationKind
.GetAccessor)))
3095
Assert.Equal(Accessibility.Public, _g.GetAccessibility(_g.GetAccessor(newProp,
DeclarationKind
.SetAccessor)))
3483
Assert.Equal(
DeclarationKind
.Field, Generator.GetDeclarationKind(declX))
3484
Assert.Equal(
DeclarationKind
.Field, Generator.GetDeclarationKind(declY))
3485
Assert.Equal(
DeclarationKind
.Field, Generator.GetDeclarationKind(declZ))
3506
Assert.Equal(
DeclarationKind
.Field, Generator.GetDeclarationKind(xTypedT))
3511
Assert.Equal(
DeclarationKind
.Field, Generator.GetDeclarationKind(xNamedQ))
3516
Assert.Equal(
DeclarationKind
.Field, Generator.GetDeclarationKind(xInitialized))
3521
Assert.Equal(
DeclarationKind
.Field, Generator.GetDeclarationKind(xPrivate))
3526
Assert.Equal(
DeclarationKind
.Field, Generator.GetDeclarationKind(xReadOnly))
3531
Assert.Equal(
DeclarationKind
.Field, Generator.GetDeclarationKind(xAttributed))
3743
Assert.Equal(
DeclarationKind
.Attribute, Generator.GetDeclarationKind(xNamedQ))
3748
Assert.Equal(
DeclarationKind
.Attribute, Generator.GetDeclarationKind(xWithArg))
3869
Assert.Equal(
DeclarationKind
.NamespaceImport, Generator.GetDeclarationKind(xRenamedQ))
Microsoft.CodeAnalysis.Workspaces (5)
Editing\SyntaxGenerator.cs (5)
89
if (GetDeclarationKind(node) !=
DeclarationKind
.None)
103
public SyntaxNode? GetDeclaration(SyntaxNode? node,
DeclarationKind
kind)
1234
/// Gets the <see cref="
DeclarationKind
"/> for the declaration.
1236
public abstract
DeclarationKind
GetDeclarationKind(SyntaxNode declaration);
1320
public SyntaxNode? GetAccessor(SyntaxNode declaration,
DeclarationKind
kind)
Microsoft.Interop.ComInterfaceGenerator (1)
Analyzers\ConvertComImportToGeneratedComInterfaceFixer.cs (1)
105
if (gen.GetDeclarationKind(member) !=
DeclarationKind
.Method)