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


C# SyntaxTriviaList.Skip方法代码示例

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


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

示例1: VisitList

        public override SyntaxTriviaList VisitList(SyntaxTriviaList list)
        {
            list = base.VisitList(list);

            var lineBreaksAtBeginning = list.TakeWhile(t => t.IsKind(SyntaxKind.EndOfLineTrivia)).Count();
            if (lineBreaksAtBeginning > 1)
            {
                list = SyntaxFactory.TriviaList(list.Skip(lineBreaksAtBeginning - 1));
            }

            return list;
        }
开发者ID:transformersprimeabcxyz,项目名称:CodeCleanupTools,代码行数:12,代码来源:RemoveConsecutiveEmptyLines.cs

示例2: ProcessTriviaList

        private static SyntaxNode ProcessTriviaList(SyntaxNode syntaxRoot, SyntaxTriviaList triviaList, SyntaxTrivia singleLineComment)
        {
            var index = triviaList.IndexOf(singleLineComment);
            if (index == -1)
            {
                return null;
            }

            do
            {
                index++;
            }
            while (!triviaList[index].IsKind(SyntaxKind.EndOfLineTrivia));

            var startOfBlankLine = index;

            do
            {
                index++;
            }
            while (!triviaList[index].IsKind(SyntaxKind.EndOfLineTrivia));

            return syntaxRoot.ReplaceTrivia(triviaList.Skip(startOfBlankLine).Take(index - startOfBlankLine), (t1, t2) => default(SyntaxTrivia));
        }
开发者ID:nvincent,项目名称:StyleCopAnalyzers,代码行数:24,代码来源:SA1512CodeFixProvider.cs

示例3: FixTriviaList

        private static SyntaxTriviaList FixTriviaList(SyntaxTriviaList triviaList, IEnumerable<SyntaxTrivia> commentTrivias)
        {
            foreach (var singleLineComment in commentTrivias)
            {
                int commentLocation = triviaList.IndexOf(singleLineComment);
                if (commentLocation == -1)
                {
                    continue;
                }

                int index = commentLocation + 1;

                index++;
                while (index < triviaList.Count && index > 0)
                {
                    switch (triviaList[index].Kind())
                    {
                    case SyntaxKind.EndOfLineTrivia:
                    case SyntaxKind.WhitespaceTrivia:
                        index++;
                        break;

                    default:

                        if (triviaList[index - 1].IsKind(SyntaxKind.WhitespaceTrivia))
                        {
                            index--;
                        }

                        triviaList = SyntaxTriviaList.Empty.AddRange(triviaList.Take(commentLocation + 2).Concat(triviaList.Skip(index)));

                        // We found the trivia so we don't have to loop any longer
                        index = -1;
                        break;
                    }
                }

                if (index == triviaList.Count)
                {
                    if (triviaList[index - 1].IsKind(SyntaxKind.WhitespaceTrivia))
                    {
                        index--;
                    }

                    triviaList = SyntaxTriviaList.Empty.AddRange(triviaList.Take(commentLocation + 2).Concat(triviaList.Skip(index)));
                }
            }

            return triviaList;
        }
开发者ID:Noryoko,项目名称:StyleCopAnalyzers,代码行数:50,代码来源:SA1512CodeFixProvider.cs

示例4: StripFileHeader

 private static SyntaxTriviaList StripFileHeader(SyntaxTriviaList newLeadingTrivia)
 {
     var fileHeader = GetFileHeader(newLeadingTrivia);
     return SyntaxTriviaList.Empty.AddRange(newLeadingTrivia.Skip(fileHeader.Count));
 }
开发者ID:Noryoko,项目名称:StyleCopAnalyzers,代码行数:5,代码来源:ElementOrderCodeFixProvider.cs

示例5: RemoveExistingHeader

            /// <summary>
            /// Remove any copyright header that already exists.
            /// </summary>
            private SyntaxTriviaList RemoveExistingHeader(SyntaxTriviaList oldList)
            {
                var foundHeader = false;
                var i = 0;
                MovePastBlankLines(oldList, ref i);

                while (i < oldList.Count && IsLineComment(oldList[i]))
                {
                    if (oldList[i].ToFullString().IndexOf("copyright", StringComparison.OrdinalIgnoreCase) >= 0)
                    {
                        foundHeader = true;
                    }
                    i++;
                }

                if (!foundHeader)
                {
                    return oldList;
                }

                MovePastBlankLines(oldList, ref i);
                return CreateTriviaList(oldList.Skip(i));
            }
开发者ID:chuck-mitchell,项目名称:codeformatter,代码行数:26,代码来源:CopyrightHeaderRule.cs

示例6: StripFileHeader

 private static List<SyntaxTrivia> StripFileHeader(SyntaxTriviaList leadingTrivia)
 {
     var fileHeader = GetFileHeader(leadingTrivia);
     return leadingTrivia.Skip(fileHeader.Count).ToList();
 }
开发者ID:jmecosta,项目名称:StyleCopAnalyzers,代码行数:5,代码来源:UsingCodeFixProvider.cs


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