本文整理汇总了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);
}
示例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));
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}