202 references to DeclarationKind
Microsoft.CodeAnalysis.CSharp.Workspaces (49)
CodeGeneration\CSharpSyntaxGenerator.cs (8)
1877public override DeclarationKind GetDeclarationKind(SyntaxNode declaration) 2103case DeclarationKind.Class: 2104case DeclarationKind.Interface: 2105case DeclarationKind.Struct: 2106case DeclarationKind.Enum: 2107case DeclarationKind.Namespace: 2108case DeclarationKind.CompilationUnit: 2117case 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)
210modifiers:=GetModifierList(accessibility, modifiers And GetAllowedModifiers(SyntaxKind.EventStatement), declaration:=Nothing, DeclarationKind.Event), 364Friend Shared Function GetModifierList(accessibility As Accessibility, modifiers As DeclarationModifiers, declaration As SyntaxNode, kind As DeclarationKind, Optional isDefault As Boolean = False) As SyntaxTokenList 395Dim isClass = kind = DeclarationKind.Class OrElse declaration.IsKind(SyntaxKind.ClassStatement) 453If (kind = DeclarationKind.Field AndAlso _list.Count = 0) Then
Microsoft.CodeAnalysis.VisualBasic.Workspaces (54)
CodeGeneration\VisualBasicSyntaxGenerator.vb (50)
681modifiers:=GetModifierList(accessibility, modifiers And VisualBasicSyntaxGeneratorInternal.s_fieldModifiers, declaration:=Nothing, DeclarationKind.Field), 697modifiers:=GetModifierList(accessibility, modifiers And VisualBasicSyntaxGeneratorInternal.s_methodModifiers, declaration:=Nothing, DeclarationKind.Method), 733Dim modifierList As SyntaxTokenList = GetModifierList(accessibility, modifiers And VisualBasicSyntaxGeneratorInternal.s_methodModifiers, declaration:=Nothing, DeclarationKind.Operator) 854SyntaxFactory.GetAccessorStatement().WithModifiers(GetModifierList(accessibility, DeclarationModifiers.None, declaration:=Nothing, DeclarationKind.Property)), 860SyntaxFactory.SetAccessorStatement().WithModifiers(GetModifierList(accessibility, DeclarationModifiers.None, declaration:=Nothing, DeclarationKind.Property)), 931modifiers:=GetModifierList(accessibility, modifiers And VisualBasicSyntaxGeneratorInternal.s_propertyModifiers, declaration:=Nothing, DeclarationKind.Property), 964modifiers:=GetModifierList(accessibility, modifiers And VisualBasicSyntaxGeneratorInternal.s_indexerModifiers, declaration:=Nothing, DeclarationKind.Indexer, isDefault:=True), 1211modifiers:=GetModifierList(accessibility, modifiers And VisualBasicSyntaxGeneratorInternal.s_constructorModifiers, declaration:=Nothing, DeclarationKind.Constructor), 1248modifiers:=GetModifierList(accessibility, modifiers And VisualBasicSyntaxGeneratorInternal.s_classModifiers, declaration:=Nothing, DeclarationKind.Class), 1285modifiers:=GetModifierList(accessibility, modifiers And VisualBasicSyntaxGeneratorInternal.s_structModifiers, declaration:=Nothing, DeclarationKind.Struct), 1308modifiers:=GetModifierList(accessibility, DeclarationModifiers.None, declaration:=Nothing, DeclarationKind.Interface), 1371modifiers:=GetModifierList(accessibility, modifiers And GetAllowedModifiers(SyntaxKind.EnumStatement), declaration:=Nothing, DeclarationKind.Enum), 1423modifiers:=GetModifierList(accessibility, modifiers And GetAllowedModifiers(kind), declaration:=Nothing, DeclarationKind.Delegate), 1756Public Overrides Function GetDeclarationKind(declaration As SyntaxNode) As DeclarationKind 1759Return DeclarationKind.CompilationUnit 1761Return DeclarationKind.Namespace 1763Return DeclarationKind.NamespaceImport 1765Return DeclarationKind.Class 1767Return DeclarationKind.Struct 1769Return DeclarationKind.Interface 1771Return DeclarationKind.Enum 1773Return DeclarationKind.EnumMember 1776Return DeclarationKind.Delegate 1779Return DeclarationKind.Method 1782Return DeclarationKind.Method 1786Return DeclarationKind.Method 1789Return DeclarationKind.Constructor 1792Return DeclarationKind.Indexer 1794Return DeclarationKind.Property 1799Return DeclarationKind.Indexer 1801Return DeclarationKind.Property 1805Return DeclarationKind.Operator 1808Return DeclarationKind.Operator 1811Return DeclarationKind.CustomEvent 1814Return DeclarationKind.Event 1817Return DeclarationKind.Parameter 1819Return DeclarationKind.Field 1822Return DeclarationKind.Variable 1827Return DeclarationKind.Field 1829Return DeclarationKind.Variable 1835Return DeclarationKind.Attribute 1840Return DeclarationKind.Attribute 1843Return DeclarationKind.GetAccessor 1845Return DeclarationKind.SetAccessor 1847Return DeclarationKind.AddAccessor 1849Return DeclarationKind.RemoveAccessor 1851Return DeclarationKind.RaiseAccessor 1854Return DeclarationKind.None 2551Friend Shared Function GetModifierList(accessibility As Accessibility, modifiers As DeclarationModifiers, declaration As SyntaxNode, kind As DeclarationKind, Optional isDefault As Boolean = False) As SyntaxTokenList 3214modifiers:=GetModifierList(accessibility, modifiers And GetAllowedModifiers(SyntaxKind.EventStatement), declaration:=Nothing, DeclarationKind.Event),
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\LanguageServices\VisualBasicSyntaxGeneratorInternal.vb (4)
210modifiers:=GetModifierList(accessibility, modifiers And GetAllowedModifiers(SyntaxKind.EventStatement), declaration:=Nothing, DeclarationKind.Event), 364Friend Shared Function GetModifierList(accessibility As Accessibility, modifiers As DeclarationModifiers, declaration As SyntaxNode, kind As DeclarationKind, Optional isDefault As Boolean = False) As SyntaxTokenList 395Dim isClass = kind = DeclarationKind.Class OrElse declaration.IsKind(SyntaxKind.ClassStatement) 453If (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)