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