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


C# SyntaxTriviaList.Reverse方法代码示例

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


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

示例1: GetIndentationSteps

        private static int GetIndentationSteps(IndentationSettings indentationSettings, SyntaxTree syntaxTree, SyntaxTriviaList leadingTrivia)
        {
            var triviaSpan = syntaxTree.GetLineSpan(leadingTrivia.FullSpan);

            // There is no indentation when the leading trivia doesn't begin at the start of the line.
            if ((triviaSpan.StartLinePosition == triviaSpan.EndLinePosition) && (triviaSpan.StartLinePosition.Character > 0))
            {
                return 0;
            }

            var builder = StringBuilderPool.Allocate();

            foreach (SyntaxTrivia trivia in leadingTrivia.Reverse())
            {
                if (!trivia.IsKind(SyntaxKind.WhitespaceTrivia))
                {
                    break;
                }

                builder.Insert(0, trivia.ToFullString());
            }

            var tabSize = indentationSettings.TabSize;
            var indentationCount = 0;
            for (var i = 0; i < builder.Length; i++)
            {
                indentationCount += builder[i] == '\t' ? tabSize - (indentationCount % tabSize) : 1;
            }

            StringBuilderPool.ReturnAndFree(builder);

            return (indentationCount + (indentationSettings.IndentationSize / 2)) / indentationSettings.IndentationSize;
        }
开发者ID:Romanx,项目名称:StyleCopAnalyzers,代码行数:33,代码来源:IndentationHelper.cs

示例2: GetLastToken

        private SyntaxToken GetLastToken(
            SyntaxTriviaList list,
            Func<SyntaxToken, bool> predicate,
            Func<SyntaxTrivia, bool> stepInto)
        {
            Debug.Assert(stepInto != null);

            foreach (var trivia in list.Reverse())
            {
                SyntaxToken token;
                if (TryGetLastTokenForStructuredTrivia(trivia, predicate, stepInto, out token))
                {
                    return token;
                }
            }

            return default(SyntaxToken);
        }
开发者ID:ehsansajjad465,项目名称:roslyn,代码行数:18,代码来源:AbstractSyntaxNavigator.cs

示例3: GetPreviousToken

        private SyntaxToken GetPreviousToken(
            SyntaxTrivia current,
            SyntaxTriviaList list,
            Func<SyntaxToken, bool> predicate,
            Func<SyntaxTrivia, bool> stepInto,
            ref bool returnPrevious)
        {
            foreach (var trivia in list.Reverse())
            {
                if (returnPrevious)
                {
                    SyntaxToken token;
                    if (TryGetLastTokenForStructuredTrivia(trivia, predicate, stepInto, out token))
                    {
                        return token;
                    }
                }
                else if (trivia == current)
                {
                    returnPrevious = true;
                }
            }

            return default(SyntaxToken);
        }
开发者ID:ehsansajjad465,项目名称:roslyn,代码行数:25,代码来源:AbstractSyntaxNavigator.cs

示例4: GetIndentationSteps

        private static int GetIndentationSteps(IndentationOptions indentationOptions, SyntaxTriviaList leadingTrivia)
        {
            SyntaxTriviaList.Reversed reversed = leadingTrivia.Reverse();
            int indentationCount = 0;

            foreach (SyntaxTrivia trivia in reversed)
            {
                if (!trivia.IsKind(SyntaxKind.WhitespaceTrivia))
                {
                    break;
                }

                foreach (char c in trivia.ToFullString())
                {
                    indentationCount += c == '\t' ? indentationOptions.TabSize : 1;
                }
            }

            return indentationCount / indentationOptions.IndentationSize;
        }
开发者ID:JaRau,项目名称:StyleCopAnalyzers,代码行数:20,代码来源:IndentationHelper.cs


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