protected override bool IsValidContext( int position, CSharpSyntaxContext context, CancellationToken cancellationToken ) { if ( context.IsMemberAttributeContext( SyntaxKindSet.ClassInterfaceStructRecordTypeDeclarations, cancellationToken ) ) { return(true); } var token = context.TargetToken; if ( token.Kind() == SyntaxKind.OpenBracketToken && token.Parent.IsKind(SyntaxKind.AttributeList) ) { if ( token.GetAncestor <PropertyDeclarationSyntax>() != null || token.GetAncestor <EventDeclarationSyntax>() != null ) { return(true); } } return(false); }
private static bool IsAttributeContext(CSharpSyntaxContext context, CancellationToken cancellationToken) { return (context.IsMemberAttributeContext(SyntaxKindSet.ClassInterfaceStructTypeDeclarations, cancellationToken) || (context.SyntaxTree.IsScript() && context.IsTypeAttributeContext(cancellationToken)) || context.IsStatementAttributeContext()); }
protected override bool IsValidContext( int position, CSharpSyntaxContext context, CancellationToken cancellationToken ) { var syntaxTree = context.SyntaxTree; return((context.IsGlobalStatementContext && syntaxTree.IsScript()) || syntaxTree.IsGlobalMemberDeclarationContext( position, SyntaxKindSet.AllGlobalMemberModifiers, cancellationToken ) || context.IsMemberDeclarationContext( validModifiers: s_validClassModifiers, validTypeDeclarations: SyntaxKindSet.ClassInterfaceRecordTypeDeclarations, canBePartial: false, cancellationToken: cancellationToken ) || context.IsMemberDeclarationContext( validModifiers: s_validStructModifiers, validTypeDeclarations: SyntaxKindSet.StructOnlyTypeDeclarations, canBePartial: false, cancellationToken: cancellationToken ) || context.IsMemberAttributeContext( SyntaxKindSet.ClassInterfaceStructRecordTypeDeclarations, cancellationToken )); }
protected override bool IsValidContext( int position, CSharpSyntaxContext context, CancellationToken cancellationToken ) => context.IsMemberAttributeContext( SyntaxKindSet.ClassInterfaceStructRecordTypeDeclarations, cancellationToken );
protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken) { return(context.IsMemberAttributeContext(s_validTypeDeclarations, cancellationToken)); }