public CompletionRequestCompleted(
     IEnumerable <CompletionItem> completionList,
     RequestCompletion command,
     LinePositionSpan?range = null) : base(command)
 {
     CompletionList = completionList ?? throw new ArgumentNullException(nameof(completionList));
     _range         = range;
 }
Exemplo n.º 2
0
 public CompletionsProduced(
     IEnumerable <CompletionItem> completions,
     RequestCompletions command,
     LinePositionSpan?linePositionSpan = null) : base(command)
 {
     Completions       = completions ?? throw new ArgumentNullException(nameof(completions));
     _linePositionSpan = linePositionSpan;
 }
Exemplo n.º 3
0
        public HoverTextProduced(IKernelCommand command, IReadOnlyCollection <FormattedValue> content, LinePositionSpan?range = null)
            : base(command)
        {
            if (content.Count == 0)
            {
                throw new ArgumentException(nameof(content), "At least one content required.");
            }

            Content = content;
            Range   = range;
        }
Exemplo n.º 4
0
        public static Range FromLinePositionSpan(LinePositionSpan?linePositionSpan)
        {
            if (!linePositionSpan.HasValue)
            {
                return(null);
            }

            return(new Range(
                       Position.FromLinePosition(linePositionSpan.GetValueOrDefault().Start),
                       Position.FromLinePosition(linePositionSpan.GetValueOrDefault().End)));
        }
Exemplo n.º 5
0
 public SourceCodeError(string message, LinePositionSpan?location = default)
 {
     _message     = message;
     _hasLocation = location.HasValue;
     if (location.HasValue)
     {
         _startLine      = location.Value.Start.Line;
         _startCharacter = location.Value.Start.Character;
         _endLine        = location.Value.End.Line;
         _endCharacter   = location.Value.End.Character;
     }
 }
Exemplo n.º 6
0
        public HoverTextProduced(RequestHoverText command, IReadOnlyCollection <FormattedValue> content, LinePositionSpan?linePositionSpan = null)
            : base(command)
        {
            if (content == null)
            {
                throw new ArgumentNullException(nameof(content));
            }

            if (content.Count == 0)
            {
                throw new ArgumentException("At least one content required.", nameof(content));
            }

            Content           = content;
            _linePositionSpan = linePositionSpan;
        }
Exemplo n.º 7
0
 public HoverTextProduced(IKernelCommand command, string content, LinePositionSpan?range = null)
     : base(command)
 {
     Content = content;
     Range   = range;
 }
Exemplo n.º 8
0
 public HoverMarkdownProduced(IKernelCommand command, string content, LinePositionSpan?range = null)
     : base(command, content, range)
 {
 }
 public static void PublishHoverTextMarkdownResponse(this KernelInvocationContext context, RequestHoverText command, string content, LinePositionSpan?linePositionSpan = null)
 {
     context.PublishHoverTextResponse(command, new FormattedValue("text/markdown", content), linePositionSpan);
 }
 public static void PublishHoverTextResponse(this KernelInvocationContext context, RequestHoverText command, FormattedValue value, LinePositionSpan?linePositionSpan = null)
 {
     context.PublishHoverTextResponse(command, new[] { value }, linePositionSpan);
 }
        public static void PublishHoverTextResponse(this KernelInvocationContext context, RequestHoverText command, IReadOnlyCollection <FormattedValue> content, LinePositionSpan?linePositionSpan = null)
        {
            var response = new HoverTextProduced(command, content, linePositionSpan);

            context.Publish(response);
        }
Exemplo n.º 12
0
        public static LinePositionSpan?CalculateLineOffsetFromParentCommand(this KernelEvent @event, LinePositionSpan?initialRange)
        {
            if (!initialRange.HasValue)
            {
                return(null);
            }

            var range          = initialRange.GetValueOrDefault();
            var requestCommand = @event.Command as LanguageServiceCommand;

            if (requestCommand?.Parent is LanguageServiceCommand parentRequest)
            {
                var requestPosition = requestCommand.LinePosition;
                var lineOffset      = parentRequest.LinePosition.Line - requestPosition.Line;
                return(new LinePositionSpan(
                           new LinePosition(range.Start.Line + lineOffset, range.Start.Character),
                           new LinePosition(range.End.Line + lineOffset, range.End.Character)));
            }

            return(range);
        }