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) { if (context.IsTypeAttributeContext(cancellationToken)) { var token = context.LeftToken; var type = token.GetAncestor <MemberDeclarationSyntax>(); return(type == null || type.IsParentKind(SyntaxKind.CompilationUnit)); } return(false); }
protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken) { return(context.IsTypeAttributeContext(cancellationToken)); }