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


C# SyntaxTokenList.Where方法代码示例

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


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

示例1: PartiallySortModifiers

        /// <summary>
        /// Sorts the modifier list to fix all issues before <paramref name="modifierToFix"/>
        /// and keep the remaining modifiers untouched.
        /// The trivia will be maintained positionally.
        /// The relative order within the different kinds <seealso cref="ModifierType"/> will not be
        /// changed.
        /// </summary>
        /// <param name="modifiers">All modifiers from the declaration.</param>
        /// <param name="modifierToFix">The modifier with diagnostics.</param>
        /// <returns>A partially sorted modifier list (sorted up to <paramref name="modifierToFix"/>)</returns>
        private static SyntaxTokenList PartiallySortModifiers(SyntaxTokenList modifiers, SyntaxToken modifierToFix)
        {
            var accessModifiers = modifiers.Where(modifier => GetModifierType(modifier) == ModifierType.Access);
            var staticModifiers = modifiers.Where(modifier => GetModifierType(modifier) == ModifierType.Static);
            var otherModifiers = modifiers.Where(modifier => GetModifierType(modifier) == ModifierType.Other);

            IEnumerable<SyntaxToken> beforeIncluding;

            // the modifier to fix is of type other, so we need to sort the whole list of
            // modifier list
            if (GetModifierType(modifierToFix) == ModifierType.Other)
            {
                beforeIncluding = accessModifiers
                    .Concat(staticModifiers)
                    .Concat(otherModifiers);
            }
            else if (GetModifierType(modifierToFix) == ModifierType.Static)
            {
                beforeIncluding = accessModifiers
                    .Concat(staticModifiers.TakeWhile(modifier => modifier != modifierToFix))
                    .Concat(new[] { modifierToFix });
            }
            else
            {
                beforeIncluding = accessModifiers
                    .TakeWhile(modifier => modifier != modifierToFix)
                    .Concat(new[] { modifierToFix });
            }

            var after = modifiers.Where(modifier => !beforeIncluding.Contains(modifier));

            return AdjustTrivia(beforeIncluding.Concat(after), modifiers);
        }
开发者ID:EdwinEngelen,项目名称:StyleCopAnalyzers,代码行数:43,代码来源:SA1206CodeFixProvider.cs

示例2: FullySortModifiers

        /// <summary>
        /// Sorts the complete modifier list to fix all issues.
        /// The trivia will be maintained positionally.
        /// The relative order within the different kinds <seealso cref="ModifierType"/> will not be
        /// changed.
        /// </summary>
        /// <param name="modifiers">All modifiers from the declaration.</param>
        /// <returns>A fully sorted modifier list.</returns>
        private static SyntaxTokenList FullySortModifiers(SyntaxTokenList modifiers)
        {
            var accessModifiers = modifiers.Where(modifier => GetModifierType(modifier) == ModifierType.Access);
            var staticModifiers = modifiers.Where(modifier => GetModifierType(modifier) == ModifierType.Static);
            var otherModifiers = modifiers.Where(modifier => GetModifierType(modifier) == ModifierType.Other);

            return AdjustTrivia(
                accessModifiers
                    .Concat(staticModifiers)
                    .Concat(otherModifiers), modifiers);
        }
开发者ID:EdwinEngelen,项目名称:StyleCopAnalyzers,代码行数:19,代码来源:SA1206CodeFixProvider.cs

示例3: RemoveModifier

 private static SyntaxTokenList RemoveModifier(SyntaxTokenList list, params SyntaxKind[] modifiers)
 {
     return SyntaxFactory.TokenList(list.Where(t => Array.IndexOf(modifiers, t.Kind()) < 0));
 }
开发者ID:Eucaly,项目名称:pinvoke,代码行数:4,代码来源:OfferIntPtrOverloadGenerator.cs


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