本文整理汇总了C#中SyntaxTree.GetMappedLineSpan方法的典型用法代码示例。如果您正苦于以下问题:C# SyntaxTree.GetMappedLineSpan方法的具体用法?C# SyntaxTree.GetMappedLineSpan怎么用?C# SyntaxTree.GetMappedLineSpan使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SyntaxTree
的用法示例。
在下文中一共展示了SyntaxTree.GetMappedLineSpan方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AssertMappedSpanEqual
private void AssertMappedSpanEqual(
SyntaxTree syntaxTree,
string sourceText,
string expectedPath,
int expectedStartLine,
int expectedStartOffset,
int expectedEndLine,
int expectedEndOffset,
bool hasMappedPath)
{
var span = GetSpanIn(syntaxTree, sourceText);
var mappedSpan = syntaxTree.GetMappedLineSpan(span);
var actualDisplayPath = syntaxTree.GetDisplayPath(span, s_resolver);
Assert.Equal(hasMappedPath, mappedSpan.HasMappedPath);
Assert.Equal(expectedPath, mappedSpan.Path);
if (expectedPath == "")
{
Assert.Equal("", actualDisplayPath);
}
else
{
Assert.Equal(string.Format("[{0};{1}]", expectedPath, hasMappedPath ? syntaxTree.FilePath : null), actualDisplayPath);
}
Assert.Equal(expectedStartLine, mappedSpan.StartLinePosition.Line);
Assert.Equal(expectedStartOffset, mappedSpan.StartLinePosition.Character);
Assert.Equal(expectedEndLine, mappedSpan.EndLinePosition.Line);
Assert.Equal(expectedEndOffset, mappedSpan.EndLinePosition.Character);
}
示例2: UpdatePosition
private DiagnosticData UpdatePosition(DiagnosticData diagnostic, SyntaxTree tree, int delta)
{
var start = Math.Min(Math.Max(diagnostic.TextSpan.Start + delta, 0), tree.Length);
var newSpan = new TextSpan(start, start >= tree.Length ? 0 : diagnostic.TextSpan.Length);
var mappedLineInfo = tree.GetMappedLineSpan(newSpan);
var originalLineInfo = tree.GetLineSpan(newSpan);
return new DiagnosticData(
diagnostic.Id,
diagnostic.Category,
diagnostic.Message,
diagnostic.ENUMessageForBingSearch,
diagnostic.Severity,
diagnostic.DefaultSeverity,
diagnostic.IsEnabledByDefault,
diagnostic.WarningLevel,
diagnostic.CustomTags,
diagnostic.Properties,
diagnostic.Workspace,
diagnostic.ProjectId,
diagnostic.DocumentId,
newSpan,
mappedFilePath: mappedLineInfo.GetMappedFilePathIfExist(),
mappedStartLine: mappedLineInfo.StartLinePosition.Line,
mappedStartColumn: mappedLineInfo.StartLinePosition.Character,
mappedEndLine: mappedLineInfo.EndLinePosition.Line,
mappedEndColumn: mappedLineInfo.EndLinePosition.Character,
originalFilePath: originalLineInfo.Path,
originalStartLine: originalLineInfo.StartLinePosition.Line,
originalStartColumn: originalLineInfo.StartLinePosition.Character,
originalEndLine: originalLineInfo.EndLinePosition.Line,
originalEndColumn: originalLineInfo.EndLinePosition.Character,
description: diagnostic.Description,
helpLink: diagnostic.HelpLink);
}
示例3: UpdateDiagnosticLocation
private DiagnosticDataLocation UpdateDiagnosticLocation(
DiagnosticDataLocation dataLocation, SyntaxTree tree, int delta)
{
var span = dataLocation.SourceSpan.Value;
var start = Math.Min(Math.Max(span.Start + delta, 0), tree.Length);
var newSpan = new TextSpan(start, start >= tree.Length ? 0 : span.Length);
var mappedLineInfo = tree.GetMappedLineSpan(newSpan);
var originalLineInfo = tree.GetLineSpan(newSpan);
return new DiagnosticDataLocation(dataLocation.DocumentId, newSpan,
originalFilePath: originalLineInfo.Path,
originalStartLine: originalLineInfo.StartLinePosition.Line,
originalStartColumn: originalLineInfo.StartLinePosition.Character,
originalEndLine: originalLineInfo.EndLinePosition.Line,
originalEndColumn: originalLineInfo.EndLinePosition.Character,
mappedFilePath: mappedLineInfo.GetMappedFilePathIfExist(),
mappedStartLine: mappedLineInfo.StartLinePosition.Line,
mappedStartColumn: mappedLineInfo.StartLinePosition.Character,
mappedEndLine: mappedLineInfo.EndLinePosition.Line,
mappedEndColumn: mappedLineInfo.EndLinePosition.Character);
}