ChangeSignature\CSharpChangeSignatureService.cs (81)
39private static readonly ImmutableArray<SyntaxKind> _declarationKinds = ImmutableArray.Create(
40SyntaxKind.MethodDeclaration,
41SyntaxKind.ConstructorDeclaration,
42SyntaxKind.IndexerDeclaration,
43SyntaxKind.DelegateDeclaration,
44SyntaxKind.SimpleLambdaExpression,
45SyntaxKind.ParenthesizedLambdaExpression,
46SyntaxKind.LocalFunctionStatement,
47SyntaxKind.RecordStructDeclaration,
48SyntaxKind.RecordDeclaration,
49SyntaxKind.StructDeclaration,
50SyntaxKind.ClassDeclaration);
52private static readonly ImmutableArray<SyntaxKind> _declarationAndInvocableKinds =
54SyntaxKind.InvocationExpression,
55SyntaxKind.ElementAccessExpression,
56SyntaxKind.ThisConstructorInitializer,
57SyntaxKind.BaseConstructorInitializer,
58SyntaxKind.ObjectCreationExpression,
59SyntaxKind.ImplicitObjectCreationExpression,
60SyntaxKind.Attribute,
61SyntaxKind.NameMemberCref));
63private static readonly ImmutableArray<SyntaxKind> _updatableAncestorKinds = ImmutableArray.Create(
64SyntaxKind.ConstructorDeclaration,
65SyntaxKind.IndexerDeclaration,
66SyntaxKind.InvocationExpression,
67SyntaxKind.ElementAccessExpression,
68SyntaxKind.ThisConstructorInitializer,
69SyntaxKind.BaseConstructorInitializer,
70SyntaxKind.ObjectCreationExpression,
71SyntaxKind.Attribute,
72SyntaxKind.DelegateDeclaration,
73SyntaxKind.SimpleLambdaExpression,
74SyntaxKind.ParenthesizedLambdaExpression,
75SyntaxKind.NameMemberCref);
77private static readonly ImmutableArray<SyntaxKind> _updatableNodeKinds = ImmutableArray.Create(
78SyntaxKind.MethodDeclaration,
79SyntaxKind.LocalFunctionStatement,
80SyntaxKind.ConstructorDeclaration,
81SyntaxKind.IndexerDeclaration,
82SyntaxKind.InvocationExpression,
83SyntaxKind.ElementAccessExpression,
84SyntaxKind.ThisConstructorInitializer,
85SyntaxKind.BaseConstructorInitializer,
86SyntaxKind.ObjectCreationExpression,
87SyntaxKind.ImplicitObjectCreationExpression,
88SyntaxKind.Attribute,
89SyntaxKind.DelegateDeclaration,
90SyntaxKind.NameMemberCref,
91SyntaxKind.AnonymousMethodExpression,
92SyntaxKind.ParenthesizedLambdaExpression,
93SyntaxKind.SimpleLambdaExpression,
94SyntaxKind.RecordStructDeclaration,
95SyntaxKind.RecordDeclaration,
96SyntaxKind.StructDeclaration,
97SyntaxKind.ClassDeclaration);
114if (token.Kind() == SyntaxKind.SemicolonToken && token.Parent is StatementSyntax)
192current.Kind() == SyntaxKind.Block || current.Kind() == SyntaxKind.ArrowExpressionClause)
256case SyntaxKind.InvocationExpression:
259case SyntaxKind.ElementAccessExpression:
262case SyntaxKind.ObjectCreationExpression:
265case SyntaxKind.ConstructorDeclaration:
266case SyntaxKind.IndexerDeclaration:
267case SyntaxKind.ThisConstructorInitializer:
268case SyntaxKind.BaseConstructorInitializer:
269case SyntaxKind.Attribute:
270case SyntaxKind.DelegateDeclaration:
271case SyntaxKind.NameMemberCref:
291if (updatedNode.IsKind(SyntaxKind.MethodDeclaration) ||
292updatedNode.IsKind(SyntaxKind.ConstructorDeclaration) ||
293updatedNode.IsKind(SyntaxKind.IndexerDeclaration) ||
294updatedNode.IsKind(SyntaxKind.DelegateDeclaration) ||
295updatedNode.IsKind(SyntaxKind.RecordStructDeclaration) ||
296updatedNode.IsKind(SyntaxKind.RecordDeclaration) ||
297updatedNode.IsKind(SyntaxKind.StructDeclaration) ||
298updatedNode.IsKind(SyntaxKind.ClassDeclaration))
667var oldOnlyHasWhitespaceTrivia = oldTrivia.All(t => t.IsKind(SyntaxKind.WhitespaceTrivia));
670var newOnlyHasWhitespaceTrivia = newTrivia.All(t => t.IsKind(SyntaxKind.WhitespaceTrivia));
852if (!node.IsKind(SyntaxKind.IdentifierName) ||
898var initializerExpression = InitializerExpression(SyntaxKind.ArrayInitializerExpression, listOfArguments);
909=> Token(SyntaxKind.CommaToken).WithTrailingTrivia(ElasticSpace);
Completion\KeywordRecommenders\AbstractKeywordRecommender.cs (29)
14private static readonly ISet<SyntaxKind> s_validNonInterfaceMemberModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
16SyntaxKind.ExternKeyword,
17SyntaxKind.InternalKeyword,
18SyntaxKind.NewKeyword,
19SyntaxKind.PublicKeyword,
20SyntaxKind.ProtectedKeyword,
21SyntaxKind.UnsafeKeyword,
22SyntaxKind.OverrideKeyword,
25private static readonly ISet<SyntaxKind> s_validInterfaceMemberModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
27SyntaxKind.ExternKeyword,
28SyntaxKind.InternalKeyword,
29SyntaxKind.NewKeyword,
30SyntaxKind.PublicKeyword,
31SyntaxKind.ProtectedKeyword,
32SyntaxKind.StaticKeyword,
33SyntaxKind.UnsafeKeyword,
34SyntaxKind.OverrideKeyword,
37private static readonly ISet<SyntaxKind> s_validTypeModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
39SyntaxKind.InternalKeyword,
40SyntaxKind.NewKeyword,
41SyntaxKind.PublicKeyword,
42SyntaxKind.PrivateKeyword,
43SyntaxKind.ProtectedKeyword,
44SyntaxKind.UnsafeKeyword,
45SyntaxKind.FileKeyword,
49: base(SyntaxKind.AbstractKeyword)
Completion\KeywordRecommenders\ClassKeywordRecommender.cs (13)
14private static readonly ISet<SyntaxKind> s_validModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
16SyntaxKind.NewKeyword,
17SyntaxKind.PublicKeyword,
18SyntaxKind.ProtectedKeyword,
19SyntaxKind.InternalKeyword,
20SyntaxKind.PrivateKeyword,
21SyntaxKind.AbstractKeyword,
22SyntaxKind.SealedKeyword,
23SyntaxKind.StaticKeyword,
24SyntaxKind.UnsafeKeyword,
25SyntaxKind.FileKeyword,
29: base(SyntaxKind.ClassKeyword)
Completion\KeywordRecommenders\EventKeywordRecommender.cs (18)
15private static readonly ISet<SyntaxKind> s_validClassModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
17SyntaxKind.NewKeyword,
18SyntaxKind.PublicKeyword,
19SyntaxKind.ProtectedKeyword,
20SyntaxKind.InternalKeyword,
21SyntaxKind.PrivateKeyword,
22SyntaxKind.StaticKeyword,
23SyntaxKind.VirtualKeyword,
24SyntaxKind.SealedKeyword,
25SyntaxKind.OverrideKeyword,
26SyntaxKind.AbstractKeyword,
27SyntaxKind.ExternKeyword,
28SyntaxKind.UnsafeKeyword
31private static readonly ISet<SyntaxKind> s_validStructModifiers = new HashSet<SyntaxKind>(s_validClassModifiers, SyntaxFacts.EqualityComparer)
33SyntaxKind.ReadOnlyKeyword,
37: base(SyntaxKind.EventKeyword)
Completion\KeywordRecommenders\ExternKeywordRecommender.cs (32)
15private static readonly ISet<SyntaxKind> s_validModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
17SyntaxKind.InternalKeyword,
18SyntaxKind.NewKeyword,
19SyntaxKind.OverrideKeyword,
20SyntaxKind.PublicKeyword,
21SyntaxKind.PrivateKeyword,
22SyntaxKind.ProtectedKeyword,
23SyntaxKind.SealedKeyword,
24SyntaxKind.StaticKeyword,
25SyntaxKind.UnsafeKeyword,
26SyntaxKind.VirtualKeyword,
29private static readonly ISet<SyntaxKind> s_validGlobalModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
31SyntaxKind.InternalKeyword,
32SyntaxKind.NewKeyword,
33SyntaxKind.PublicKeyword,
34SyntaxKind.PrivateKeyword,
35SyntaxKind.StaticKeyword,
36SyntaxKind.UnsafeKeyword,
39private static readonly ISet<SyntaxKind> s_validLocalFunctionModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
41SyntaxKind.StaticKeyword,
42SyntaxKind.UnsafeKeyword
46: base(SyntaxKind.ExternKeyword)
84if (token.Kind() == SyntaxKind.None)
90if (token.Kind() == SyntaxKind.OpenBraceToken &&
91token.Parent.IsKind(SyntaxKind.NamespaceDeclaration))
98if (token.Kind() == SyntaxKind.SemicolonToken &&
99token.Parent.IsKind(SyntaxKind.FileScopedNamespaceDeclaration))
106if (token.Kind() == SyntaxKind.SemicolonToken &&
107token.Parent.IsKind(SyntaxKind.ExternAliasDirective))
Completion\KeywordRecommenders\NewKeywordRecommender.cs (27)
18private static readonly ISet<SyntaxKind> s_validMemberModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
20SyntaxKind.AbstractKeyword,
21SyntaxKind.ExternKeyword,
22SyntaxKind.InternalKeyword,
23SyntaxKind.PublicKeyword,
24SyntaxKind.PrivateKeyword,
25SyntaxKind.ProtectedKeyword,
26SyntaxKind.ReadOnlyKeyword,
27SyntaxKind.SealedKeyword,
28SyntaxKind.StaticKeyword,
29SyntaxKind.UnsafeKeyword,
30SyntaxKind.VirtualKeyword,
31SyntaxKind.VolatileKeyword,
34protected static readonly ISet<SyntaxKind> ValidTypeModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
36SyntaxKind.AbstractKeyword,
37SyntaxKind.InternalKeyword,
38SyntaxKind.PublicKeyword,
39SyntaxKind.PrivateKeyword,
40SyntaxKind.ProtectedKeyword,
41SyntaxKind.SealedKeyword,
42SyntaxKind.StaticKeyword,
43SyntaxKind.UnsafeKeyword
47: base(SyntaxKind.NewKeyword)
102if (token.Kind() == SyntaxKind.CommaToken &&
107.Any(c => c.ClassOrStructKeyword.Kind() == SyntaxKind.StructKeyword))
Completion\KeywordRecommenders\RecordKeywordRecommender.cs (14)
14private static readonly ISet<SyntaxKind> s_validModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
16SyntaxKind.NewKeyword,
17SyntaxKind.PublicKeyword,
18SyntaxKind.ProtectedKeyword,
19SyntaxKind.InternalKeyword,
20SyntaxKind.PrivateKeyword,
21SyntaxKind.AbstractKeyword,
22SyntaxKind.SealedKeyword,
23SyntaxKind.StaticKeyword,
24SyntaxKind.UnsafeKeyword,
25SyntaxKind.ReadOnlyKeyword,
26SyntaxKind.FileKeyword,
30: base(SyntaxKind.RecordKeyword)
Completion\KeywordRecommenders\RefKeywordRecommender.cs (54)
16: base(SyntaxKind.RefKeyword)
23private static readonly ISet<SyntaxKind> RefMemberModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
25SyntaxKind.AbstractKeyword,
27SyntaxKind.ExternKeyword,
28SyntaxKind.InternalKeyword,
29SyntaxKind.NewKeyword,
30SyntaxKind.OverrideKeyword,
31SyntaxKind.PublicKeyword,
32SyntaxKind.PrivateKeyword,
33SyntaxKind.ProtectedKeyword,
35SyntaxKind.SealedKeyword,
36SyntaxKind.StaticKeyword,
37SyntaxKind.UnsafeKeyword,
38SyntaxKind.VirtualKeyword,
45private static readonly ISet<SyntaxKind> RefGlobalMemberModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
48SyntaxKind.ExternKeyword,
49SyntaxKind.InternalKeyword,
50SyntaxKind.NewKeyword,
51SyntaxKind.OverrideKeyword,
52SyntaxKind.PublicKeyword,
53SyntaxKind.PrivateKeyword,
54SyntaxKind.ReadOnlyKeyword,
55SyntaxKind.StaticKeyword,
56SyntaxKind.UnsafeKeyword,
57SyntaxKind.VolatileKeyword,
63private static readonly ISet<SyntaxKind> RefGlobalMemberScriptModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
66SyntaxKind.ExternKeyword,
67SyntaxKind.InternalKeyword,
68SyntaxKind.NewKeyword,
69SyntaxKind.OverrideKeyword,
70SyntaxKind.PublicKeyword,
71SyntaxKind.PrivateKeyword,
73SyntaxKind.StaticKeyword,
74SyntaxKind.UnsafeKeyword,
94position, context.LeftToken, includeOperators: false, out var parameterIndex, out var previousModifier))
96if (previousModifier is SyntaxKind.None or SyntaxKind.ScopedKeyword)
101if (previousModifier == SyntaxKind.ThisKeyword &&
150case SyntaxKind.ReturnKeyword:
154case SyntaxKind.ScopedKeyword:
155case SyntaxKind.IdentifierToken when token.Text == "scoped":
161case SyntaxKind.EqualsGreaterThanToken:
169case SyntaxKind.OpenParenToken:
171return previous.IsKind(SyntaxKind.ForKeyword)
172|| previous.IsKind(SyntaxKind.ForEachKeyword);
177case SyntaxKind.EqualsToken:
179return parent?.Kind() == SyntaxKind.SimpleAssignmentExpression
180|| parent?.Parent?.Kind() == SyntaxKind.VariableDeclarator;
185case SyntaxKind.QuestionToken:
186case SyntaxKind.ColonToken:
187return token.Parent?.Kind() == SyntaxKind.ConditionalExpression;
Completion\KeywordRecommenders\SealedKeywordRecommender.cs (29)
14private static readonly ISet<SyntaxKind> s_validNonInterfaceMemberModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
16SyntaxKind.ExternKeyword,
17SyntaxKind.InternalKeyword,
18SyntaxKind.NewKeyword,
19SyntaxKind.OverrideKeyword,
20SyntaxKind.PublicKeyword,
21SyntaxKind.ProtectedKeyword,
22SyntaxKind.UnsafeKeyword,
25private static readonly ISet<SyntaxKind> s_validInterfaceMemberModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
27SyntaxKind.ExternKeyword,
28SyntaxKind.InternalKeyword,
29SyntaxKind.NewKeyword,
30SyntaxKind.OverrideKeyword,
31SyntaxKind.PublicKeyword,
32SyntaxKind.ProtectedKeyword,
33SyntaxKind.StaticKeyword,
34SyntaxKind.UnsafeKeyword,
37private static readonly ISet<SyntaxKind> s_validTypeModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
39SyntaxKind.InternalKeyword,
40SyntaxKind.NewKeyword,
41SyntaxKind.PublicKeyword,
42SyntaxKind.PrivateKeyword,
43SyntaxKind.ProtectedKeyword,
44SyntaxKind.UnsafeKeyword,
45SyntaxKind.FileKeyword,
49: base(SyntaxKind.SealedKeyword)
Completion\KeywordRecommenders\StaticKeywordRecommender.cs (53)
14private static readonly ISet<SyntaxKind> s_validTypeModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
16SyntaxKind.InternalKeyword,
17SyntaxKind.NewKeyword,
18SyntaxKind.PublicKeyword,
19SyntaxKind.PrivateKeyword,
20SyntaxKind.ProtectedKeyword,
21SyntaxKind.UnsafeKeyword,
22SyntaxKind.FileKeyword,
25private static readonly ISet<SyntaxKind> s_validNonInterfaceMemberModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
27SyntaxKind.AsyncKeyword,
28SyntaxKind.ExternKeyword,
29SyntaxKind.InternalKeyword,
30SyntaxKind.NewKeyword,
31SyntaxKind.PublicKeyword,
32SyntaxKind.PrivateKeyword,
33SyntaxKind.ProtectedKeyword,
34SyntaxKind.ReadOnlyKeyword,
35SyntaxKind.UnsafeKeyword,
36SyntaxKind.VolatileKeyword,
39private static readonly ISet<SyntaxKind> s_validInterfaceMemberModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
41SyntaxKind.AbstractKeyword,
42SyntaxKind.AsyncKeyword,
43SyntaxKind.ExternKeyword,
44SyntaxKind.InternalKeyword,
45SyntaxKind.NewKeyword,
46SyntaxKind.PublicKeyword,
47SyntaxKind.PrivateKeyword,
48SyntaxKind.ProtectedKeyword,
49SyntaxKind.ReadOnlyKeyword,
50SyntaxKind.SealedKeyword,
51SyntaxKind.UnsafeKeyword,
52SyntaxKind.VolatileKeyword,
53SyntaxKind.VirtualKeyword,
56private static readonly ISet<SyntaxKind> s_validGlobalMemberModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
58SyntaxKind.ExternKeyword,
59SyntaxKind.InternalKeyword,
60SyntaxKind.NewKeyword,
61SyntaxKind.PublicKeyword,
62SyntaxKind.PrivateKeyword,
63SyntaxKind.ReadOnlyKeyword,
64SyntaxKind.UnsafeKeyword,
65SyntaxKind.VolatileKeyword,
68private static readonly ISet<SyntaxKind> s_validLocalFunctionModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
70SyntaxKind.ExternKeyword,
71SyntaxKind.AsyncKeyword,
72SyntaxKind.UnsafeKeyword
76: base(SyntaxKind.StaticKeyword)
87context.SyntaxTree.IsLambdaDeclarationContext(position, otherModifier: SyntaxKind.AsyncKeyword, cancellationToken) ||
Completion\KeywordRecommenders\UnsafeKeywordRecommender.cs (42)
14private static readonly ISet<SyntaxKind> s_validTypeModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
16SyntaxKind.AbstractKeyword,
17SyntaxKind.InternalKeyword,
18SyntaxKind.NewKeyword,
19SyntaxKind.PublicKeyword,
20SyntaxKind.PrivateKeyword,
21SyntaxKind.ProtectedKeyword,
22SyntaxKind.SealedKeyword,
23SyntaxKind.StaticKeyword,
24SyntaxKind.FileKeyword,
27private static readonly ISet<SyntaxKind> s_validMemberModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
29SyntaxKind.AbstractKeyword,
30SyntaxKind.ExternKeyword,
31SyntaxKind.InternalKeyword,
32SyntaxKind.NewKeyword,
33SyntaxKind.OverrideKeyword,
34SyntaxKind.PublicKeyword,
35SyntaxKind.PrivateKeyword,
36SyntaxKind.ProtectedKeyword,
37SyntaxKind.ReadOnlyKeyword,
38SyntaxKind.SealedKeyword,
39SyntaxKind.StaticKeyword,
40SyntaxKind.VirtualKeyword,
41SyntaxKind.VolatileKeyword,
44private static readonly ISet<SyntaxKind> s_validGlobalMemberModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
46SyntaxKind.ExternKeyword,
47SyntaxKind.InternalKeyword,
48SyntaxKind.NewKeyword,
49SyntaxKind.PublicKeyword,
50SyntaxKind.PrivateKeyword,
51SyntaxKind.ReadOnlyKeyword,
52SyntaxKind.StaticKeyword,
53SyntaxKind.VolatileKeyword,
56private static readonly ISet<SyntaxKind> s_validLocalFunctionModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
58SyntaxKind.ExternKeyword,
59SyntaxKind.StaticKeyword,
60SyntaxKind.AsyncKeyword
64: base(SyntaxKind.UnsafeKeyword)
Completion\KeywordRecommenders\VirtualKeywordRecommender.cs (22)
14private static readonly ISet<SyntaxKind> s_validNonInterfaceMemberModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
16SyntaxKind.ExternKeyword,
17SyntaxKind.InternalKeyword,
18SyntaxKind.NewKeyword,
19SyntaxKind.PublicKeyword,
20SyntaxKind.ProtectedKeyword,
21SyntaxKind.PrivateKeyword,
22SyntaxKind.UnsafeKeyword,
25private static readonly ISet<SyntaxKind> s_validInterfaceMemberModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
27SyntaxKind.ExternKeyword,
28SyntaxKind.InternalKeyword,
29SyntaxKind.NewKeyword,
30SyntaxKind.PublicKeyword,
31SyntaxKind.ProtectedKeyword,
32SyntaxKind.PrivateKeyword,
33SyntaxKind.StaticKeyword,
34SyntaxKind.UnsafeKeyword,
38: base(SyntaxKind.VirtualKeyword)
59return !modifiers.Contains(SyntaxKind.PrivateKeyword) || modifiers.Contains(SyntaxKind.ProtectedKeyword);
Completion\KeywordRecommenders\VoidKeywordRecommender.cs (21)
15private static readonly ISet<SyntaxKind> s_validClassInterfaceRecordModifiers = new HashSet<SyntaxKind>(SyntaxFacts.EqualityComparer)
17SyntaxKind.NewKeyword,
18SyntaxKind.PublicKeyword,
19SyntaxKind.ProtectedKeyword,
20SyntaxKind.InternalKeyword,
21SyntaxKind.PrivateKeyword,
22SyntaxKind.StaticKeyword,
23SyntaxKind.VirtualKeyword,
24SyntaxKind.SealedKeyword,
25SyntaxKind.OverrideKeyword,
26SyntaxKind.AbstractKeyword,
27SyntaxKind.ExternKeyword,
28SyntaxKind.UnsafeKeyword,
29SyntaxKind.AsyncKeyword
32private static readonly ISet<SyntaxKind> s_validStructModifiers = new HashSet<SyntaxKind>(s_validClassInterfaceRecordModifiers, SyntaxFacts.EqualityComparer)
34SyntaxKind.ReadOnlyKeyword,
38: base(SyntaxKind.VoidKeyword)
79if (token.Kind() == SyntaxKind.OpenParenToken &&
80token.Parent.IsKind(SyntaxKind.ParenthesizedExpression))
ConvertIfToSwitch\CSharpConvertIfToSwitchCodeRefactoringProvider.Rewriting.cs (13)
22private static readonly Dictionary<BinaryOperatorKind, SyntaxKind> s_operatorMap = new Dictionary<BinaryOperatorKind, SyntaxKind>
24{ BinaryOperatorKind.LessThan, SyntaxKind.LessThanToken },
25{ BinaryOperatorKind.GreaterThan, SyntaxKind.GreaterThanToken },
26{ BinaryOperatorKind.LessThanOrEqual, SyntaxKind.LessThanEqualsToken },
27{ BinaryOperatorKind.GreaterThanOrEqual, SyntaxKind.GreaterThanEqualsToken },
53pattern = BinaryPattern(SyntaxKind.OrPattern, pattern.Parenthesize(), nextPattern.Parenthesize());
72switchKeyword: Token(SyntaxKind.SwitchKeyword).WithTriviaFrom(ifStatement.IfKeyword),
76openBraceToken: block?.OpenBraceToken ?? Token(SyntaxKind.OpenBraceToken),
78closeBraceToken: block?.CloseBraceToken.WithoutLeadingTrivia() ?? Token(SyntaxKind.CloseBraceToken));
84.AggregateOrDefault((prev, current) => BinaryExpression(SyntaxKind.LogicalAndExpression, prev, current)));
93Token(SyntaxKind.ColonToken));
98AnalyzedPattern.And p => BinaryPattern(SyntaxKind.AndPattern, AsPatternSyntax(p.LeftPattern, feature).Parenthesize(), AsPatternSyntax(p.RightPattern, feature).Parenthesize()),
ConvertLinq\CSharpConvertLinqQueryToForEachProvider.cs (36)
75SyntaxKind.SingleLineCommentTrivia or
76SyntaxKind.MultiLineCommentTrivia or
77SyntaxKind.MultiLineDocumentationCommentTrivia) ||
100if (!documentUpdateInfo.Source.IsParentKind(SyntaxKind.Block) &&
123case SyntaxKind.WhereClause:
125case SyntaxKind.FromClause:
153case SyntaxKind.LetClause:
156case SyntaxKind.JoinClause:
206SyntaxKind.SimpleMemberAccessExpression,
207SyntaxFactory.PredefinedType(SyntaxFactory.Token(SyntaxKind.ObjectKeyword)),
215case SyntaxKind.SelectClause:
234case SyntaxKind.ReturnStatement:
237case SyntaxKind.ForEachStatement:
240case SyntaxKind.SimpleMemberAccessExpression:
325SyntaxFactory.PostfixUnaryExpression(SyntaxKind.PostIncrementExpression, variableIdentifier)), // Generating 'count++'
326SyntaxFactory.LiteralExpression(SyntaxKind.NumericLiteralExpression, SyntaxFactory.Literal(0)), // count = 0
358SyntaxKind.SimpleMemberAccessExpression,
466case SyntaxKind.EqualsValueClause:
469SyntaxKind.VariableDeclarator or
470SyntaxKind.VariableDeclaration or
471SyntaxKind.LocalDeclarationStatement &&
487case SyntaxKind.SimpleAssignmentExpression:
502case SyntaxKind.ReturnStatement:
580=> SyntaxFactory.YieldStatement(SyntaxKind.YieldReturnStatement, expression);
599SyntaxKind.OpenBraceToken,
602SyntaxFactory.Token(SyntaxKind.CloseBraceToken)),
773=> SyntaxFactory.YieldStatement(SyntaxKind.YieldReturnStatement, expression), queryExpressionProcessingInfo);
776var yieldBreakStatement = SyntaxFactory.YieldStatement(SyntaxKind.YieldBreakStatement);
849case SyntaxKind.WhereClause:
852case SyntaxKind.LetClause:
859case SyntaxKind.FromClause:
867case SyntaxKind.JoinClause:
940case SyntaxKind.AnonymousMethodExpression:
941case SyntaxKind.ParenthesizedLambdaExpression:
942case SyntaxKind.SimpleLambdaExpression:
944case SyntaxKind.LocalFunctionStatement:
ConvertSwitchStatementToExpressionCodeFixProvider.Rewriter.cs (21)
40SyntaxKind nodeToGenerate,
51var rewriter = new Rewriter(model, isAllThrowStatements: nodeToGenerate == SyntaxKind.ThrowStatement, cancellationToken);
67SyntaxKind nodeToGenerate,
72case SyntaxKind.ReturnStatement:
74Token(leadingTrivia, SyntaxKind.ReturnKeyword, trailing: default),
76Token(SyntaxKind.SemicolonToken));
77case SyntaxKind.ThrowStatement:
79Token(leadingTrivia, SyntaxKind.ThrowKeyword, trailing: default),
81Token(SyntaxKind.SemicolonToken));
92private ExpressionStatementSyntax GenerateAssignment(ExpressionSyntax switchExpression, SyntaxKind assignmentKind, SyntaxTriviaList leadingTrivia)
151totalPattern = BinaryPattern(SyntaxKind.OrPattern, totalPattern.Parenthesize(), nextPatternPart.Parenthesize());
162case SyntaxKind.CasePatternSwitchLabel:
167case SyntaxKind.CaseSwitchLabel:
171case SyntaxKind.DefaultSwitchLabel:
208Debug.Assert(!statements[0].IsKind(SyntaxKind.BreakStatement));
234if (nextStatement is (kind: SyntaxKind.ThrowStatement or SyntaxKind.ReturnStatement))
250Token(leading: default, SyntaxKind.SwitchKeyword, node.CloseParenToken.TrailingTrivia),
251Token(leading: default, SyntaxKind.OpenBraceToken, node.OpenBraceToken.TrailingTrivia),
254switchArms.Select(t => Token(SyntaxKind.CommaToken).WithTrailingTrivia(t.tokensForTrailingTrivia.GetTrivia().FilterComments(addElasticMarker: true)))),
255Token(SyntaxKind.CloseBraceToken));
ConvertSwitchStatementToExpressionDiagnosticAnalyzer.Analyzer.cs (33)
20private sealed class Analyzer : CSharpSyntaxVisitor<SyntaxKind>
31public static (SyntaxKind nodeToGenerate, VariableDeclaratorSyntax? declaratorToRemoveOpt) Analyze(
37var nodeToGenerate = analyzer.AnalyzeSwitchStatement(node, out shouldRemoveNextStatement);
39if (nodeToGenerate == SyntaxKind.SimpleAssignmentExpression &&
84if (!_assignmentTargetOpt.IsKind(SyntaxKind.IdentifierName))
104public override SyntaxKind VisitSwitchStatement(SwitchStatementSyntax node)
107private SyntaxKind AnalyzeSwitchStatement(SwitchStatementSyntax switchStatement, out bool shouldRemoveNextStatement)
126var nextStatement = AnalyzeNextStatement(switchStatement, out shouldRemoveNextStatement);
176private SyntaxKind AnalyzeNextStatement(SwitchStatementSyntax switchStatement, out bool shouldRemoveNextStatement)
183return SyntaxKind.ThrowStatement;
191private static SyntaxKind Intersect(SyntaxKind left, SyntaxKind right)
193if (left == SyntaxKind.ThrowStatement)
198if (right == SyntaxKind.ThrowStatement)
211private SyntaxKind AnalyzeNextStatement(StatementSyntax? nextStatement)
214return nextStatement is (kind: SyntaxKind.ThrowStatement or SyntaxKind.ReturnStatement)
219private SyntaxKind AnalyzeSwitchSection(SwitchSectionSyntax section)
224case 2 when section.Statements[1].IsKind(SyntaxKind.BreakStatement) || section.Statements[0].IsKind(SyntaxKind.SwitchStatement):
231private static SyntaxKind Aggregate<T>(SyntaxKind seed, SyntaxList<T> nodes, Func<SyntaxKind, T, SyntaxKind> func)
234var result = seed;
249public override SyntaxKind VisitAssignmentExpression(AssignmentExpressionSyntax node)
269public override SyntaxKind VisitExpressionStatement(ExpressionStatementSyntax node)
272public override SyntaxKind VisitReturnStatement(ReturnStatementSyntax node)
280: SyntaxKind.ReturnStatement;
283public override SyntaxKind VisitThrowStatement(ThrowStatementSyntax node)
287return node.Expression is null ? default : SyntaxKind.ThrowStatement;
290public override SyntaxKind DefaultVisit(SyntaxNode node)
CSharpAddRequiredExpressionParenthesesDiagnosticAnalyzer.cs (25)
19ExpressionSyntax, ExpressionSyntax, SyntaxKind>
26private static readonly ImmutableArray<SyntaxKind> s_kinds = ImmutableArray.Create(
27SyntaxKind.AddExpression,
28SyntaxKind.SubtractExpression,
29SyntaxKind.MultiplyExpression,
30SyntaxKind.DivideExpression,
31SyntaxKind.ModuloExpression,
32SyntaxKind.LeftShiftExpression,
33SyntaxKind.RightShiftExpression,
34SyntaxKind.LogicalOrExpression,
35SyntaxKind.LogicalAndExpression,
36SyntaxKind.BitwiseOrExpression,
37SyntaxKind.BitwiseAndExpression,
38SyntaxKind.ExclusiveOrExpression,
39SyntaxKind.EqualsExpression,
40SyntaxKind.NotEqualsExpression,
41SyntaxKind.LessThanExpression,
42SyntaxKind.LessThanOrEqualExpression,
43SyntaxKind.GreaterThanExpression,
44SyntaxKind.GreaterThanOrEqualExpression,
45SyntaxKind.IsExpression,
46SyntaxKind.AsExpression,
47SyntaxKind.CoalesceExpression,
48SyntaxKind.IsPatternExpression);
50protected override ImmutableArray<SyntaxKind> GetSyntaxNodeKinds()
CSharpUseCoalesceExpressionForNullableTernaryConditionalCheckDiagnosticAnalyzer.cs (1)
16SyntaxKind,
CSharpUseCoalesceExpressionForTernaryConditionalCheckDiagnosticAnalyzer.cs (1)
17SyntaxKind,
CSharpUseCollectionInitializerDiagnosticAnalyzer.cs (1)
17SyntaxKind,
CSharpUseCompoundAssignmentCodeFixProvider.cs (11)
18: AbstractUseCompoundAssignmentCodeFixProvider<SyntaxKind, AssignmentExpressionSyntax, ExpressionSyntax>
27protected override SyntaxToken Token(SyntaxKind kind)
31SyntaxKind assignmentOpKind, ExpressionSyntax left, SyntaxToken syntaxToken, ExpressionSyntax right)
38? Postfix(SyntaxKind.PostIncrementExpression, left)
39: Prefix(SyntaxKind.PreIncrementExpression, left);
43? Postfix(SyntaxKind.PostDecrementExpression, left)
44: Prefix(SyntaxKind.PreDecrementExpression, left);
46private static ExpressionSyntax Postfix(SyntaxKind kind, ExpressionSyntax operand)
49private static ExpressionSyntax Prefix(SyntaxKind kind, ExpressionSyntax operand)
52protected override SyntaxTriviaList PrepareRightExpressionLeadingTrivia(SyntaxTriviaList initialTrivia) => initialTrivia.SkipWhile(el => el.Kind() is SyntaxKind.WhitespaceTrivia or SyntaxKind.EndOfLineTrivia).ToSyntaxTriviaList();
CSharpUseObjectInitializerDiagnosticAnalyzer.cs (1)
17SyntaxKind,
EditAndContinue\CSharpEditAndContinueAnalyzer.cs (399)
90case SyntaxKind.MethodDeclaration:
91case SyntaxKind.ConversionOperatorDeclaration:
92case SyntaxKind.OperatorDeclaration:
93case SyntaxKind.SetAccessorDeclaration:
94case SyntaxKind.InitAccessorDeclaration:
95case SyntaxKind.AddAccessorDeclaration:
96case SyntaxKind.RemoveAccessorDeclaration:
97case SyntaxKind.GetAccessorDeclaration:
98case SyntaxKind.ConstructorDeclaration:
99case SyntaxKind.DestructorDeclaration:
103case SyntaxKind.PropertyDeclaration:
109case SyntaxKind.FieldDeclaration:
110case SyntaxKind.EventFieldDeclaration:
116case SyntaxKind.VariableDeclarator:
118RoslynDebug.Assert(current.Parent.IsKind(SyntaxKind.VariableDeclaration));
122case SyntaxKind.FieldDeclaration:
123case SyntaxKind.EventFieldDeclaration:
131case SyntaxKind.ArrowExpressionClause:
133if (current.Parent is (kind: SyntaxKind.PropertyDeclaration or SyntaxKind.IndexerDeclaration))
185Debug.Assert(memberBody.IsKind(SyntaxKind.Block) || memberBody is ExpressionSyntax);
207where node.IsKind(SyntaxKind.IdentifierName)
233if (node.IsKind(SyntaxKind.VariableDeclarator))
241if (fieldDeclaration.Modifiers.Any(SyntaxKind.ConstKeyword))
299if (bodyOrMatchRoot.Parent.IsKind(SyntaxKind.ConstructorDeclaration))
306if (bodyOrMatchRoot.IsKind(SyntaxKind.EqualsValueClause) &&
307bodyOrMatchRoot.Parent.IsKind(SyntaxKind.VariableDeclarator) &&
308bodyOrMatchRoot.Parent.Parent.IsKind(SyntaxKind.FieldDeclaration))
315if (bodyOrMatchRoot.Parent.IsKind(SyntaxKind.EqualsValueClause) &&
316bodyOrMatchRoot.Parent.Parent.IsKind(SyntaxKind.VariableDeclarator) &&
317bodyOrMatchRoot.Parent.Parent.Parent.IsKind(SyntaxKind.FieldDeclaration))
342if (declarationBody.Parent.IsKind(SyntaxKind.ConstructorDeclaration))
384case SyntaxKind.Block:
388case SyntaxKind.ForEachStatement:
389case SyntaxKind.ForEachVariableStatement:
394case SyntaxKind.DoStatement:
402case SyntaxKind.PropertyDeclaration:
409case SyntaxKind.VariableDeclaration:
426case SyntaxKind.SwitchExpression:
451case SyntaxKind.SwitchExpressionArm:
580if (oldBody is ExpressionSyntax || newBody is ExpressionSyntax || (oldBody.Parent.IsKind(SyntaxKind.LocalFunctionStatement) && newBody.Parent.IsKind(SyntaxKind.LocalFunctionStatement)))
604return parent.IsKind(SyntaxKind.ArrowExpressionClause) && parent.Parent.IsKind(SyntaxKind.LocalFunctionStatement) ? parent.Parent : parent;
612if (oldBody.Parent.IsKind(SyntaxKind.ConstructorDeclaration))
616RoslynDebug.Assert(oldBody.IsKind(SyntaxKind.Block));
617RoslynDebug.Assert(newBody.IsKind(SyntaxKind.Block));
618RoslynDebug.Assert(newBody.Parent.IsKind(SyntaxKind.ConstructorDeclaration));
668if (oldNode.IsKind(SyntaxKind.CompilationUnit) || newNode.IsKind(SyntaxKind.CompilationUnit))
704else if (property.AccessorList.Accessors.Any(a => a.IsKind(SyntaxKind.SetAccessorDeclaration)))
749case SyntaxKind.ThisConstructorInitializer:
750case SyntaxKind.BaseConstructorInitializer:
751case SyntaxKind.ConstructorDeclaration:
752var newConstructor = (ConstructorDeclarationSyntax)(newBody.Parent.IsKind(SyntaxKind.ArrowExpressionClause) ? newBody.Parent.Parent : newBody.Parent)!;
762if (oldStatement == oldBody && !newBody.IsKind(SyntaxKind.Block))
787=> node.IsKind(SyntaxKind.GlobalStatement);
830=> (ushort)SyntaxKind.LineDirectiveTrivia;
852case SyntaxKind.Block:
856case SyntaxKind.ForEachStatement:
860case SyntaxKind.ForEachVariableStatement:
864case SyntaxKind.DoStatement:
873case SyntaxKind.PropertyDeclaration:
890case SyntaxKind.SwitchExpression:
894case SyntaxKind.SwitchExpressionArm:
933case SyntaxKind.Block:
938case SyntaxKind.ForEachStatement:
939case SyntaxKind.ForEachVariableStatement:
981nodeModifiers.Value.Any(SyntaxKind.StaticKeyword) != fieldOrPropertyModifiers.Value.Any(SyntaxKind.StaticKeyword))
989case SyntaxKind.Block:
993case SyntaxKind.ForEachStatement:
994case SyntaxKind.ForEachVariableStatement:
1013case SyntaxKind.Block:
1028case SyntaxKind.ConstructorDeclaration:
1032case SyntaxKind.ForEachStatement:
1033case SyntaxKind.ForEachVariableStatement:
1037case SyntaxKind.IfStatement:
1041case SyntaxKind.WhileStatement:
1045case SyntaxKind.DoStatement:
1049case SyntaxKind.SwitchStatement:
1052case SyntaxKind.LockStatement:
1055case SyntaxKind.UsingStatement:
1129case SyntaxKind.ForEachStatement: return AreEquivalentIgnoringLambdaBodies(((ForEachStatementSyntax)oldNode).Type, ((ForEachStatementSyntax)newNode).Type);
1130case SyntaxKind.ForEachVariableStatement: return AreEquivalentIgnoringLambdaBodies(((ForEachVariableStatementSyntax)oldNode).Variable, ((ForEachVariableStatementSyntax)newNode).Variable);
1151=> node.IsKind(SyntaxKind.InterfaceDeclaration);
1154=> node.Kind() is SyntaxKind.RecordDeclaration or SyntaxKind.RecordStructDeclaration;
1165if (node.Kind() is SyntaxKind.Parameter or SyntaxKind.TypeParameter)
1168SyntaxKind.ParameterList or
1169SyntaxKind.TypeParameterList or
1170SyntaxKind.BracketedParameterList));
1178SyntaxKind.PropertyDeclaration or
1179SyntaxKind.IndexerDeclaration or
1180SyntaxKind.EventDeclaration))
1232=> constructorDeclaration is ConstructorDeclarationSyntax ctor && (ctor.Initializer == null || ctor.Initializer.IsKind(SyntaxKind.BaseConstructorInitializer));
1238|| ((BaseTypeDeclarationSyntax)syntaxRefs.Single().GetSyntax()).Modifiers.Any(SyntaxKind.PartialKeyword);
1339=> (oldModifiers.IndexOf(SyntaxKind.ReadOnlyKeyword) >= 0) != (newModifiers.IndexOf(SyntaxKind.ReadOnlyKeyword) >= 0);
1375if (node.IsKind(SyntaxKind.GetAccessorDeclaration))
1377Debug.Assert(node.Parent.IsKind(SyntaxKind.AccessorList));
1397if (node.IsKind(SyntaxKind.TypeParameterConstraintClause))
1403if (node.IsKind(SyntaxKind.GlobalStatement))
1419return oldNode.IsKind(SyntaxKind.LocalFunctionStatement)
1433if (node.Kind() is SyntaxKind.UsingDirective or SyntaxKind.NamespaceDeclaration or SyntaxKind.FileScopedNamespaceDeclaration)
1438if (node.IsKind(SyntaxKind.TypeParameterConstraintClause))
1446if (node.IsKind(SyntaxKind.GlobalStatement))
1466=> node.IsKind(SyntaxKind.LocalFunctionStatement) ||
1477=> node.IsKind(SyntaxKind.LocalFunctionStatement);
1501case SyntaxKind.FromClause:
1502case SyntaxKind.LetClause:
1503case SyntaxKind.WhereClause:
1504case SyntaxKind.OrderByClause:
1505case SyntaxKind.JoinClause:
1512case SyntaxKind.AscendingOrdering:
1513case SyntaxKind.DescendingOrdering:
1519case SyntaxKind.SelectClause:
1530case SyntaxKind.GroupClause:
1595internal static TextSpan? TryGetDiagnosticSpanImpl(SyntaxKind kind, SyntaxNode node, EditKind editKind)
1599case SyntaxKind.CompilationUnit:
1602case SyntaxKind.GlobalStatement:
1605case SyntaxKind.ExternAliasDirective:
1606case SyntaxKind.UsingDirective:
1609case SyntaxKind.NamespaceDeclaration:
1610case SyntaxKind.FileScopedNamespaceDeclaration:
1614case SyntaxKind.ClassDeclaration:
1615case SyntaxKind.StructDeclaration:
1616case SyntaxKind.InterfaceDeclaration:
1617case SyntaxKind.RecordDeclaration:
1618case SyntaxKind.RecordStructDeclaration:
1623case SyntaxKind.EnumDeclaration:
1627case SyntaxKind.DelegateDeclaration:
1631case SyntaxKind.FieldDeclaration:
1635case SyntaxKind.EventFieldDeclaration:
1639case SyntaxKind.VariableDeclaration:
1642case SyntaxKind.VariableDeclarator:
1645case SyntaxKind.MethodDeclaration:
1649case SyntaxKind.ConversionOperatorDeclaration:
1653case SyntaxKind.OperatorDeclaration:
1657case SyntaxKind.ConstructorDeclaration:
1661case SyntaxKind.DestructorDeclaration:
1665case SyntaxKind.PropertyDeclaration:
1669case SyntaxKind.IndexerDeclaration:
1673case SyntaxKind.EventDeclaration:
1677case SyntaxKind.EnumMemberDeclaration:
1680case SyntaxKind.GetAccessorDeclaration:
1681case SyntaxKind.SetAccessorDeclaration:
1682case SyntaxKind.InitAccessorDeclaration:
1683case SyntaxKind.AddAccessorDeclaration:
1684case SyntaxKind.RemoveAccessorDeclaration:
1685case SyntaxKind.UnknownAccessorDeclaration:
1689case SyntaxKind.TypeParameterConstraintClause:
1693case SyntaxKind.TypeParameter:
1697case SyntaxKind.AccessorList:
1698case SyntaxKind.TypeParameterList:
1699case SyntaxKind.ParameterList:
1700case SyntaxKind.BracketedParameterList:
1710case SyntaxKind.Parameter:
1716case SyntaxKind.AttributeList:
1720case SyntaxKind.Attribute:
1723case SyntaxKind.ArrowExpressionClause:
1729case SyntaxKind.Block:
1732case SyntaxKind.UsingStatement:
1736case SyntaxKind.FixedStatement:
1740case SyntaxKind.LockStatement:
1744case SyntaxKind.StackAllocArrayCreationExpression:
1747case SyntaxKind.ImplicitStackAllocArrayCreationExpression:
1750case SyntaxKind.TryStatement:
1753case SyntaxKind.CatchClause:
1756case SyntaxKind.CatchDeclaration:
1757case SyntaxKind.CatchFilterClause:
1760case SyntaxKind.FinallyClause:
1763case SyntaxKind.IfStatement:
1767case SyntaxKind.ElseClause:
1770case SyntaxKind.SwitchStatement:
1775case SyntaxKind.SwitchSection:
1778case SyntaxKind.WhileStatement:
1782case SyntaxKind.DoStatement:
1785case SyntaxKind.ForStatement:
1789case SyntaxKind.ForEachStatement:
1790case SyntaxKind.ForEachVariableStatement:
1796case SyntaxKind.LabeledStatement:
1799case SyntaxKind.CheckedStatement:
1800case SyntaxKind.UncheckedStatement:
1803case SyntaxKind.UnsafeStatement:
1806case SyntaxKind.LocalFunctionStatement:
1810case SyntaxKind.YieldBreakStatement:
1811case SyntaxKind.YieldReturnStatement:
1812case SyntaxKind.ReturnStatement:
1813case SyntaxKind.ThrowStatement:
1814case SyntaxKind.ExpressionStatement:
1815case SyntaxKind.EmptyStatement:
1816case SyntaxKind.GotoStatement:
1817case SyntaxKind.GotoCaseStatement:
1818case SyntaxKind.GotoDefaultStatement:
1819case SyntaxKind.BreakStatement:
1820case SyntaxKind.ContinueStatement:
1823case SyntaxKind.LocalDeclarationStatement:
1827case SyntaxKind.AwaitExpression:
1830case SyntaxKind.AnonymousObjectCreationExpression:
1833case SyntaxKind.ParenthesizedLambdaExpression:
1836case SyntaxKind.SimpleLambdaExpression:
1839case SyntaxKind.AnonymousMethodExpression:
1842case SyntaxKind.QueryExpression:
1845case SyntaxKind.QueryBody:
1849case SyntaxKind.QueryContinuation:
1852case SyntaxKind.FromClause:
1855case SyntaxKind.JoinClause:
1858case SyntaxKind.JoinIntoClause:
1861case SyntaxKind.LetClause:
1864case SyntaxKind.WhereClause:
1867case SyntaxKind.OrderByClause:
1870case SyntaxKind.AscendingOrdering:
1871case SyntaxKind.DescendingOrdering:
1874case SyntaxKind.SelectClause:
1877case SyntaxKind.GroupClause:
1880case SyntaxKind.IsPatternExpression:
1881case SyntaxKind.TupleType:
1882case SyntaxKind.TupleExpression:
1883case SyntaxKind.DeclarationExpression:
1884case SyntaxKind.RefType:
1885case SyntaxKind.RefExpression:
1886case SyntaxKind.DeclarationPattern:
1887case SyntaxKind.SimpleAssignmentExpression:
1888case SyntaxKind.WhenClause:
1889case SyntaxKind.SingleVariableDesignation:
1890case SyntaxKind.CasePatternSwitchLabel:
1893case SyntaxKind.SwitchExpression:
1896case SyntaxKind.SwitchExpressionArm:
1916case SyntaxKind.ParenthesizedLambdaExpression:
1919case SyntaxKind.SimpleLambdaExpression:
1923case SyntaxKind.AnonymousMethodExpression:
1967case SyntaxKind.CompilationUnit:
1968case SyntaxKind.GlobalStatement:
1971case SyntaxKind.ExternAliasDirective:
1974case SyntaxKind.UsingDirective:
1979case SyntaxKind.NamespaceDeclaration:
1980case SyntaxKind.FileScopedNamespaceDeclaration:
1983case SyntaxKind.ClassDeclaration:
1986case SyntaxKind.StructDeclaration:
1989case SyntaxKind.InterfaceDeclaration:
1992case SyntaxKind.RecordDeclaration:
1995case SyntaxKind.RecordStructDeclaration:
1998case SyntaxKind.EnumDeclaration:
2001case SyntaxKind.DelegateDeclaration:
2004case SyntaxKind.FieldDeclaration:
2006return declaration.Modifiers.Any(SyntaxKind.ConstKeyword) ? FeaturesResources.const_field : FeaturesResources.field;
2008case SyntaxKind.EventFieldDeclaration:
2011case SyntaxKind.VariableDeclaration:
2012case SyntaxKind.VariableDeclarator:
2015case SyntaxKind.MethodDeclaration:
2018case SyntaxKind.ConversionOperatorDeclaration:
2021case SyntaxKind.OperatorDeclaration:
2024case SyntaxKind.ConstructorDeclaration:
2026return ctor.Modifiers.Any(SyntaxKind.StaticKeyword) ? FeaturesResources.static_constructor : FeaturesResources.constructor;
2028case SyntaxKind.DestructorDeclaration:
2031case SyntaxKind.PropertyDeclaration:
2034case SyntaxKind.IndexerDeclaration:
2037case SyntaxKind.EventDeclaration:
2040case SyntaxKind.EnumMemberDeclaration:
2043case SyntaxKind.GetAccessorDeclaration:
2044if (node.Parent!.Parent!.IsKind(SyntaxKind.PropertyDeclaration))
2050RoslynDebug.Assert(node.Parent.Parent.IsKind(SyntaxKind.IndexerDeclaration));
2054case SyntaxKind.InitAccessorDeclaration:
2055case SyntaxKind.SetAccessorDeclaration:
2056if (node.Parent!.Parent!.IsKind(SyntaxKind.PropertyDeclaration))
2062RoslynDebug.Assert(node.Parent.Parent.IsKind(SyntaxKind.IndexerDeclaration));
2066case SyntaxKind.AddAccessorDeclaration:
2067case SyntaxKind.RemoveAccessorDeclaration:
2070case SyntaxKind.ArrowExpressionClause:
2073SyntaxKind.PropertyDeclaration => CSharpFeaturesResources.property_getter,
2074SyntaxKind.IndexerDeclaration => CSharpFeaturesResources.indexer_getter,
2078case SyntaxKind.TypeParameterConstraintClause:
2081case SyntaxKind.TypeParameterList:
2082case SyntaxKind.TypeParameter:
2085case SyntaxKind.Parameter:
2088case SyntaxKind.AttributeList:
2091case SyntaxKind.Attribute:
2094case SyntaxKind.AttributeTargetSpecifier:
2099case SyntaxKind.TryStatement:
2102case SyntaxKind.CatchClause:
2103case SyntaxKind.CatchDeclaration:
2106case SyntaxKind.CatchFilterClause:
2109case SyntaxKind.FinallyClause:
2112case SyntaxKind.FixedStatement:
2115case SyntaxKind.UsingStatement:
2118case SyntaxKind.LockStatement:
2121case SyntaxKind.ForEachStatement:
2122case SyntaxKind.ForEachVariableStatement:
2125case SyntaxKind.CheckedStatement:
2128case SyntaxKind.UncheckedStatement:
2131case SyntaxKind.YieldBreakStatement:
2134case SyntaxKind.YieldReturnStatement:
2137case SyntaxKind.AwaitExpression:
2140case SyntaxKind.ParenthesizedLambdaExpression:
2141case SyntaxKind.SimpleLambdaExpression:
2144case SyntaxKind.AnonymousMethodExpression:
2147case SyntaxKind.FromClause:
2150case SyntaxKind.JoinClause:
2151case SyntaxKind.JoinIntoClause:
2154case SyntaxKind.LetClause:
2157case SyntaxKind.WhereClause:
2160case SyntaxKind.OrderByClause:
2161case SyntaxKind.AscendingOrdering:
2162case SyntaxKind.DescendingOrdering:
2165case SyntaxKind.SelectClause:
2168case SyntaxKind.GroupClause:
2171case SyntaxKind.QueryBody:
2174case SyntaxKind.QueryContinuation:
2177case SyntaxKind.IsPatternExpression:
2180case SyntaxKind.SimpleAssignmentExpression:
2190case SyntaxKind.TupleType:
2191case SyntaxKind.TupleExpression:
2194case SyntaxKind.LocalFunctionStatement:
2197case SyntaxKind.DeclarationExpression:
2200case SyntaxKind.RefType:
2201case SyntaxKind.RefExpression:
2204case SyntaxKind.SwitchStatement:
2207case SyntaxKind.LocalDeclarationStatement:
2208if (((LocalDeclarationStatementSyntax)node).UsingKeyword.IsKind(SyntaxKind.UsingKeyword))
2224case SyntaxKind.ForEachStatement:
2225Debug.Assert(((CommonForEachStatementSyntax)node).AwaitKeyword.IsKind(SyntaxKind.AwaitKeyword));
2228case SyntaxKind.VariableDeclarator:
2229RoslynDebug.Assert(((LocalDeclarationStatementSyntax)node.Parent!.Parent!).AwaitKeyword.IsKind(SyntaxKind.AwaitKeyword));
2339if (_newNode.IsKind(SyntaxKind.LocalFunctionStatement))
2346case SyntaxKind.PropertyDeclaration:
2347case SyntaxKind.FieldDeclaration:
2348case SyntaxKind.EventFieldDeclaration:
2349case SyntaxKind.VariableDeclarator:
2354case SyntaxKind.EnumMemberDeclaration:
2360case SyntaxKind.TypeParameter:
2370case SyntaxKind.ExternAliasDirective:
2374case SyntaxKind.Attribute:
2375case SyntaxKind.AttributeList:
2381if (node.IsParentKind(SyntaxKind.CompilationUnit) || node.Parent.IsParentKind(SyntaxKind.CompilationUnit))
2394case SyntaxKind.ExternAliasDirective:
2400case SyntaxKind.AttributeList:
2401case SyntaxKind.Attribute:
2407if (oldNode.IsParentKind(SyntaxKind.CompilationUnit) || oldNode.Parent.IsParentKind(SyntaxKind.CompilationUnit))
2420case SyntaxKind.ExternAliasDirective:
2424case SyntaxKind.Attribute:
2430if (newNode.IsParentKind(SyntaxKind.CompilationUnit) || newNode.Parent.IsParentKind(SyntaxKind.CompilationUnit))
2445case SyntaxKind.StackAllocArrayCreationExpression:
2446case SyntaxKind.ImplicitStackAllocArrayCreationExpression:
2551var kind = current.Kind();
2555case SyntaxKind.TryStatement:
2563case SyntaxKind.CatchClause:
2564case SyntaxKind.FinallyClause:
2569RoslynDebug.Assert(current.Parent.Kind() == SyntaxKind.TryStatement);
2575case SyntaxKind.ClassDeclaration:
2576case SyntaxKind.StructDeclaration:
2577case SyntaxKind.RecordDeclaration:
2578case SyntaxKind.RecordStructDeclaration:
2616case SyntaxKind.TryStatement:
2622case SyntaxKind.CatchClause:
2623case SyntaxKind.FinallyClause:
2650case SyntaxKind.TryStatement:
2666case SyntaxKind.CatchClause:
2670case SyntaxKind.FinallyClause:
2706if (newNode.IsKind(SyntaxKind.AwaitExpression) && oldNode.IsKind(SyntaxKind.AwaitExpression))
2726deletedForeachStatement.AwaitKeyword.IsKind(SyntaxKind.AwaitKeyword))
2738if (deletedSuspensionPoint.IsKind(SyntaxKind.VariableDeclarator) &&
2740!((LocalDeclarationStatementSyntax)newLocalDeclaration).AwaitKeyword.IsKind(SyntaxKind.AwaitKeyword))
2760!oldForEachStatement.AwaitKeyword.IsKind(SyntaxKind.AwaitKeyword))
2772if (insertedSuspensionPoint.IsKind(SyntaxKind.VariableDeclarator) &&
2774!((LocalDeclarationStatementSyntax)oldLocalDeclaration).AwaitKeyword.IsKind(SyntaxKind.AwaitKeyword))
2803case SyntaxKind.ForStatement:
2804case SyntaxKind.ForEachStatement:
2805case SyntaxKind.IfStatement:
2806case SyntaxKind.WhileStatement:
2807case SyntaxKind.DoStatement:
2808case SyntaxKind.SwitchStatement:
2809case SyntaxKind.LockStatement:
2810case SyntaxKind.UsingStatement:
2811case SyntaxKind.ArrowExpressionClause:
2826Debug.Assert(awaitExpression.IsKind(SyntaxKind.AwaitExpression));
2836case SyntaxKind.ExpressionStatement:
2837case SyntaxKind.ReturnStatement:
2851case SyntaxKind.VariableDeclaration:
2856case SyntaxKind.LocalDeclarationStatement:
2869case SyntaxKind.ExpressionStatement:
2872case SyntaxKind.ReturnStatement:
2883if (node is AssignmentExpressionSyntax(SyntaxKind.SimpleAssignmentExpression) assignment)
2885return assignment.Left.IsKind(SyntaxKind.IdentifierName) && assignment.Right == awaitExpression;
2916if (!oldActiveStatement.IsKind(SyntaxKind.WhenClause))
2931Debug.Assert(newActiveStatement.IsKind(SyntaxKind.WhenClause));
3013case SyntaxKind.CheckedStatement:
3014case SyntaxKind.UncheckedStatement:
3039ReportUnmatchedStatements<LockStatementSyntax>(diagnostics, match, n => n.IsKind(SyntaxKind.LockStatement), oldActiveStatement, newActiveStatement,
3043ReportUnmatchedStatements<FixedStatementSyntax>(diagnostics, match, n => n.IsKind(SyntaxKind.FixedStatement), oldActiveStatement, newActiveStatement,
3060n => n.IsKind(SyntaxKind.ForEachStatement) || n.IsKind(SyntaxKind.ForEachVariableStatement),
InvertIf\CSharpInvertIfCodeRefactoringProvider.cs (21)
23SyntaxKind, StatementSyntax, IfStatementSyntax, StatementSyntax>
38=> ifNode?.Parent is (kind: SyntaxKind.Block or SyntaxKind.SwitchSection);
47=> node.Kind() is SyntaxKind.Block or SyntaxKind.SwitchSection;
50=> node.Kind() is SyntaxKind.Block or SyntaxKind.EmptyStatement;
94protected override SyntaxKind? GetJumpStatementKind(SyntaxNode node)
98=> SyntaxKind.BreakStatement,
100=> node.ContainsYield() ? SyntaxKind.YieldBreakStatement : SyntaxKind.ReturnStatement,
102=> SyntaxKind.ReturnStatement,
104=> SyntaxKind.ContinueStatement,
108protected override StatementSyntax GetJumpStatement(SyntaxKind kind)
111SyntaxKind.ContinueStatement => SyntaxFactory.ContinueStatement(),
112SyntaxKind.BreakStatement => SyntaxFactory.BreakStatement(),
113SyntaxKind.ReturnStatement => SyntaxFactory.ReturnStatement(),
114SyntaxKind.YieldBreakStatement => SyntaxFactory.YieldStatement(SyntaxKind.YieldBreakStatement),
220return trivia.IsKind(SyntaxKind.MultiLineCommentTrivia)
221|| trivia.IsKind(SyntaxKind.SingleLineCommentTrivia);
ReplacePropertyWithMethods\CSharpReplacePropertyWithMethodsService.cs (35)
129if (propertyDeclaration.Modifiers.Any(SyntaxKind.UnsafeKeyword)
130&& !methodDeclaration.Modifiers.Any(SyntaxKind.UnsafeKeyword))
132methodDeclaration = methodDeclaration.AddModifiers(SyntaxFactory.Token(SyntaxKind.UnsafeKeyword));
184if (propertyDeclaration.Modifiers.Any(SyntaxKind.UnsafeKeyword)
185&& !methodDeclaration.Modifiers.Any(SyntaxKind.UnsafeKeyword))
187methodDeclaration = methodDeclaration.AddModifiers(SyntaxFactory.Token(SyntaxKind.UnsafeKeyword));
237if (trivia.Kind() is SyntaxKind.MultiLineDocumentationCommentTrivia or
238SyntaxKind.SingleLineDocumentationCommentTrivia)
327var operatorKind = parent.Kind() switch
329SyntaxKind.AddAssignmentExpression => SyntaxKind.AddExpression,
330SyntaxKind.AndAssignmentExpression => SyntaxKind.BitwiseAndExpression,
331SyntaxKind.CoalesceAssignmentExpression => SyntaxKind.CoalesceExpression,
332SyntaxKind.DivideAssignmentExpression => SyntaxKind.DivideExpression,
333SyntaxKind.ExclusiveOrAssignmentExpression => SyntaxKind.ExclusiveOrExpression,
334SyntaxKind.LeftShiftAssignmentExpression => SyntaxKind.LeftShiftExpression,
335SyntaxKind.ModuloAssignmentExpression => SyntaxKind.ModuloExpression,
336SyntaxKind.MultiplyAssignmentExpression => SyntaxKind.MultiplyExpression,
337SyntaxKind.OrAssignmentExpression => SyntaxKind.BitwiseOrExpression,
338SyntaxKind.RightShiftAssignmentExpression => SyntaxKind.RightShiftExpression,
339SyntaxKind.SubtractAssignmentExpression => SyntaxKind.SubtractExpression,
340SyntaxKind.UnsignedRightShiftAssignmentExpression => SyntaxKind.UnsignedRightShiftExpression,
341_ => SyntaxKind.None,
344if (operatorKind is SyntaxKind.None)
SimplifyThisOrMe\CSharpSimplifyThisOrMeDiagnosticAnalyzer.cs (1)
20SyntaxKind,
Utilities.cs (30)
12public static readonly ImmutableArray<(SyntaxKind, SyntaxKind, SyntaxKind)> Kinds =
14(SyntaxKind.AddExpression, SyntaxKind.AddAssignmentExpression),
15(SyntaxKind.SubtractExpression, SyntaxKind.SubtractAssignmentExpression),
16(SyntaxKind.MultiplyExpression, SyntaxKind.MultiplyAssignmentExpression),
17(SyntaxKind.DivideExpression, SyntaxKind.DivideAssignmentExpression),
18(SyntaxKind.ModuloExpression, SyntaxKind.ModuloAssignmentExpression),
19(SyntaxKind.BitwiseAndExpression, SyntaxKind.AndAssignmentExpression),
20(SyntaxKind.ExclusiveOrExpression, SyntaxKind.ExclusiveOrAssignmentExpression),
21(SyntaxKind.BitwiseOrExpression, SyntaxKind.OrAssignmentExpression),
22(SyntaxKind.LeftShiftExpression, SyntaxKind.LeftShiftAssignmentExpression),
23(SyntaxKind.RightShiftExpression, SyntaxKind.RightShiftAssignmentExpression),
24(SyntaxKind.CoalesceExpression, SyntaxKind.CoalesceAssignmentExpression)).SelectAsArray(
27private static SyntaxKind FindOperatorToken(SyntaxKind assignmentExpressionKind)
29for (var current = SyntaxKind.None; current <= SyntaxKind.ThrowExpression; current++)