mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-14 01:25:40 -05:00
Changing the format of the messages to be based on language server protocol 2.0
This commit is contained in:
@@ -155,7 +155,7 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
||||
// that are not backed by a SQL connection
|
||||
ConnectionInfo info;
|
||||
IntellisenseCache cache;
|
||||
if (ConnectionServiceInstance.TryFindConnection(textDocumentPosition.Uri, out info)
|
||||
if (ConnectionServiceInstance.TryFindConnection(textDocumentPosition.TextDocument.Uri, out info)
|
||||
&& caches.TryGetValue((ConnectionSummary)info.ConnectionDetails, out cache))
|
||||
{
|
||||
return cache.GetAutoCompleteItems(textDocumentPosition).ToArray();
|
||||
|
||||
@@ -213,7 +213,7 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
||||
}
|
||||
|
||||
private static async Task HandleDocumentSymbolRequest(
|
||||
TextDocumentIdentifier textDocumentIdentifier,
|
||||
DocumentSymbolParams documentSymbolParams,
|
||||
RequestContext<SymbolInformation[]> requestContext)
|
||||
{
|
||||
Logger.Write(LogLevel.Verbose, "HandleDocumentSymbolRequest");
|
||||
|
||||
@@ -19,37 +19,70 @@ namespace Microsoft.SqlTools.ServiceLayer.Workspace.Contracts
|
||||
/// text document.
|
||||
/// </summary>
|
||||
public string Uri { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Defines a position in a text document.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("TextDocumentPosition = {Position.Line}:{Position.Character}")]
|
||||
public class TextDocumentPosition : TextDocumentIdentifier
|
||||
public class TextDocumentPosition
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the document identifier.
|
||||
/// </summary>
|
||||
public TextDocumentIdentifier TextDocument { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the position in the document.
|
||||
/// </summary>
|
||||
public Position Position { get; set; }
|
||||
}
|
||||
|
||||
public class DidOpenTextDocumentNotification : TextDocumentIdentifier
|
||||
/// <summary>
|
||||
/// Defines a text document.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("TextDocumentItem = {Uri}")]
|
||||
public class TextDocumentItem
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the URI which identifies the path of the
|
||||
/// text document.
|
||||
/// </summary>
|
||||
public string Uri { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the language of the document
|
||||
/// </summary>
|
||||
public string LanguageId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the version of the document
|
||||
/// </summary>
|
||||
public int Version { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the full content of the document.
|
||||
/// </summary>
|
||||
public string Text { get; set; }
|
||||
}
|
||||
|
||||
public class DidOpenTextDocumentNotification
|
||||
{
|
||||
public static readonly
|
||||
EventType<DidOpenTextDocumentNotification> Type =
|
||||
EventType<DidOpenTextDocumentNotification>.Create("textDocument/didOpen");
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the full content of the opened document.
|
||||
/// Gets or sets the opened document.
|
||||
/// </summary>
|
||||
public string Text { get; set; }
|
||||
public TextDocumentItem TextDocument { get; set; }
|
||||
}
|
||||
|
||||
public class DidCloseTextDocumentNotification
|
||||
{
|
||||
public static readonly
|
||||
EventType<TextDocumentIdentifier> Type =
|
||||
EventType<TextDocumentIdentifier>.Create("textDocument/didClose");
|
||||
EventType<DidCloseTextDocumentParams> Type =
|
||||
EventType<DidCloseTextDocumentParams>.Create("textDocument/didClose");
|
||||
}
|
||||
|
||||
public class DidChangeTextDocumentNotification
|
||||
@@ -59,9 +92,20 @@ namespace Microsoft.SqlTools.ServiceLayer.Workspace.Contracts
|
||||
EventType<DidChangeTextDocumentParams>.Create("textDocument/didChange");
|
||||
}
|
||||
|
||||
public class DidChangeTextDocumentParams : TextDocumentIdentifier
|
||||
public class DidCloseTextDocumentParams
|
||||
{
|
||||
public TextDocumentUriChangeEvent TextDocument { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the closed document.
|
||||
/// </summary>
|
||||
public TextDocumentItem TextDocument { get; set; }
|
||||
}
|
||||
|
||||
public class DidChangeTextDocumentParams
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the changed document.
|
||||
/// </summary>
|
||||
public VersionedTextDocumentIdentifier TextDocument { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the list of changes to the document content.
|
||||
@@ -69,13 +113,11 @@ namespace Microsoft.SqlTools.ServiceLayer.Workspace.Contracts
|
||||
public TextDocumentChangeEvent[] ContentChanges { get; set; }
|
||||
}
|
||||
|
||||
public class TextDocumentUriChangeEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the Uri of the changed text document
|
||||
/// </summary>
|
||||
public string Uri { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Define a specific version of a text document
|
||||
/// </summary>
|
||||
public class VersionedTextDocumentIdentifier : TextDocumentIdentifier
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the Version of the changed text document
|
||||
/// </summary>
|
||||
|
||||
@@ -43,8 +43,16 @@ namespace Microsoft.SqlTools.ServiceLayer.Workspace.Contracts
|
||||
public class DocumentSymbolRequest
|
||||
{
|
||||
public static readonly
|
||||
RequestType<TextDocumentIdentifier, SymbolInformation[]> Type =
|
||||
RequestType<TextDocumentIdentifier, SymbolInformation[]>.Create("textDocument/documentSymbol");
|
||||
RequestType<DocumentSymbolParams, SymbolInformation[]> Type =
|
||||
RequestType<DocumentSymbolParams, SymbolInformation[]>.Create("textDocument/documentSymbol");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Defines a set of parameters to send document symbol request
|
||||
/// </summary>
|
||||
public class DocumentSymbolParams
|
||||
{
|
||||
public TextDocumentIdentifier TextDocument { get; set; }
|
||||
}
|
||||
|
||||
public class WorkspaceSymbolRequest
|
||||
|
||||
@@ -181,7 +181,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Workspace
|
||||
// A text change notification can batch multiple change requests
|
||||
foreach (var textChange in textChangeParams.ContentChanges)
|
||||
{
|
||||
string fileUri = textChangeParams.Uri ?? textChangeParams.TextDocument.Uri;
|
||||
string fileUri = textChangeParams.TextDocument.Uri ?? textChangeParams.TextDocument.Uri;
|
||||
msg.AppendLine(string.Format(" File: {0}", fileUri));
|
||||
|
||||
ScriptFile changedFile = Workspace.GetFile(fileUri);
|
||||
@@ -207,7 +207,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Workspace
|
||||
Logger.Write(LogLevel.Verbose, "HandleDidOpenTextDocumentNotification");
|
||||
|
||||
// read the SQL file contents into the ScriptFile
|
||||
ScriptFile openedFile = Workspace.GetFileBuffer(openParams.Uri, openParams.Text);
|
||||
ScriptFile openedFile = Workspace.GetFileBuffer(openParams.TextDocument.Uri, openParams.TextDocument.Text);
|
||||
|
||||
// Propagate the changes to the event handlers
|
||||
var textDocOpenTasks = TextDocOpenCallbacks.Select(
|
||||
@@ -217,7 +217,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Workspace
|
||||
}
|
||||
|
||||
protected Task HandleDidCloseTextDocumentNotification(
|
||||
TextDocumentIdentifier closeParams,
|
||||
DidCloseTextDocumentParams closeParams,
|
||||
EventContext eventContext)
|
||||
{
|
||||
Logger.Write(LogLevel.Verbose, "HandleDidCloseTextDocumentNotification");
|
||||
|
||||
@@ -197,7 +197,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.LanguageServices
|
||||
|
||||
// Check that we get table suggestions for an autocomplete request
|
||||
TextDocumentPosition position = new TextDocumentPosition();
|
||||
position.Uri = connectionRequest.OwnerUri;
|
||||
position.TextDocument = new TextDocumentIdentifier();
|
||||
position.TextDocument.Uri = connectionRequest.OwnerUri;
|
||||
position.Position = new Position();
|
||||
position.Position.Line = 1;
|
||||
position.Position.Character = 1;
|
||||
@@ -291,7 +292,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.LanguageServices
|
||||
|
||||
// Check that we get 2 different table suggestions for autocomplete requests
|
||||
TextDocumentPosition position = new TextDocumentPosition();
|
||||
position.Uri = connectionRequest.OwnerUri;
|
||||
position.TextDocument = new TextDocumentIdentifier();
|
||||
position.TextDocument.Uri = connectionRequest.OwnerUri;
|
||||
position.Position = new Position();
|
||||
position.Position.Line = 1;
|
||||
position.Position.Character = 1;
|
||||
@@ -302,7 +304,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.LanguageServices
|
||||
Assert.Equal("model", items[1].Label);
|
||||
|
||||
TextDocumentPosition position2 = new TextDocumentPosition();
|
||||
position2.Uri = connectionRequest2.OwnerUri;
|
||||
position2.TextDocument = new TextDocumentIdentifier();
|
||||
position2.TextDocument.Uri = connectionRequest2.OwnerUri;
|
||||
position2.Position = new Position();
|
||||
position2.Position.Line = 1;
|
||||
position2.Position.Character = 1;
|
||||
|
||||
Reference in New Issue
Block a user