private bool IsTypeDeclarationContext(CSharpSyntaxContext context, CancellationToken cancellationToken) { return context.IsTypeDeclarationContext( validModifiers: SyntaxKindSet.AllTypeModifiers, validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations, canBePartial: false, cancellationToken: cancellationToken); }
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; }
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); }
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); }
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); }
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; }
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); }
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; }