198 references to DeclarationKind
Microsoft.CodeAnalysis.CSharp.Workspaces (49)
CodeGeneration\CSharpSyntaxGenerator.cs (8)
1882
public override
DeclarationKind
GetDeclarationKind(SyntaxNode declaration)
2108
case
DeclarationKind
.Class:
2109
case
DeclarationKind
.Interface:
2110
case
DeclarationKind
.Struct:
2111
case
DeclarationKind
.Enum:
2112
case
DeclarationKind
.Namespace:
2113
case
DeclarationKind
.CompilationUnit:
2122
case
DeclarationKind
.Attribute:
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));
2769
Assert.Equal(
DeclarationKind
.CompilationUnit, Generator.GetDeclarationKind(Generator.CompilationUnit()));
2770
Assert.Equal(
DeclarationKind
.Class, Generator.GetDeclarationKind(Generator.ClassDeclaration("c")));
2771
Assert.Equal(
DeclarationKind
.Struct, Generator.GetDeclarationKind(Generator.StructDeclaration("s")));
2772
Assert.Equal(
DeclarationKind
.Interface, Generator.GetDeclarationKind(Generator.InterfaceDeclaration("i")));
2773
Assert.Equal(
DeclarationKind
.Enum, Generator.GetDeclarationKind(Generator.EnumDeclaration("e")));
2774
Assert.Equal(
DeclarationKind
.Delegate, Generator.GetDeclarationKind(Generator.DelegateDeclaration("d")));
2775
Assert.Equal(
DeclarationKind
.Method, Generator.GetDeclarationKind(Generator.MethodDeclaration("m")));
2776
Assert.Equal(
DeclarationKind
.Constructor, Generator.GetDeclarationKind(Generator.ConstructorDeclaration()));
2777
Assert.Equal(
DeclarationKind
.Parameter, Generator.GetDeclarationKind(Generator.ParameterDeclaration("p")));
2778
Assert.Equal(
DeclarationKind
.Property, Generator.GetDeclarationKind(Generator.PropertyDeclaration("p", Generator.IdentifierName("t"))));
2779
Assert.Equal(
DeclarationKind
.Indexer, Generator.GetDeclarationKind(Generator.IndexerDeclaration(new[] { Generator.ParameterDeclaration("i") }, Generator.IdentifierName("t"))));
2780
Assert.Equal(
DeclarationKind
.Field, Generator.GetDeclarationKind(Generator.FieldDeclaration("f", Generator.IdentifierName("t"))));
2781
Assert.Equal(
DeclarationKind
.EnumMember, Generator.GetDeclarationKind(Generator.EnumMember("v")));
2782
Assert.Equal(
DeclarationKind
.Event, Generator.GetDeclarationKind(Generator.EventDeclaration("ef", Generator.IdentifierName("t"))));
2783
Assert.Equal(
DeclarationKind
.CustomEvent, Generator.GetDeclarationKind(Generator.CustomEventDeclaration("e", Generator.IdentifierName("t"))));
2784
Assert.Equal(
DeclarationKind
.Namespace, Generator.GetDeclarationKind(Generator.NamespaceDeclaration("n")));
2785
Assert.Equal(
DeclarationKind
.NamespaceImport, Generator.GetDeclarationKind(Generator.NamespaceImportDeclaration("u")));
2786
Assert.Equal(
DeclarationKind
.Variable, Generator.GetDeclarationKind(Generator.LocalDeclarationStatement(Generator.IdentifierName("t"), "loc")));
2787
Assert.Equal(
DeclarationKind
.Attribute, Generator.GetDeclarationKind(Generator.Attribute("a")));
3252
var getAccessor = Generator.GetAccessor(prop,
DeclarationKind
.GetAccessor);
3261
var setAccessor = Generator.GetAccessor(prop,
DeclarationKind
.SetAccessor);
3266
Assert.Null(Generator.GetAccessor(Generator.RemoveNode(prop, getAccessor),
DeclarationKind
.GetAccessor));
3267
Assert.Null(Generator.GetAccessor(Generator.RemoveNode(prop, setAccessor),
DeclarationKind
.SetAccessor));
3289
Assert.Equal(Accessibility.Public, Generator.GetAccessibility(Generator.GetAccessor(newProp,
DeclarationKind
.GetAccessor)));
3292
Assert.Equal(Accessibility.Public, Generator.GetAccessibility(Generator.GetAccessor(newProp,
DeclarationKind
.SetAccessor)));
3352
var y2 = Generator.AddAccessors(y, new[] { Generator.GetAccessor(x,
DeclarationKind
.GetAccessor) });
3373
var y2 = Generator.AddAccessors(y, new[] { Generator.GetAccessor(x,
DeclarationKind
.GetAccessor) });
3688
Assert.Equal(
DeclarationKind
.Field, Generator.GetDeclarationKind(declX));
3689
Assert.Equal(
DeclarationKind
.Field, Generator.GetDeclarationKind(declY));
3690
Assert.Equal(
DeclarationKind
.Field, Generator.GetDeclarationKind(declZ));
3711
Assert.Equal(
DeclarationKind
.Field, Generator.GetDeclarationKind(xTypedT));
3716
Assert.Equal(
DeclarationKind
.Field, Generator.GetDeclarationKind(xNamedQ));
3721
Assert.Equal(
DeclarationKind
.Field, Generator.GetDeclarationKind(xInitialized));
3726
Assert.Equal(
DeclarationKind
.Field, Generator.GetDeclarationKind(xPrivate));
3731
Assert.Equal(
DeclarationKind
.Field, Generator.GetDeclarationKind(xReadOnly));
3736
Assert.Equal(
DeclarationKind
.Field, Generator.GetDeclarationKind(xAttributed));
4039
Assert.Equal(
DeclarationKind
.Attribute, Generator.GetDeclarationKind(xNamedQ));
4044
Assert.Equal(
DeclarationKind
.Attribute, Generator.GetDeclarationKind(xWithArg));
4219
Assert.Equal(
DeclarationKind
.Attribute, Generator.GetDeclarationKind(xNamedQ));
4224
Assert.Equal(
DeclarationKind
.Attribute, Generator.GetDeclarationKind(xWithArg));
Microsoft.CodeAnalysis.VisualBasic.Workspaces (53)
CodeGeneration\VisualBasicSyntaxGenerator.vb (53)
767
modifiers:=GetModifierList(accessibility, modifiers And s_fieldModifiers, declaration:=Nothing,
DeclarationKind
.Field),
783
modifiers:=GetModifierList(accessibility, modifiers And s_methodModifiers, declaration:=Nothing,
DeclarationKind
.Method),
814
Dim modifierList As SyntaxTokenList = GetModifierList(accessibility, modifiers And s_methodModifiers, declaration:=Nothing,
DeclarationKind
.Operator)
933
SyntaxFactory.GetAccessorStatement().WithModifiers(GetModifierList(accessibility, DeclarationModifiers.None, declaration:=Nothing,
DeclarationKind
.Property)),
939
SyntaxFactory.SetAccessorStatement().WithModifiers(GetModifierList(accessibility, DeclarationModifiers.None, declaration:=Nothing,
DeclarationKind
.Property)),
1010
modifiers:=GetModifierList(accessibility, modifiers And s_propertyModifiers, declaration:=Nothing,
DeclarationKind
.Property),
1043
modifiers:=GetModifierList(accessibility, modifiers And s_indexerModifiers, declaration:=Nothing,
DeclarationKind
.Indexer, isDefault:=True),
1349
modifiers:=GetModifierList(accessibility, modifiers And s_constructorModifiers, declaration:=Nothing,
DeclarationKind
.Constructor),
1386
modifiers:=GetModifierList(accessibility, modifiers And s_classModifiers, declaration:=Nothing,
DeclarationKind
.Class),
1423
modifiers:=GetModifierList(accessibility, modifiers And s_structModifiers, declaration:=Nothing,
DeclarationKind
.Struct),
1446
modifiers:=GetModifierList(accessibility, DeclarationModifiers.None, declaration:=Nothing,
DeclarationKind
.Interface),
1509
modifiers:=GetModifierList(accessibility, modifiers And GetAllowedModifiers(SyntaxKind.EnumStatement), declaration:=Nothing,
DeclarationKind
.Enum),
1561
modifiers:=GetModifierList(accessibility, modifiers And GetAllowedModifiers(kind), declaration:=Nothing,
DeclarationKind
.Delegate),
1888
Public Overrides Function GetDeclarationKind(declaration As SyntaxNode) As
DeclarationKind
1891
Return
DeclarationKind
.CompilationUnit
1893
Return
DeclarationKind
.Namespace
1895
Return
DeclarationKind
.NamespaceImport
1897
Return
DeclarationKind
.Class
1899
Return
DeclarationKind
.Struct
1901
Return
DeclarationKind
.Interface
1903
Return
DeclarationKind
.Enum
1905
Return
DeclarationKind
.EnumMember
1908
Return
DeclarationKind
.Delegate
1911
Return
DeclarationKind
.Method
1914
Return
DeclarationKind
.Method
1918
Return
DeclarationKind
.Method
1921
Return
DeclarationKind
.Constructor
1924
Return
DeclarationKind
.Indexer
1926
Return
DeclarationKind
.Property
1931
Return
DeclarationKind
.Indexer
1933
Return
DeclarationKind
.Property
1937
Return
DeclarationKind
.Operator
1940
Return
DeclarationKind
.Operator
1943
Return
DeclarationKind
.CustomEvent
1946
Return
DeclarationKind
.Event
1949
Return
DeclarationKind
.Parameter
1951
Return
DeclarationKind
.Field
1954
Return
DeclarationKind
.Variable
1959
Return
DeclarationKind
.Field
1961
Return
DeclarationKind
.Variable
1967
Return
DeclarationKind
.Attribute
1972
Return
DeclarationKind
.Attribute
1975
Return
DeclarationKind
.GetAccessor
1977
Return
DeclarationKind
.SetAccessor
1979
Return
DeclarationKind
.AddAccessor
1981
Return
DeclarationKind
.RemoveAccessor
1983
Return
DeclarationKind
.RaiseAccessor
1986
Return
DeclarationKind
.None
2683
Private Shared Function GetModifierList(accessibility As Accessibility, modifiers As DeclarationModifiers, declaration As SyntaxNode, kind As
DeclarationKind
, Optional isDefault As Boolean = False) As SyntaxTokenList
2714
Dim isClass = kind =
DeclarationKind
.Class OrElse declaration.IsKind(SyntaxKind.ClassStatement)
2772
If (kind =
DeclarationKind
.Field AndAlso _list.Count = 0) Then
3433
modifiers:=GetModifierList(accessibility, modifiers And GetAllowedModifiers(SyntaxKind.EventStatement), declaration:=Nothing,
DeclarationKind
.Event),
3489
modifiers:=GetModifierList(accessibility, modifiers And GetAllowedModifiers(SyntaxKind.EventStatement), declaration:=Nothing,
DeclarationKind
.Event),
Microsoft.CodeAnalysis.VisualBasic.Workspaces.UnitTests (45)
CodeGeneration\SyntaxGeneratorTests.vb (45)
2262
CheckAddRemoveAttribute(Generator.GetAccessor(prop,
DeclarationKind
.GetAccessor))
2263
CheckAddRemoveAttribute(Generator.GetAccessor(prop,
DeclarationKind
.SetAccessor))
2264
CheckAddRemoveAttribute(Generator.GetAccessor(evnt,
DeclarationKind
.AddAccessor))
2265
CheckAddRemoveAttribute(Generator.GetAccessor(evnt,
DeclarationKind
.RemoveAccessor))
2266
CheckAddRemoveAttribute(Generator.GetAccessor(evnt,
DeclarationKind
.RaiseAccessor))
2521
Assert.Equal(
DeclarationKind
.CompilationUnit, Generator.GetDeclarationKind(Generator.CompilationUnit()))
2522
Assert.Equal(
DeclarationKind
.Class, Generator.GetDeclarationKind(Generator.ClassDeclaration("c")))
2523
Assert.Equal(
DeclarationKind
.Struct, Generator.GetDeclarationKind(Generator.StructDeclaration("s")))
2524
Assert.Equal(
DeclarationKind
.Interface, Generator.GetDeclarationKind(Generator.InterfaceDeclaration("i")))
2525
Assert.Equal(
DeclarationKind
.Enum, Generator.GetDeclarationKind(Generator.EnumDeclaration("e")))
2526
Assert.Equal(
DeclarationKind
.Delegate, Generator.GetDeclarationKind(Generator.DelegateDeclaration("d")))
2527
Assert.Equal(
DeclarationKind
.Method, Generator.GetDeclarationKind(Generator.MethodDeclaration("m")))
2528
Assert.Equal(
DeclarationKind
.Method, Generator.GetDeclarationKind(Generator.MethodDeclaration("m", modifiers:=DeclarationModifiers.Abstract)))
2529
Assert.Equal(
DeclarationKind
.Constructor, Generator.GetDeclarationKind(Generator.ConstructorDeclaration()))
2530
Assert.Equal(
DeclarationKind
.Parameter, Generator.GetDeclarationKind(Generator.ParameterDeclaration("p")))
2531
Assert.Equal(
DeclarationKind
.Property, Generator.GetDeclarationKind(Generator.PropertyDeclaration("p", Generator.IdentifierName("t"))))
2532
Assert.Equal(
DeclarationKind
.Property, Generator.GetDeclarationKind(Generator.PropertyDeclaration("p", Generator.IdentifierName("t"), modifiers:=DeclarationModifiers.Abstract)))
2533
Assert.Equal(
DeclarationKind
.Indexer, Generator.GetDeclarationKind(Generator.IndexerDeclaration({Generator.ParameterDeclaration("i")}, Generator.IdentifierName("t"))))
2534
Assert.Equal(
DeclarationKind
.Indexer, Generator.GetDeclarationKind(Generator.IndexerDeclaration({Generator.ParameterDeclaration("i")}, Generator.IdentifierName("t"), modifiers:=DeclarationModifiers.Abstract)))
2535
Assert.Equal(
DeclarationKind
.Field, Generator.GetDeclarationKind(Generator.FieldDeclaration("f", Generator.IdentifierName("t"))))
2536
Assert.Equal(
DeclarationKind
.EnumMember, Generator.GetDeclarationKind(Generator.EnumMember("v")))
2537
Assert.Equal(
DeclarationKind
.Event, Generator.GetDeclarationKind(Generator.EventDeclaration("e", Generator.IdentifierName("t"))))
2538
Assert.Equal(
DeclarationKind
.CustomEvent, Generator.GetDeclarationKind(Generator.CustomEventDeclaration("ce", Generator.IdentifierName("t"))))
2539
Assert.Equal(
DeclarationKind
.Namespace, Generator.GetDeclarationKind(Generator.NamespaceDeclaration("n")))
2540
Assert.Equal(
DeclarationKind
.NamespaceImport, Generator.GetDeclarationKind(Generator.NamespaceImportDeclaration("u")))
2541
Assert.Equal(
DeclarationKind
.Variable, Generator.GetDeclarationKind(Generator.LocalDeclarationStatement(Generator.IdentifierName("t"), "loc")))
2542
Assert.Equal(
DeclarationKind
.Attribute, Generator.GetDeclarationKind(Generator.Attribute("a")))
3015
Dim getAccessor = _g.GetAccessor(prop,
DeclarationKind
.GetAccessor)
3025
Dim setAccessor = _g.GetAccessor(prop,
DeclarationKind
.SetAccessor)
3030
Assert.Null(_g.GetAccessor(_g.RemoveNode(prop, getAccessor),
DeclarationKind
.GetAccessor))
3031
Assert.Null(_g.GetAccessor(_g.RemoveNode(prop, setAccessor),
DeclarationKind
.SetAccessor))
3048
Assert.Equal(Accessibility.Public, _g.GetAccessibility(_g.GetAccessor(newProp,
DeclarationKind
.GetAccessor)))
3051
Assert.Equal(Accessibility.Public, _g.GetAccessibility(_g.GetAccessor(newProp,
DeclarationKind
.SetAccessor)))
3439
Assert.Equal(
DeclarationKind
.Field, Generator.GetDeclarationKind(declX))
3440
Assert.Equal(
DeclarationKind
.Field, Generator.GetDeclarationKind(declY))
3441
Assert.Equal(
DeclarationKind
.Field, Generator.GetDeclarationKind(declZ))
3462
Assert.Equal(
DeclarationKind
.Field, Generator.GetDeclarationKind(xTypedT))
3467
Assert.Equal(
DeclarationKind
.Field, Generator.GetDeclarationKind(xNamedQ))
3472
Assert.Equal(
DeclarationKind
.Field, Generator.GetDeclarationKind(xInitialized))
3477
Assert.Equal(
DeclarationKind
.Field, Generator.GetDeclarationKind(xPrivate))
3482
Assert.Equal(
DeclarationKind
.Field, Generator.GetDeclarationKind(xReadOnly))
3487
Assert.Equal(
DeclarationKind
.Field, Generator.GetDeclarationKind(xAttributed))
3699
Assert.Equal(
DeclarationKind
.Attribute, Generator.GetDeclarationKind(xNamedQ))
3704
Assert.Equal(
DeclarationKind
.Attribute, Generator.GetDeclarationKind(xWithArg))
3825
Assert.Equal(
DeclarationKind
.NamespaceImport, Generator.GetDeclarationKind(xRenamedQ))
Microsoft.CodeAnalysis.Workspaces (6)
Editing\SyntaxGenerator.cs (5)
82
if (GetDeclarationKind(node) !=
DeclarationKind
.None)
96
public SyntaxNode? GetDeclaration(SyntaxNode? node,
DeclarationKind
kind)
1231
/// Gets the <see cref="
DeclarationKind
"/> for the declaration.
1233
public abstract
DeclarationKind
GetDeclarationKind(SyntaxNode declaration);
1317
public SyntaxNode? GetAccessor(SyntaxNode declaration,
DeclarationKind
kind)
Simplification\AbstractSimplificationService.cs (1)
297
&& gen.GetDeclarationKind(n) ==
DeclarationKind
.NamespaceImport
Microsoft.VisualStudio.LanguageServices.Implementation (1)
CodeModel\AbstractCodeModelService.cs (1)
1075
if (gen.GetDeclarationKind(node) !=
DeclarationKind
.NamespaceImport)