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


C# SyntaxTree.GetLineSpan方法代码示例

本文整理汇总了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;
        }
开发者ID:rexzh,项目名称:SharpJs,代码行数:9,代码来源:IssueLocation.cs

示例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, 
				"Слишком длинная строка. Не заставляйте людей использовать горизонтальный скролл");
		}
开发者ID:kontur-edu,项目名称:uLearn,代码行数:10,代码来源:LineLengthStyleValidator.cs

示例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;
        }
开发者ID:Romanx,项目名称:StyleCopAnalyzers,代码行数:33,代码来源:IndentationHelper.cs

示例4: CompleterError

 public CompleterError(SyntaxTree tree, Message message, SyntaxToken token)
     : this(tree, message, tree.GetLineSpan(token.Span))
 {
 }
开发者ID:VitalyTVA,项目名称:MetaSharp,代码行数:4,代码来源:Completer.cs

示例5: GetStartLinePosition

 private int GetStartLinePosition(SyntaxTree syntaxTree, TextSpan textSpan)
 {
     return syntaxTree.GetLineSpan(textSpan).StartLinePosition.Line;
 }
开发者ID:sebastian-heinz,项目名称:CStats,代码行数:4,代码来源:DocumentExposer.cs


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