mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-16 18:47:57 -05:00
Addressing code review feedback
This commit is contained in:
@@ -14,6 +14,9 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class ConnectionInfo
|
public class ConnectionInfo
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor
|
||||||
|
/// </summary>
|
||||||
public ConnectionInfo(ISqlConnectionFactory factory, string ownerUri, ConnectionDetails details)
|
public ConnectionInfo(ISqlConnectionFactory factory, string ownerUri, ConnectionDetails details)
|
||||||
{
|
{
|
||||||
Factory = factory;
|
Factory = factory;
|
||||||
@@ -27,12 +30,24 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public Guid ConnectionId { get; private set; }
|
public Guid ConnectionId { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// URI identifying the owner/user of the connection. Could be a file, service, resource, etc.
|
||||||
|
/// </summary>
|
||||||
public string OwnerUri { get; private set; }
|
public string OwnerUri { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Factory used for creating the SQL connection associated with the connection info.
|
||||||
|
/// </summary>
|
||||||
public ISqlConnectionFactory Factory {get; private set;}
|
public ISqlConnectionFactory Factory {get; private set;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Properties used for creating/opening the SQL connection.
|
||||||
|
/// </summary>
|
||||||
public ConnectionDetails ConnectionDetails { get; private set; }
|
public ConnectionDetails ConnectionDetails { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The connection to the SQL database that commands will be run against.
|
||||||
|
/// </summary>
|
||||||
public DbConnection SqlConnection { get; set; }
|
public DbConnection SqlConnection { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,89 +0,0 @@
|
|||||||
//
|
|
||||||
// Copyright (c) Microsoft. All rights reserved.
|
|
||||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
||||||
//
|
|
||||||
|
|
||||||
using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol.Contracts;
|
|
||||||
|
|
||||||
namespace Microsoft.SqlTools.ServiceLayer.Connection.Contracts
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Parameters for the Connect Request.
|
|
||||||
/// </summary>
|
|
||||||
public class ConnectParams
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// A URI identifying the owner of the connection. This will most commonly be a file in the workspace
|
|
||||||
/// or a virtual file representing an object in a database.
|
|
||||||
/// </summary>
|
|
||||||
public string OwnerUri { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// Contains the required parameters to initialize a connection to a database.
|
|
||||||
/// A connection will identified by its server name, database name and user name.
|
|
||||||
/// This may be changed in the future to support multiple connections with different
|
|
||||||
/// connection properties to the same database.
|
|
||||||
/// </summary>
|
|
||||||
public ConnectionDetails Connection { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Message format for the connection result response
|
|
||||||
/// </summary>
|
|
||||||
public class ConnectResponse
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// A GUID representing a unique connection ID
|
|
||||||
/// </summary>
|
|
||||||
public string ConnectionId { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets any connection error messages
|
|
||||||
/// </summary>
|
|
||||||
public string Messages { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Provides high level information about a connection.
|
|
||||||
/// </summary>
|
|
||||||
public class ConnectionSummary
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the connection server name
|
|
||||||
/// </summary>
|
|
||||||
public string ServerName { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the connection database name
|
|
||||||
/// </summary>
|
|
||||||
public string DatabaseName { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the connection user name
|
|
||||||
/// </summary>
|
|
||||||
public string UserName { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Message format for the initial connection request
|
|
||||||
/// </summary>
|
|
||||||
public class ConnectionDetails : ConnectionSummary
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the connection password
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public string Password { get; set; }
|
|
||||||
|
|
||||||
// TODO Handle full set of properties
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Connect request mapping entry
|
|
||||||
/// </summary>
|
|
||||||
public class ConnectionRequest
|
|
||||||
{
|
|
||||||
public static readonly
|
|
||||||
RequestType<ConnectParams, ConnectResponse> Type =
|
|
||||||
RequestType<ConnectParams, ConnectResponse>.Create("connection/connect");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
//
|
||||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||||
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||||
|
//
|
||||||
|
|
||||||
|
namespace Microsoft.SqlTools.ServiceLayer.Connection.Contracts
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Parameters for the Connect Request.
|
||||||
|
/// </summary>
|
||||||
|
public class ConnectParams
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A URI identifying the owner of the connection. This will most commonly be a file in the workspace
|
||||||
|
/// or a virtual file representing an object in a database.
|
||||||
|
/// </summary>
|
||||||
|
public string OwnerUri { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Contains the required parameters to initialize a connection to a database.
|
||||||
|
/// A connection will identified by its server name, database name and user name.
|
||||||
|
/// This may be changed in the future to support multiple connections with different
|
||||||
|
/// connection properties to the same database.
|
||||||
|
/// </summary>
|
||||||
|
public ConnectionDetails Connection { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -27,23 +27,4 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection.Contracts
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Extension methods to ConnectionSummary
|
|
||||||
/// </summary>
|
|
||||||
public static class ConnectionSummaryExtensions
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Create a copy of a ConnectionSummary object
|
|
||||||
/// </summary>
|
|
||||||
public static ConnectionSummary Clone(this ConnectionSummary summary)
|
|
||||||
{
|
|
||||||
return new ConnectionSummary()
|
|
||||||
{
|
|
||||||
ServerName = summary.ServerName,
|
|
||||||
DatabaseName = summary.DatabaseName,
|
|
||||||
UserName = summary.UserName
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
//
|
||||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||||
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||||
|
//
|
||||||
|
|
||||||
|
namespace Microsoft.SqlTools.ServiceLayer.Connection.Contracts
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Message format for the connection result response
|
||||||
|
/// </summary>
|
||||||
|
public class ConnectResponse
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A GUID representing a unique connection ID
|
||||||
|
/// </summary>
|
||||||
|
public string ConnectionId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets any connection error messages
|
||||||
|
/// </summary>
|
||||||
|
public string Messages { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
//
|
||||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||||
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||||
|
//
|
||||||
|
|
||||||
|
using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol.Contracts;
|
||||||
|
|
||||||
|
namespace Microsoft.SqlTools.ServiceLayer.Connection.Contracts
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// ConnectionChanged notification mapping entry
|
||||||
|
/// </summary>
|
||||||
|
public class ConnectionChangedNotification
|
||||||
|
{
|
||||||
|
public static readonly
|
||||||
|
EventType<ConnectionChangedParams> Type =
|
||||||
|
EventType<ConnectionChangedParams>.Create("connection/connectionchanged");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,8 +3,6 @@
|
|||||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||||
//
|
//
|
||||||
|
|
||||||
using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol.Contracts;
|
|
||||||
|
|
||||||
namespace Microsoft.SqlTools.ServiceLayer.Connection.Contracts
|
namespace Microsoft.SqlTools.ServiceLayer.Connection.Contracts
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -22,15 +20,4 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection.Contracts
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public ConnectionSummary Connection { get; set; }
|
public ConnectionSummary Connection { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// ConnectionChanged notification mapping entry
|
|
||||||
/// </summary>
|
|
||||||
public class ConnectionChangedNotification
|
|
||||||
{
|
|
||||||
public static readonly
|
|
||||||
EventType<ConnectionChangedParams> Type =
|
|
||||||
EventType<ConnectionChangedParams>.Create("connection/connectionchanged");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
//
|
||||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||||
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||||
|
//
|
||||||
|
|
||||||
|
namespace Microsoft.SqlTools.ServiceLayer.Connection.Contracts
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Message format for the initial connection request
|
||||||
|
/// </summary>
|
||||||
|
public class ConnectionDetails : ConnectionSummary
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the connection password
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public string Password { get; set; }
|
||||||
|
|
||||||
|
// TODO Handle full set of properties
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
//
|
||||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||||
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||||
|
//
|
||||||
|
|
||||||
|
using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol.Contracts;
|
||||||
|
|
||||||
|
namespace Microsoft.SqlTools.ServiceLayer.Connection.Contracts
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Connect request mapping entry
|
||||||
|
/// </summary>
|
||||||
|
public class ConnectionRequest
|
||||||
|
{
|
||||||
|
public static readonly
|
||||||
|
RequestType<ConnectParams, ConnectResponse> Type =
|
||||||
|
RequestType<ConnectParams, ConnectResponse>.Create("connection/connect");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
//
|
||||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||||
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||||
|
//
|
||||||
|
|
||||||
|
namespace Microsoft.SqlTools.ServiceLayer.Connection.Contracts
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Provides high level information about a connection.
|
||||||
|
/// </summary>
|
||||||
|
public class ConnectionSummary
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the connection server name
|
||||||
|
/// </summary>
|
||||||
|
public string ServerName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the connection database name
|
||||||
|
/// </summary>
|
||||||
|
public string DatabaseName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the connection user name
|
||||||
|
/// </summary>
|
||||||
|
public string UserName { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
//
|
||||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||||
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||||
|
//
|
||||||
|
|
||||||
|
namespace Microsoft.SqlTools.ServiceLayer.Connection.Contracts
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Extension methods to ConnectionSummary
|
||||||
|
/// </summary>
|
||||||
|
public static class ConnectionSummaryExtensions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Create a copy of a ConnectionSummary object
|
||||||
|
/// </summary>
|
||||||
|
public static ConnectionSummary Clone(this ConnectionSummary summary)
|
||||||
|
{
|
||||||
|
return new ConnectionSummary()
|
||||||
|
{
|
||||||
|
ServerName = summary.ServerName,
|
||||||
|
DatabaseName = summary.DatabaseName,
|
||||||
|
UserName = summary.UserName
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,8 +3,6 @@
|
|||||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||||
//
|
//
|
||||||
|
|
||||||
using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol.Contracts;
|
|
||||||
|
|
||||||
namespace Microsoft.SqlTools.ServiceLayer.Connection.Contracts
|
namespace Microsoft.SqlTools.ServiceLayer.Connection.Contracts
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -18,14 +16,4 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection.Contracts
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string OwnerUri { get; set; }
|
public string OwnerUri { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Disconnect request mapping entry
|
|
||||||
/// </summary>
|
|
||||||
public class DisconnectRequest
|
|
||||||
{
|
|
||||||
public static readonly
|
|
||||||
RequestType<DisconnectParams, bool> Type =
|
|
||||||
RequestType<DisconnectParams, bool>.Create("connection/disconnect");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
//
|
||||||
|
// Copyright (c) Microsoft. All rights reserved.
|
||||||
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||||
|
//
|
||||||
|
|
||||||
|
using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol.Contracts;
|
||||||
|
|
||||||
|
namespace Microsoft.SqlTools.ServiceLayer.Connection.Contracts
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Disconnect request mapping entry
|
||||||
|
/// </summary>
|
||||||
|
public class DisconnectRequest
|
||||||
|
{
|
||||||
|
public static readonly
|
||||||
|
RequestType<DisconnectParams, bool> Type =
|
||||||
|
RequestType<DisconnectParams, bool>.Create("connection/disconnect");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,14 +14,17 @@ using Microsoft.SqlTools.ServiceLayer.Workspace.Contracts;
|
|||||||
|
|
||||||
namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
||||||
{
|
{
|
||||||
|
|
||||||
internal class IntellisenseCache
|
internal class IntellisenseCache
|
||||||
{
|
{
|
||||||
// connection used to query for intellisense info
|
/// <summary>
|
||||||
|
/// connection used to query for intellisense info
|
||||||
|
/// </summary>
|
||||||
private DbConnection connection;
|
private DbConnection connection;
|
||||||
|
|
||||||
// number of documents (URI's) that are using the cache for the same database
|
/// <summary>
|
||||||
// the autocomplete service uses this to remove unreferenced caches
|
/// Number of documents (URI's) that are using the cache for the same database.
|
||||||
|
/// The autocomplete service uses this to remove unreferenced caches.
|
||||||
|
/// </summary>
|
||||||
public int ReferenceCount { get; set; }
|
public int ReferenceCount { get; set; }
|
||||||
|
|
||||||
public IntellisenseCache(ISqlConnectionFactory connectionFactory, ConnectionDetails connectionDetails)
|
public IntellisenseCache(ISqlConnectionFactory connectionFactory, ConnectionDetails connectionDetails)
|
||||||
|
|||||||
Reference in New Issue
Block a user