当前位置: 首页>>代码示例>>C#>>正文


C# CSharpSyntaxContext.IsMemberDeclarationContext方法代码示例

本文整理汇总了C#中Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery.CSharpSyntaxContext.IsMemberDeclarationContext方法的典型用法代码示例。如果您正苦于以下问题:C# CSharpSyntaxContext.IsMemberDeclarationContext方法的具体用法?C# CSharpSyntaxContext.IsMemberDeclarationContext怎么用?C# CSharpSyntaxContext.IsMemberDeclarationContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery.CSharpSyntaxContext的用法示例。


在下文中一共展示了CSharpSyntaxContext.IsMemberDeclarationContext方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: IsValidContext

 protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
 {
     var syntaxTree = context.SyntaxTree;
     return
         context.IsNonAttributeExpressionContext ||
         context.IsDefiniteCastTypeContext ||
         context.IsStatementContext ||
         context.IsGlobalStatementContext ||
         context.IsObjectCreationTypeContext ||
         context.IsGenericTypeArgumentContext ||
         context.IsEnumBaseListContext ||
         context.IsIsOrAsTypeContext ||
         context.IsLocalVariableDeclarationContext ||
         context.IsFixedVariableDeclarationContext ||
         context.IsParameterTypeContext ||
         context.IsPossibleLambdaOrAnonymousMethodParameterTypeContext ||
         context.IsImplicitOrExplicitOperatorTypeContext ||
         context.IsPrimaryFunctionExpressionContext ||
         context.IsCrefContext ||
         syntaxTree.IsAfterKeyword(position, SyntaxKind.ConstKeyword, cancellationToken) ||
         syntaxTree.IsAfterKeyword(position, SyntaxKind.StackAllocKeyword, cancellationToken) ||
         context.IsDelegateReturnTypeContext ||
         syntaxTree.IsGlobalMemberDeclarationContext(position, SyntaxKindSet.AllGlobalMemberModifiers, cancellationToken) ||
         context.IsMemberDeclarationContext(
             validModifiers: SyntaxKindSet.AllMemberModifiers,
             validTypeDeclarations: SyntaxKindSet.ClassInterfaceStructTypeDeclarations,
             canBePartial: false,
             cancellationToken: cancellationToken);
 }
开发者ID:robbert229,项目名称:omnisharp-roslyn,代码行数:29,代码来源:SByteKeywordRecommender.cs

示例2: IsMemberDeclarationContext

 private static bool IsMemberDeclarationContext(CSharpSyntaxContext context, CancellationToken cancellationToken)
 {
     return
         context.TargetToken.IsUnsafeContext() &&
        (context.SyntaxTree.IsGlobalMemberDeclarationContext(context.Position, SyntaxKindSet.AllGlobalMemberModifiers, cancellationToken) ||
        context.IsMemberDeclarationContext(validModifiers: s_validModifiers, validTypeDeclarations: SyntaxKindSet.StructOnlyTypeDeclarations, canBePartial: false, cancellationToken: cancellationToken));
 }
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:7,代码来源:FixedKeywordRecommender.cs

示例3: IsValidContext

 protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
 {
     var syntaxTree = context.SyntaxTree;
     return
         context.IsNonAttributeExpressionContext ||
         context.IsDefiniteCastTypeContext ||
         context.IsStatementContext ||
         context.IsGlobalStatementContext ||
         context.IsObjectCreationTypeContext ||
         (context.IsGenericTypeArgumentContext && !context.TargetToken.Parent.HasAncestor<XmlCrefAttributeSyntax>()) ||
         context.IsIsOrAsTypeContext ||
         context.IsLocalVariableDeclarationContext ||
         context.IsParameterTypeContext ||
         context.IsPossibleLambdaOrAnonymousMethodParameterTypeContext ||
         context.IsImplicitOrExplicitOperatorTypeContext ||
         context.IsTypeOfExpressionContext ||
         context.IsCrefContext ||
         syntaxTree.IsDefaultExpressionContext(position, context.LeftToken, cancellationToken) ||
         syntaxTree.IsAfterKeyword(position, SyntaxKind.ConstKeyword, cancellationToken) ||
         context.IsDelegateReturnTypeContext ||
         syntaxTree.IsGlobalMemberDeclarationContext(position, SyntaxKindSet.AllGlobalMemberModifiers, cancellationToken) ||
         context.IsMemberDeclarationContext(
             validModifiers: SyntaxKindSet.AllMemberModifiers,
             validTypeDeclarations: SyntaxKindSet.ClassInterfaceStructTypeDeclarations,
             canBePartial: false,
             cancellationToken: cancellationToken);
 }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:27,代码来源:ObjectKeywordRecommender.cs

