private TextSpan GetTextSpan(ICodeActionRequest request, SourceText sourceText) { if (request.Selection != null) { return(sourceText.GetSpanFromRange(request.Selection)); } var position = sourceText.GetPositionFromLineAndOffset(request.Line, request.Column); return(new TextSpan(position, length: 0)); }
/// <summary> /// Converts an OmniSharp <see cref="Point"/> to a zero-based position within a <see cref="SourceText"/>. /// </summary> public static int GetPositionFromPoint(this SourceText text, Point point) => text.GetPositionFromLineAndOffset(point.Line, point.Column);
/// <summary> /// Converts an OmniSharp <see cref="Range"/> to a <see cref="TextSpan"/> within a <see cref="SourceText"/>. /// </summary> public static TextSpan GetSpanFromLinePositionSpanTextChange(this SourceText text, LinePositionSpanTextChange change) => TextSpan.FromBounds( start: text.GetPositionFromLineAndOffset(change.StartLine, change.StartColumn), end: text.GetPositionFromLineAndOffset(change.EndLine, change.EndColumn));