本文整理汇总了C#中Microsoft.CodeAnalysis.Location.GetMappedLineSpan方法的典型用法代码示例。如果您正苦于以下问题:C# Location.GetMappedLineSpan方法的具体用法?C# Location.GetMappedLineSpan怎么用?C# Location.GetMappedLineSpan使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.CodeAnalysis.Location
的用法示例。
在下文中一共展示了Location.GetMappedLineSpan方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetAdjustedDiagnosticSpan
public void GetAdjustedDiagnosticSpan(
DocumentId documentId, Location location,
out TextSpan sourceSpan, out FileLinePositionSpan originalLineInfo, out FileLinePositionSpan mappedLineInfo)
{
sourceSpan = location.SourceSpan;
originalLineInfo = location.GetLineSpan();
mappedLineInfo = location.GetMappedLineSpan();
// check quick bail out case.
if (location == Location.None)
{
return;
}
// Update the original source span, if required.
if (!TryAdjustSpanIfNeededForVenus(documentId, originalLineInfo, mappedLineInfo, out var originalSpan, out var mappedSpan))
{
return;
}
if (originalSpan.Start != originalLineInfo.StartLinePosition || originalSpan.End != originalLineInfo.EndLinePosition)
{
originalLineInfo = new FileLinePositionSpan(originalLineInfo.Path, originalSpan.Start, originalSpan.End);
var textLines = location.SourceTree.GetText().Lines;
var startPos = textLines.GetPosition(originalSpan.Start);
var endPos = textLines.GetPosition(originalSpan.End);
sourceSpan = TextSpan.FromBounds(startPos, Math.Max(startPos, endPos));
}
if (mappedSpan.Start != mappedLineInfo.StartLinePosition || mappedSpan.End != mappedLineInfo.EndLinePosition)
{
mappedLineInfo = new FileLinePositionSpan(mappedLineInfo.Path, mappedSpan.Start, mappedSpan.End);
}
}
示例2: GetAdjustedDiagnosticSpan
public void GetAdjustedDiagnosticSpan(
DocumentId documentId, Location location,
out TextSpan sourceSpan, out FileLinePositionSpan originalLineInfo, out FileLinePositionSpan mappedLineInfo)
{
sourceSpan = location.SourceSpan;
originalLineInfo = location.GetLineSpan();
mappedLineInfo = location.GetMappedLineSpan();
// Update the original source span, if required.
LinePositionSpan originalSpan;
LinePositionSpan mappedSpan;
if (!TryAdjustSpanIfNeededForVenus(documentId, originalLineInfo, mappedLineInfo, out originalSpan, out mappedSpan))
{
return;
}
if (originalSpan.Start != originalLineInfo.StartLinePosition || originalSpan.End != originalLineInfo.EndLinePosition)
{
originalLineInfo = new FileLinePositionSpan(originalLineInfo.Path, originalSpan.Start, originalSpan.End);
var textLines = location.SourceTree.GetText().Lines;
var startPos = textLines.GetPosition(originalSpan.Start);
var endPos = textLines.GetPosition(originalSpan.End);
sourceSpan = new TextSpan(startPos, endPos - startPos);
}
if (mappedSpan.Start != mappedLineInfo.StartLinePosition || mappedSpan.End != mappedLineInfo.EndLinePosition)
{
mappedLineInfo = new FileLinePositionSpan(mappedLineInfo.Path, mappedSpan.Start, mappedSpan.End);
}
}
示例3: setLocation
protected void setLocation(Location location)
{
var line = location.GetMappedLineSpan().StartLinePosition;
File = location.FilePath;
Line = line.Line + 1;
Character = line.Character + 1;
}
示例4: DiagnosticDescription
internal DiagnosticDescription(Diagnostic d, bool errorCodeOnly, bool showPosition = false)
{
_code = d.Code;
_isWarningAsError = d.IsWarningAsError;
_location = d.Location;
DiagnosticWithInfo dinfo = null;
if (d.Code == 0)
{
_code = d.Id;
_errorCodeType = typeof(string);
}
else
{
dinfo = d as DiagnosticWithInfo;
if (dinfo == null)
{
_code = d.Code;
_errorCodeType = typeof(int);
}
else
{
_errorCodeType = dinfo.Info.MessageProvider.ErrorCodeType;
_code = d.Code;
}
}
_ignoreArgumentsWhenComparing = errorCodeOnly;
_showPosition = showPosition;
if (!_ignoreArgumentsWhenComparing)
{
if (_location.IsInSource)
{
// we don't just want to do SyntaxNode.GetText(), because getting the text via the SourceTree validates the public API
_squiggledText = _location.SourceTree.GetText().ToString(_location.SourceSpan);
}
if (dinfo != null)
{
_arguments = dinfo.Info.Arguments;
}
else
{
IReadOnlyList<object> args = d.Arguments;
if (args == null || args.Count == 0)
{
_arguments = null;
}
else
{
_arguments = d.Arguments.ToArray();
}
}
if (_arguments != null && _arguments.Length == 0)
{
_arguments = null;
}
}
_startPosition = _location.GetMappedLineSpan().StartLinePosition;
}
示例5: CodeGeneratorException
public CodeGeneratorException(Location location, string message)
: this(location == null ? -1 : location.GetMappedLineSpan().StartLinePosition.Line, location == null ? -1 : location.GetMappedLineSpan().StartLinePosition.Character, message)
{
}