コード例 #1
0
        public void SimpleTest(string expected)
        {
            var model  = new MarkedString("csharp", "some documented text...");
            var result = Fixture.SerializeObject(model);

            result.Should().Be(expected);

            var deresult = new LspSerializer(ClientVersion.Lsp3).DeserializeObject <MarkedString>(expected);

            deresult.Should().BeEquivalentTo(model, x => x.UsingStructuralRecordEquality());
        }
コード例 #2
0
        public void SimpleTest(string expected)
        {
            var model  = new MarkedString("csharp", "some documented text...");
            var result = Fixture.SerializeObject(model);

            result.Should().Be(expected);

            var deresult = JsonConvert.DeserializeObject <MarkedString>(expected);

            deresult.ShouldBeEquivalentTo(model);
        }
コード例 #3
0
        /// <summary>
        /// Converts a SQL Parser QuickInfo object into a VS Code Hover object
        /// </summary>
        /// <param name="quickInfo"></param>
        /// <param name="row"></param>
        /// <param name="startColumn"></param>
        /// <param name="endColumn"></param>
        internal static Hover ConvertQuickInfoToHover(
            Babel.CodeObjectQuickInfo quickInfo,
            int row,
            int startColumn,
            int endColumn)
        {
            // convert from the parser format to the VS Code wire format
            var markedStrings = new MarkedString[1];

            if (quickInfo != null)
            {
                markedStrings[0] = new MarkedString()
                {
                    Language = "SQL",
                    Value    = quickInfo.Text
                };

                return(new Hover()
                {
                    Contents = markedStrings,
                    Range = new Range
                    {
                        Start = new Position
                        {
                            Line = row,
                            Character = startColumn
                        },
                        End = new Position
                        {
                            Line = row,
                            Character = endColumn
                        }
                    }
                });
            }
            else
            {
                return(null);
            }
        }
コード例 #4
0
        private void ProcessHover(object requestId, TextDocumentPositionParams hoverParams)
        {
            ToolTipInfo tooltip;

            if (_project != null)
            {
                string filepath = PathUtils.NormalizePath(hoverParams.TextDocument.Uri);
                tooltip = _project.ObtainToolTip(filepath, hoverParams.Position.Line, hoverParams.Position.Character);
            }
            else
            {
                tooltip = null;
            }

            Hover response;

            if (tooltip != null)
            {
                var codePart = new MarkedString()
                {
                    Language = "php",
                    Value    = tooltip.Code
                };

                response = new Hover()
                {
                    Contents = (tooltip.Description != null) ?
                               new object[] { codePart, tooltip.Description }
                        : new object[] { codePart }
                };
            }
            else
            {
                // Return empty response to hide the "Loading..." text in the box
                response = null;
            }

            _messageWriter.WriteResponse(requestId, response);
        }