202 references to DeclarationKind
Microsoft.CodeAnalysis.CSharp.Workspaces (49)
CodeGeneration\CSharpSyntaxGenerator.cs (8)
1874public override DeclarationKind GetDeclarationKind(SyntaxNode declaration) 2100case DeclarationKind.Class: 2101case DeclarationKind.Interface: 2102case DeclarationKind.Struct: 2103case DeclarationKind.Enum: 2104case DeclarationKind.Namespace: 2105case DeclarationKind.CompilationUnit: 2114case DeclarationKind.Attribute:
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpAccessibilityFacts.cs (41)
50var declarationKind = GetDeclarationKind(declaration); 51return declarationKind is DeclarationKind.Field or DeclarationKind.Event; 153public static DeclarationKind GetDeclarationKind(SyntaxNode declaration) 159return DeclarationKind.Class; 162return DeclarationKind.Struct; 164return DeclarationKind.Interface; 166return DeclarationKind.Enum; 168return DeclarationKind.Delegate; 171return DeclarationKind.Method; 173return DeclarationKind.Operator; 175return DeclarationKind.ConversionOperator; 177return DeclarationKind.Constructor; 179return DeclarationKind.Destructor; 182return DeclarationKind.Property; 184return DeclarationKind.Indexer; 186return DeclarationKind.CustomEvent; 188return DeclarationKind.EnumMember; 190return DeclarationKind.CompilationUnit; 193return DeclarationKind.Namespace; 195return DeclarationKind.NamespaceImport; 197return DeclarationKind.Parameter; 201return DeclarationKind.LambdaExpression; 208return DeclarationKind.Field; 212return DeclarationKind.None; 220return DeclarationKind.Event; 224return DeclarationKind.None; 232return DeclarationKind.Variable; 236return DeclarationKind.None; 245return DeclarationKind.Variable; 249return DeclarationKind.None; 262return DeclarationKind.Field; 266return DeclarationKind.Event; 270return DeclarationKind.Variable; 281return DeclarationKind.Attribute; 289return DeclarationKind.Attribute; 295return DeclarationKind.GetAccessor; 298return DeclarationKind.SetAccessor; 300return DeclarationKind.AddAccessor; 302return DeclarationKind.RemoveAccessor; 305return DeclarationKind.None;
Microsoft.CodeAnalysis.CSharp.Workspaces.UnitTests (44)
CodeGeneration\SyntaxGeneratorTests.cs (44)
1960CheckAddRemoveAttribute(Generator.GetAccessor(prop, DeclarationKind.GetAccessor)); 1961CheckAddRemoveAttribute(Generator.GetAccessor(prop, DeclarationKind.SetAccessor)); 1962CheckAddRemoveAttribute(Generator.GetAccessor(evnt, DeclarationKind.AddAccessor)); 1963CheckAddRemoveAttribute(Generator.GetAccessor(evnt, DeclarationKind.RemoveAccessor)); 2873Assert.Equal(DeclarationKind.CompilationUnit, Generator.GetDeclarationKind(Generator.CompilationUnit())); 2874Assert.Equal(DeclarationKind.Class, Generator.GetDeclarationKind(Generator.ClassDeclaration("c"))); 2875Assert.Equal(DeclarationKind.Struct, Generator.GetDeclarationKind(Generator.StructDeclaration("s"))); 2876Assert.Equal(DeclarationKind.Interface, Generator.GetDeclarationKind(Generator.InterfaceDeclaration("i"))); 2877Assert.Equal(DeclarationKind.Enum, Generator.GetDeclarationKind(Generator.EnumDeclaration("e"))); 2878Assert.Equal(DeclarationKind.Delegate, Generator.GetDeclarationKind(Generator.DelegateDeclaration("d"))); 2879Assert.Equal(DeclarationKind.Method, Generator.GetDeclarationKind(Generator.MethodDeclaration("m"))); 2880Assert.Equal(DeclarationKind.Constructor, Generator.GetDeclarationKind(Generator.ConstructorDeclaration())); 2881Assert.Equal(DeclarationKind.Parameter, Generator.GetDeclarationKind(Generator.ParameterDeclaration("p"))); 2882Assert.Equal(DeclarationKind.Property, Generator.GetDeclarationKind(Generator.PropertyDeclaration("p", Generator.IdentifierName("t")))); 2883Assert.Equal(DeclarationKind.Indexer, Generator.GetDeclarationKind(Generator.IndexerDeclaration([Generator.ParameterDeclaration("i")], Generator.IdentifierName("t")))); 2884Assert.Equal(DeclarationKind.Field, Generator.GetDeclarationKind(Generator.FieldDeclaration("f", Generator.IdentifierName("t")))); 2885Assert.Equal(DeclarationKind.EnumMember, Generator.GetDeclarationKind(Generator.EnumMember("v"))); 2886Assert.Equal(DeclarationKind.Event, Generator.GetDeclarationKind(Generator.EventDeclaration("ef", Generator.IdentifierName("t")))); 2887Assert.Equal(DeclarationKind.CustomEvent, Generator.GetDeclarationKind(Generator.CustomEventDeclaration("e", Generator.IdentifierName("t")))); 2888Assert.Equal(DeclarationKind.Namespace, Generator.GetDeclarationKind(Generator.NamespaceDeclaration("n"))); 2889Assert.Equal(DeclarationKind.NamespaceImport, Generator.GetDeclarationKind(Generator.NamespaceImportDeclaration("u"))); 2890Assert.Equal(DeclarationKind.Variable, Generator.GetDeclarationKind(Generator.LocalDeclarationStatement(Generator.IdentifierName("t"), "loc"))); 2891Assert.Equal(DeclarationKind.Attribute, Generator.GetDeclarationKind(Generator.Attribute("a"))); 3356var getAccessor = Generator.GetAccessor(prop, DeclarationKind.GetAccessor); 3365var setAccessor = Generator.GetAccessor(prop, DeclarationKind.SetAccessor); 3370Assert.Null(Generator.GetAccessor(Generator.RemoveNode(prop, getAccessor), DeclarationKind.GetAccessor)); 3371Assert.Null(Generator.GetAccessor(Generator.RemoveNode(prop, setAccessor), DeclarationKind.SetAccessor)); 3393Assert.Equal(Accessibility.Public, Generator.GetAccessibility(Generator.GetAccessor(newProp, DeclarationKind.GetAccessor))); 3396Assert.Equal(Accessibility.Public, Generator.GetAccessibility(Generator.GetAccessor(newProp, DeclarationKind.SetAccessor))); 3456var y2 = Generator.AddAccessors(y, [Generator.GetAccessor(x, DeclarationKind.GetAccessor)]); 3477var y2 = Generator.AddAccessors(y, [Generator.GetAccessor(x, DeclarationKind.GetAccessor)]); 3792Assert.Equal(DeclarationKind.Field, Generator.GetDeclarationKind(declX)); 3793Assert.Equal(DeclarationKind.Field, Generator.GetDeclarationKind(declY)); 3794Assert.Equal(DeclarationKind.Field, Generator.GetDeclarationKind(declZ)); 3815Assert.Equal(DeclarationKind.Field, Generator.GetDeclarationKind(xTypedT)); 3820Assert.Equal(DeclarationKind.Field, Generator.GetDeclarationKind(xNamedQ)); 3825Assert.Equal(DeclarationKind.Field, Generator.GetDeclarationKind(xInitialized)); 3830Assert.Equal(DeclarationKind.Field, Generator.GetDeclarationKind(xPrivate)); 3835Assert.Equal(DeclarationKind.Field, Generator.GetDeclarationKind(xReadOnly)); 3840Assert.Equal(DeclarationKind.Field, Generator.GetDeclarationKind(xAttributed)); 4143Assert.Equal(DeclarationKind.Attribute, Generator.GetDeclarationKind(xNamedQ)); 4148Assert.Equal(DeclarationKind.Attribute, Generator.GetDeclarationKind(xWithArg)); 4323Assert.Equal(DeclarationKind.Attribute, Generator.GetDeclarationKind(xNamedQ)); 4328Assert.Equal(DeclarationKind.Attribute, Generator.GetDeclarationKind(xWithArg));
Microsoft.CodeAnalysis.VisualBasic.CodeStyle.Fixes (4)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\LanguageServices\VisualBasicSyntaxGeneratorInternal.vb (4)
211modifiers:=GetModifierList(accessibility, modifiers And GetAllowedModifiers(SyntaxKind.EventStatement), declaration:=Nothing, DeclarationKind.Event), 365Friend Shared Function GetModifierList(accessibility As Accessibility, modifiers As DeclarationModifiers, declaration As SyntaxNode, kind As DeclarationKind, Optional isDefault As Boolean = False) As SyntaxTokenList 396Dim isClass = kind = DeclarationKind.Class OrElse declaration.IsKind(SyntaxKind.ClassStatement) 454If (kind = DeclarationKind.Field AndAlso _list.Count = 0) Then
Microsoft.CodeAnalysis.VisualBasic.Workspaces (54)
CodeGeneration\VisualBasicSyntaxGenerator.vb (50)
631modifiers:=GetModifierList(accessibility, modifiers And VisualBasicSyntaxGeneratorInternal.s_fieldModifiers, declaration:=Nothing, DeclarationKind.Field), 647modifiers:=GetModifierList(accessibility, modifiers And VisualBasicSyntaxGeneratorInternal.s_methodModifiers, declaration:=Nothing, DeclarationKind.Method), 683Dim modifierList As SyntaxTokenList = GetModifierList(accessibility, modifiers And VisualBasicSyntaxGeneratorInternal.s_methodModifiers, declaration:=Nothing, DeclarationKind.Operator) 804SyntaxFactory.GetAccessorStatement().WithModifiers(GetModifierList(accessibility, DeclarationModifiers.None, declaration:=Nothing, DeclarationKind.Property)), 810SyntaxFactory.SetAccessorStatement().WithModifiers(GetModifierList(accessibility, DeclarationModifiers.None, declaration:=Nothing, DeclarationKind.Property)), 881modifiers:=GetModifierList(accessibility, modifiers And VisualBasicSyntaxGeneratorInternal.s_propertyModifiers, declaration:=Nothing, DeclarationKind.Property), 914modifiers:=GetModifierList(accessibility, modifiers And VisualBasicSyntaxGeneratorInternal.s_indexerModifiers, declaration:=Nothing, DeclarationKind.Indexer, isDefault:=True), 1161modifiers:=GetModifierList(accessibility, modifiers And VisualBasicSyntaxGeneratorInternal.s_constructorModifiers, declaration:=Nothing, DeclarationKind.Constructor), 1198modifiers:=GetModifierList(accessibility, modifiers And VisualBasicSyntaxGeneratorInternal.s_classModifiers, declaration:=Nothing, DeclarationKind.Class), 1235modifiers:=GetModifierList(accessibility, modifiers And VisualBasicSyntaxGeneratorInternal.s_structModifiers, declaration:=Nothing, DeclarationKind.Struct), 1258modifiers:=GetModifierList(accessibility, DeclarationModifiers.None, declaration:=Nothing, DeclarationKind.Interface), 1321modifiers:=GetModifierList(accessibility, modifiers And GetAllowedModifiers(SyntaxKind.EnumStatement), declaration:=Nothing, DeclarationKind.Enum), 1373modifiers:=GetModifierList(accessibility, modifiers And GetAllowedModifiers(kind), declaration:=Nothing, DeclarationKind.Delegate), 1706Public Overrides Function GetDeclarationKind(declaration As SyntaxNode) As DeclarationKind 1709Return DeclarationKind.CompilationUnit 1711Return DeclarationKind.Namespace 1713Return DeclarationKind.NamespaceImport 1715Return DeclarationKind.Class 1717Return DeclarationKind.Struct 1719Return DeclarationKind.Interface 1721Return DeclarationKind.Enum 1723Return DeclarationKind.EnumMember 1726Return DeclarationKind.Delegate 1729Return DeclarationKind.Method 1732Return DeclarationKind.Method 1736Return DeclarationKind.Method 1739Return DeclarationKind.Constructor 1742Return DeclarationKind.Indexer 1744Return DeclarationKind.Property 1749Return DeclarationKind.Indexer 1751Return DeclarationKind.Property 1755Return DeclarationKind.Operator 1758Return DeclarationKind.Operator 1761Return DeclarationKind.CustomEvent 1764Return DeclarationKind.Event 1767Return DeclarationKind.Parameter 1769Return DeclarationKind.Field 1772Return DeclarationKind.Variable 1777Return DeclarationKind.Field 1779Return DeclarationKind.Variable 1785Return DeclarationKind.Attribute 1790Return DeclarationKind.Attribute 1793Return DeclarationKind.GetAccessor 1795Return DeclarationKind.SetAccessor 1797Return DeclarationKind.AddAccessor 1799Return DeclarationKind.RemoveAccessor 1801Return DeclarationKind.RaiseAccessor 1804Return DeclarationKind.None 2501Friend Shared Function GetModifierList(accessibility As Accessibility, modifiers As DeclarationModifiers, declaration As SyntaxNode, kind As DeclarationKind, Optional isDefault As Boolean = False) As SyntaxTokenList 3164modifiers:=GetModifierList(accessibility, modifiers And GetAllowedModifiers(SyntaxKind.EventStatement), declaration:=Nothing, DeclarationKind.Event),
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\LanguageServices\VisualBasicSyntaxGeneratorInternal.vb (4)
211modifiers:=GetModifierList(accessibility, modifiers And GetAllowedModifiers(SyntaxKind.EventStatement), declaration:=Nothing, DeclarationKind.Event), 365Friend Shared Function GetModifierList(accessibility As Accessibility, modifiers As DeclarationModifiers, declaration As SyntaxNode, kind As DeclarationKind, Optional isDefault As Boolean = False) As SyntaxTokenList 396Dim isClass = kind = DeclarationKind.Class OrElse declaration.IsKind(SyntaxKind.ClassStatement) 454If (kind = DeclarationKind.Field AndAlso _list.Count = 0) Then
Microsoft.CodeAnalysis.VisualBasic.Workspaces.UnitTests (45)
CodeGeneration\SyntaxGeneratorTests.vb (45)
2279CheckAddRemoveAttribute(Generator.GetAccessor(prop, DeclarationKind.GetAccessor)) 2280CheckAddRemoveAttribute(Generator.GetAccessor(prop, DeclarationKind.SetAccessor)) 2281CheckAddRemoveAttribute(Generator.GetAccessor(evnt, DeclarationKind.AddAccessor)) 2282CheckAddRemoveAttribute(Generator.GetAccessor(evnt, DeclarationKind.RemoveAccessor)) 2283CheckAddRemoveAttribute(Generator.GetAccessor(evnt, DeclarationKind.RaiseAccessor)) 2565Assert.Equal(DeclarationKind.CompilationUnit, Generator.GetDeclarationKind(Generator.CompilationUnit())) 2566Assert.Equal(DeclarationKind.Class, Generator.GetDeclarationKind(Generator.ClassDeclaration("c"))) 2567Assert.Equal(DeclarationKind.Struct, Generator.GetDeclarationKind(Generator.StructDeclaration("s"))) 2568Assert.Equal(DeclarationKind.Interface, Generator.GetDeclarationKind(Generator.InterfaceDeclaration("i"))) 2569Assert.Equal(DeclarationKind.Enum, Generator.GetDeclarationKind(Generator.EnumDeclaration("e"))) 2570Assert.Equal(DeclarationKind.Delegate, Generator.GetDeclarationKind(Generator.DelegateDeclaration("d"))) 2571Assert.Equal(DeclarationKind.Method, Generator.GetDeclarationKind(Generator.MethodDeclaration("m"))) 2572Assert.Equal(DeclarationKind.Method, Generator.GetDeclarationKind(Generator.MethodDeclaration("m", modifiers:=DeclarationModifiers.Abstract))) 2573Assert.Equal(DeclarationKind.Constructor, Generator.GetDeclarationKind(Generator.ConstructorDeclaration())) 2574Assert.Equal(DeclarationKind.Parameter, Generator.GetDeclarationKind(Generator.ParameterDeclaration("p"))) 2575Assert.Equal(DeclarationKind.Property, Generator.GetDeclarationKind(Generator.PropertyDeclaration("p", Generator.IdentifierName("t")))) 2576Assert.Equal(DeclarationKind.Property, Generator.GetDeclarationKind(Generator.PropertyDeclaration("p", Generator.IdentifierName("t"), modifiers:=DeclarationModifiers.Abstract))) 2577Assert.Equal(DeclarationKind.Indexer, Generator.GetDeclarationKind(Generator.IndexerDeclaration({Generator.ParameterDeclaration("i")}, Generator.IdentifierName("t")))) 2578Assert.Equal(DeclarationKind.Indexer, Generator.GetDeclarationKind(Generator.IndexerDeclaration({Generator.ParameterDeclaration("i")}, Generator.IdentifierName("t"), modifiers:=DeclarationModifiers.Abstract))) 2579Assert.Equal(DeclarationKind.Field, Generator.GetDeclarationKind(Generator.FieldDeclaration("f", Generator.IdentifierName("t")))) 2580Assert.Equal(DeclarationKind.EnumMember, Generator.GetDeclarationKind(Generator.EnumMember("v"))) 2581Assert.Equal(DeclarationKind.Event, Generator.GetDeclarationKind(Generator.EventDeclaration("e", Generator.IdentifierName("t")))) 2582Assert.Equal(DeclarationKind.CustomEvent, Generator.GetDeclarationKind(Generator.CustomEventDeclaration("ce", Generator.IdentifierName("t")))) 2583Assert.Equal(DeclarationKind.Namespace, Generator.GetDeclarationKind(Generator.NamespaceDeclaration("n"))) 2584Assert.Equal(DeclarationKind.NamespaceImport, Generator.GetDeclarationKind(Generator.NamespaceImportDeclaration("u"))) 2585Assert.Equal(DeclarationKind.Variable, Generator.GetDeclarationKind(Generator.LocalDeclarationStatement(Generator.IdentifierName("t"), "loc"))) 2586Assert.Equal(DeclarationKind.Attribute, Generator.GetDeclarationKind(Generator.Attribute("a"))) 3059Dim getAccessor = _g.GetAccessor(prop, DeclarationKind.GetAccessor) 3069Dim setAccessor = _g.GetAccessor(prop, DeclarationKind.SetAccessor) 3074Assert.Null(_g.GetAccessor(_g.RemoveNode(prop, getAccessor), DeclarationKind.GetAccessor)) 3075Assert.Null(_g.GetAccessor(_g.RemoveNode(prop, setAccessor), DeclarationKind.SetAccessor)) 3092Assert.Equal(Accessibility.Public, _g.GetAccessibility(_g.GetAccessor(newProp, DeclarationKind.GetAccessor))) 3095Assert.Equal(Accessibility.Public, _g.GetAccessibility(_g.GetAccessor(newProp, DeclarationKind.SetAccessor))) 3483Assert.Equal(DeclarationKind.Field, Generator.GetDeclarationKind(declX)) 3484Assert.Equal(DeclarationKind.Field, Generator.GetDeclarationKind(declY)) 3485Assert.Equal(DeclarationKind.Field, Generator.GetDeclarationKind(declZ)) 3506Assert.Equal(DeclarationKind.Field, Generator.GetDeclarationKind(xTypedT)) 3511Assert.Equal(DeclarationKind.Field, Generator.GetDeclarationKind(xNamedQ)) 3516Assert.Equal(DeclarationKind.Field, Generator.GetDeclarationKind(xInitialized)) 3521Assert.Equal(DeclarationKind.Field, Generator.GetDeclarationKind(xPrivate)) 3526Assert.Equal(DeclarationKind.Field, Generator.GetDeclarationKind(xReadOnly)) 3531Assert.Equal(DeclarationKind.Field, Generator.GetDeclarationKind(xAttributed)) 3743Assert.Equal(DeclarationKind.Attribute, Generator.GetDeclarationKind(xNamedQ)) 3748Assert.Equal(DeclarationKind.Attribute, Generator.GetDeclarationKind(xWithArg)) 3869Assert.Equal(DeclarationKind.NamespaceImport, Generator.GetDeclarationKind(xRenamedQ))
Microsoft.CodeAnalysis.Workspaces (5)
Editing\SyntaxGenerator.cs (5)
89if (GetDeclarationKind(node) != DeclarationKind.None) 103public SyntaxNode? GetDeclaration(SyntaxNode? node, DeclarationKind kind) 1234/// Gets the <see cref="DeclarationKind"/> for the declaration. 1236public abstract DeclarationKind GetDeclarationKind(SyntaxNode declaration); 1320public SyntaxNode? GetAccessor(SyntaxNode declaration, DeclarationKind kind)
Microsoft.Interop.ComInterfaceGenerator (1)
Analyzers\ConvertComImportToGeneratedComInterfaceFixer.cs (1)
105if (gen.GetDeclarationKind(member) != DeclarationKind.Method)