コード例 #1
0
 private bool IsTypeDeclarationContext(CSharpSyntaxContext context, CancellationToken cancellationToken)
 {
     return context.IsTypeDeclarationContext(
         validModifiers: SyntaxKindSet.AllTypeModifiers,
         validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations,
         canBePartial: false,
         cancellationToken: cancellationToken);
 }
コード例 #2
0
        private static bool IsValidContextForType(CSharpSyntaxContext context, CancellationToken cancellationToken)
        {
            if (context.IsTypeDeclarationContext(validModifiers: SyntaxKindSet.AllTypeModifiers, validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations, canBePartial: false, cancellationToken: cancellationToken))
            {
                return CheckPreviousAccessibilityModifiers(context);
            }

            return false;
        }
コード例 #3
0
 protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
 {
     return
         context.IsGlobalStatementContext ||
         context.IsTypeDeclarationContext(
             validModifiers: s_validModifiers,
             validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations,
             canBePartial: true,
             cancellationToken: cancellationToken);
 }
コード例 #4
0
 protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
 {
     var syntaxTree = context.SyntaxTree;
     return
         context.IsGlobalStatementContext ||
         context.IsTypeDeclarationContext(
             validModifiers: s_validModifiers,
             validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations,
             canBePartial: true,
             cancellationToken: cancellationToken) ||
         syntaxTree.IsTypeParameterConstraintStartContext(position, context.LeftToken, cancellationToken);
 }
コード例 #5
0
 protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
 {
     return
         context.IsGlobalStatementContext ||
         (context.IsNonAttributeExpressionContext && !context.IsConstantExpressionContext) ||
         IsAfterAsyncKeywordInExpressionContext(context, cancellationToken) ||
         context.IsTypeDeclarationContext(
             validModifiers: s_validModifiers,
             validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations,
             canBePartial: false,
             cancellationToken: cancellationToken);
 }
コード例 #6
0
        private bool IsTypeDeclarationContext(CSharpSyntaxContext context, CancellationToken cancellationToken)
        {
            if (context.IsTypeDeclarationContext(validModifiers: ValidTypeModifiers, validTypeDeclarations: SyntaxKindSet.ClassInterfaceStructTypeDeclarations, canBePartial: false, cancellationToken: cancellationToken))
            {
                // we must be on a nested type.
                var token = context.LeftToken;
                return token.GetAncestors<TypeDeclarationSyntax>()
                    .Any(t => token.SpanStart > t.OpenBraceToken.Span.End &&
                              token.Span.End < t.CloseBraceToken.SpanStart);
            }

            return false;
        }
コード例 #7
0
 protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
 {
     var syntaxTree = context.SyntaxTree;
     return
         context.IsStatementContext ||
         context.IsGlobalStatementContext ||
         context.IsTypeDeclarationContext(validModifiers: s_validTypeModifiers, validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations, canBePartial: false, cancellationToken: cancellationToken) ||
         syntaxTree.IsGlobalMemberDeclarationContext(position, s_validGlobalMemberModifiers, cancellationToken) ||
         context.IsMemberDeclarationContext(
             validModifiers: s_validMemberModifiers,
             validTypeDeclarations: SyntaxKindSet.ClassInterfaceStructTypeDeclarations,
             canBePartial: false,
             cancellationToken: cancellationToken);
 }
コード例 #8
0
        private static bool IsValidContextForType(CSharpSyntaxContext context, CancellationToken cancellationToken)
        {
            if (context.IsTypeDeclarationContext(validModifiers: SyntaxKindSet.AllTypeModifiers, validTypeDeclarations: SyntaxKindSet.ClassOnlyTypeDeclarations, canBePartial: false, cancellationToken: cancellationToken))
            {
                // protected things can't be in namespaces.
                var typeDecl = context.ContainingTypeDeclaration;
                if (typeDecl == null)
                {
                    return false;
                }

                return CheckPreviousAccessibilityModifiers(context);
            }

            return false;
        }