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