示例4: IsValidContext

 protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
 {
     return context.IsMemberDeclarationContext(
         validModifiers: s_validMemberModifiers,
         validTypeDeclarations: SyntaxKindSet.ClassOnlyTypeDeclarations,
         canBePartial: false,
         cancellationToken: cancellationToken);
 }
开发者ID:pabloescribanoloza,项目名称:monodevelop,代码行数:8,代码来源:VirtualKeywordRecommender.cs

示例5: IsValidContextForMember

        private static bool IsValidContextForMember(CSharpSyntaxContext context, CancellationToken cancellationToken)
        {
            if (context.IsMemberDeclarationContext(validModifiers: SyntaxKindSet.AllMemberModifiers, validTypeDeclarations: SyntaxKindSet.ClassOnlyTypeDeclarations, canBePartial: false, cancellationToken: cancellationToken))
            {
                return CheckPreviousAccessibilityModifiers(context);
            }

            return false;
        }
开发者ID:robbert229,项目名称:omnisharp-roslyn,代码行数:9,代码来源:ProtectedKeywordRecommender.cs

示例6: InMemberDeclarationContext

        private static bool InMemberDeclarationContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
        {
			return context.SyntaxTree.IsGlobalMemberDeclarationContext(position, SyntaxKindSet.AllGlobalMemberModifiers, cancellationToken)
                || context.IsMemberDeclarationContext(
                    validModifiers: SyntaxKindSet.AllMemberModifiers,
                    validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations,
                    canBePartial: true,
                    cancellationToken: cancellationToken);
        }
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:9,代码来源:AsyncKeywordRecommender.cs

示例7: IsValidContext

 protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
 {
     var syntaxTree = context.SyntaxTree;
     return
         context.IsGlobalStatementContext ||
         syntaxTree.IsGlobalMemberDeclarationContext(position, SyntaxKindSet.AllGlobalMemberModifiers, cancellationToken) ||
         context.IsMemberDeclarationContext(validModifiers: s_validModifiers, validTypeDeclarations: SyntaxKindSet.ClassInterfaceStructTypeDeclarations, canBePartial: false, cancellationToken: cancellationToken) ||
         context.IsMemberAttributeContext(SyntaxKindSet.ClassInterfaceStructTypeDeclarations, cancellationToken);
 }
开发者ID:Rickinio,项目名称:roslyn,代码行数:9,代码来源:EventKeywordRecommender.cs

示例8: IsMemberDeclarationContext

 private bool IsMemberDeclarationContext(CSharpSyntaxContext context, CancellationToken cancellationToken)
 {
     return
         context.SyntaxTree.IsGlobalMemberDeclarationContext(context.Position, s_validGlobalModifiers, cancellationToken) ||
         context.IsMemberDeclarationContext(
             validModifiers: s_validModifiers,
             validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations,
             canBePartial: false,
             cancellationToken: cancellationToken);
 }
开发者ID:pabloescribanoloza,项目名称:monodevelop,代码行数:10,代码来源:ConstKeywordRecommender.cs

示例9: IsMemberReturnTypeContext

 private bool IsMemberReturnTypeContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
 {
     var syntaxTree = context.SyntaxTree;
     return
         syntaxTree.IsGlobalMemberDeclarationContext(position, SyntaxKindSet.AllGlobalMemberModifiers, cancellationToken) ||
         context.IsMemberDeclarationContext(
             validModifiers: s_validModifiers,
             validTypeDeclarations: SyntaxKindSet.ClassInterfaceStructTypeDeclarations,
             canBePartial: true,
             cancellationToken: cancellationToken);
 }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:11,代码来源:VoidKeywordRecommender.cs

