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


C# Location.GetLineSpan方法代码示例

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


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

示例1: CallHierarchyDetail

 public CallHierarchyDetail(Location location, Workspace workspace)
 {
     _span = location.SourceSpan;
     _documentId = workspace.CurrentSolution.GetDocumentId(location.SourceTree);
     _workspace = workspace;
     _endColumn = location.GetLineSpan().Span.End.Character;
     _endLine = location.GetLineSpan().EndLinePosition.Line;
     _sourceFile = location.SourceTree.FilePath;
     _startColumn = location.GetLineSpan().StartLinePosition.Character;
     _startLine = location.GetLineSpan().StartLinePosition.Line;
     _text = ComputeText(location);
 }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:12,代码来源:CallHierarchyDetail.cs

示例2: ComputeText

 private string ComputeText(Location location)
 {
     var lineSpan = location.GetLineSpan();
     var start = location.SourceTree.GetText().Lines[lineSpan.StartLinePosition.Line].Start;
     var end = location.SourceTree.GetText().Lines[lineSpan.EndLinePosition.Line].End;
     return location.SourceTree.GetText().GetSubText(TextSpan.FromBounds(start, end)).ToString();
 }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:7,代码来源:CallHierarchyDetail.cs

示例3: ReferenceLocationDescriptor

 public ReferenceLocationDescriptor(string longDescription, string language, Glyph? glyph, Location location, DocumentId documentId, string referenceLineText, int referenceStart, int referenceLength, string beforeReferenceText1, string beforeReferenceText2, string afterReferenceText1, string afterReferenceText2)
 {
     LongDescription = longDescription;
     Language = language;
     Glyph = glyph;
     var sourceText = location.GetLineSpan().StartLinePosition;
     LineNumber = sourceText.Line;
     ColumnNumber = sourceText.Character;
     // We want to keep track of the location's document if it comes from a file in your solution.
     DocumentId = documentId;
     ReferenceLineText = referenceLineText;
     ReferenceStart = referenceStart;
     ReferenceLength = referenceLength;
     BeforeReferenceText1 = beforeReferenceText1;
     BeforeReferenceText2 = beforeReferenceText2;
     AfterReferenceText1 = afterReferenceText1;
     AfterReferenceText2 = afterReferenceText2;
 }
开发者ID:tvsonar,项目名称:roslyn,代码行数:18,代码来源:ReferenceLocationDescriptor.cs

示例4: GetLocationInfo

        private static void GetLocationInfo(Document document, Location location, out TextSpan sourceSpan, out FileLinePositionSpan originalLineInfo, out FileLinePositionSpan mappedLineInfo)
        {
            var diagnosticSpanMappingService = document.Project.Solution.Workspace.Services.GetService<IWorkspaceVenusSpanMappingService>();
            if (diagnosticSpanMappingService != null)
            {
                diagnosticSpanMappingService.GetAdjustedDiagnosticSpan(document.Id, location, out sourceSpan, out originalLineInfo, out mappedLineInfo);
                return;
            }

            sourceSpan = location.SourceSpan;
            originalLineInfo = location.GetLineSpan();
            mappedLineInfo = location.GetMappedLineSpan();
        }
开发者ID:robertoenbarcelona,项目名称:roslyn,代码行数:13,代码来源:DiagnosticData.cs

示例5: VerifyDiagnosticLocation

        private static void VerifyDiagnosticLocation(DiagnosticAnalyzer analyzer, Diagnostic diagnostic, Location actual, DiagnosticResultLocation expected)
        {
            FileLinePositionSpan actualSpan = actual.GetLineSpan();

            Assert.True(actualSpan.Path == expected.Path || (actualSpan.Path != null && actualSpan.Path.Contains("Test0.") && expected.Path.Contains("Test.")),
                string.Format("Expected diagnostic to be in file \"{0}\" was actually in file \"{1}\"\r\n\r\nDiagnostic:\r\n    {2}\r\n",
                    expected.Path, actualSpan.Path, FormatDiagnostics(analyzer, diagnostic)));

            Text.LinePosition actualLinePosition = actualSpan.StartLinePosition;

            // Only check line position if there is an actual line in the real diagnostic
            if (actualLinePosition.Line > 0)
            {
                if (actualLinePosition.Line + 1 != expected.Line)
                {
                    Assert.True(false,
                        string.Format("Expected diagnostic to be on line \"{0}\" was actually on line \"{1}\"\r\n\r\nDiagnostic:\r\n    {2}\r\n",
                            expected.Line, actualLinePosition.Line + 1, FormatDiagnostics(analyzer, diagnostic)));
                }
            }

            // Only check column position if there is an actual column position in the real diagnostic
            if (actualLinePosition.Character > 0)
            {
                if (actualLinePosition.Character + 1 != expected.Column)
                {
                    Assert.True(false,
                        string.Format("Expected diagnostic to start at column \"{0}\" was actually at column \"{1}\"\r\n\r\nDiagnostic:\r\n    {2}\r\n",
                            expected.Column, actualLinePosition.Character + 1, FormatDiagnostics(analyzer, diagnostic)));
                }
            }
        }
开发者ID:duracellko,项目名称:roslyn-analyzers,代码行数:32,代码来源:DiagnosticAnalyzerTests.Extensions.cs


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