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