示例10: IsValidNewByRefContext

 private bool IsValidNewByRefContext(SyntaxTree syntaxTree, int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
 {
     return
         IsValidRefDeclarationOrAssignmentContext(syntaxTree, position, context, cancellationToken) ||
         context.IsDelegateReturnTypeContext ||
         syntaxTree.IsGlobalMemberDeclarationContext(position, RefGlobalMemberModifiers, cancellationToken) ||
         context.IsMemberDeclarationContext(
             validModifiers: RefMemberModifiers,
             validTypeDeclarations: SyntaxKindSet.ClassInterfaceStructTypeDeclarations,
             canBePartial: true,
             cancellationToken: cancellationToken);
 }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:12,代码来源:RefKeywordRecommender.cs

示例11: IsValidContext

 protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
 {
     var syntaxTree = context.SyntaxTree;
     return
         IsExternAliasContext(context) ||
         context.IsGlobalStatementContext ||
         syntaxTree.IsGlobalMemberDeclarationContext(position, s_validGlobalModifiers, cancellationToken) ||
         context.IsMemberDeclarationContext(
             validModifiers: s_validModifiers,
             validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations,
             canBePartial: false,
             cancellationToken: cancellationToken);
 }
开发者ID:robbert229,项目名称:omnisharp-roslyn,代码行数:13,代码来源:ExternKeywordRecommender.cs

示例12: IsValidContext

        protected override bool IsValidContext(int position, CSharpSyntaxContext context, CancellationToken cancellationToken)
        {
            if (context.IsMemberDeclarationContext(validModifiers: s_validMemberModifiers, validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations, canBePartial: false, cancellationToken: cancellationToken))
            {
                // operators must be both public and static
				var modifiers = context.PrecedingModifiers;

                return
                    modifiers.Contains(SyntaxKind.PublicKeyword) &&
                    modifiers.Contains(SyntaxKind.StaticKeyword);
            }

            return false;
        }
开发者ID:pabloescribanoloza,项目名称:monodevelop,代码行数:14,代码来源:ExplicitKeywordRecommender.cs

示例13: IsMemberDeclarationContext

        private bool IsMemberDeclarationContext(CSharpSyntaxContext context, CancellationToken cancellationToken)
        {
            if (context.IsMemberDeclarationContext(validModifiers: s_validMemberModifiers, validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations, canBePartial: false, cancellationToken: cancellationToken))
            {
                var token = context.LeftToken;
                var decl = token.GetAncestor<TypeDeclarationSyntax>();

                // partial methods must be in partial types
                if (!decl.Modifiers.Any(t => t.IsKindOrHasMatchingText(SyntaxKind.PartialKeyword)))
                {
                    return false;
                }

                return true;
            }

            return false;
        }
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:18,代码来源:PartialKeywordRecommender.cs

示例14: IsValidContextForMember

        private static bool IsValidContextForMember(CSharpSyntaxContext context, CancellationToken cancellationToken)
        {
            if (context.SyntaxTree.IsGlobalMemberDeclarationContext(context.Position, SyntaxKindSet.AllGlobalMemberModifiers, cancellationToken) ||
                context.IsMemberDeclarationContext(validModifiers: SyntaxKindSet.AllMemberModifiers, validTypeDeclarations: SyntaxKindSet.ClassStructTypeDeclarations, canBePartial: false, cancellationToken: cancellationToken))
            {
                var modifiers = context.PrecedingModifiers;

                // can't have private + abstract/virtual/override/sealed
                if (modifiers.Contains(SyntaxKind.AbstractKeyword) ||
                    modifiers.Contains(SyntaxKind.VirtualKeyword) ||
                    modifiers.Contains(SyntaxKind.OverrideKeyword) ||
                    modifiers.Contains(SyntaxKind.SealedKeyword))
                {
                    return false;
                }

                return CheckPreviousAccessibilityModifiers(context);
            }

            return false;
        }
开发者ID:robbert229,项目名称:omnisharp-roslyn,代码行数:21,代码来源:PrivateKeywordRecommender.cs


注:本文中的Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery.CSharpSyntaxContext.IsMemberDeclarationContext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。