本文整理汇总了C#中Microsoft.CodeAnalysis.SyntaxTree.GetLineSpan方法的典型用法代码示例。如果您正苦于以下问题:C# SyntaxTree.GetLineSpan方法的具体用法?C# SyntaxTree.GetLineSpan怎么用?C# SyntaxTree.GetLineSpan使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.CodeAnalysis.SyntaxTree
的用法示例。
在下文中一共展示了SyntaxTree.GetLineSpan方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitPosition
private void InitPosition(SyntaxTree tree, TextSpan span)
{
var x = tree.GetLineSpan(span);
this._line = x.StartLinePosition.Line + 1;
this._column = x.StartLinePosition.Character + 1;
this._endLine = x.EndLinePosition.Line + 1;
this._endColumn = x.EndLinePosition.Character + 1;
}
示例2: ReportAllErrors
protected override IEnumerable<string> ReportAllErrors(SyntaxTree userSolution)
{
var text = userSolution.GetText();
var longLines = text.Lines.Where(line => line.End - line.Start > maxLineLen).ToList();
if (longLines.Count == 0) yield break;
var position = userSolution.GetLineSpan(longLines[0].Span);
yield return Report(
position,
"Слишком длинная строка. Не заставляйте людей использовать горизонтальный скролл");
}
示例3: 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;
}
示例4: CompleterError
public CompleterError(SyntaxTree tree, Message message, SyntaxToken token)
: this(tree, message, tree.GetLineSpan(token.Span))
{
}
示例5: GetStartLinePosition
private int GetStartLinePosition(SyntaxTree syntaxTree, TextSpan textSpan)
{
return syntaxTree.GetLineSpan(textSpan).StartLinePosition.Line;
}