示例#1
0
 private static bool IsAttributeContext(CSharpSyntaxContext context, CancellationToken cancellationToken)
 {
     return
         (context.IsMemberAttributeContext(SyntaxKindSet.ClassInterfaceStructTypeDeclarations, cancellationToken) ||
          (context.SyntaxTree.IsScript() && context.IsTypeAttributeContext(cancellationToken)) ||
          context.IsStatementAttributeContext());
 }
示例#2
0
        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));
 }