mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-23 01:25:42 -05:00
Move unused forked code to external directory (#1192)
* Move unused forked code to external directory * Fix SLN build errors * Add back resource provider core since it's referenced by main resource provider project * Update PackageProjects step of pipeline
This commit is contained in:
3
external/Microsoft.SqlTools.DataProtocol.Contracts/AssemblyInfo.cs
vendored
Normal file
3
external/Microsoft.SqlTools.DataProtocol.Contracts/AssemblyInfo.cs
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
[assembly: InternalsVisibleTo("Microsoft.SqlTools.Hosting.UnitTests")]
|
||||
28
external/Microsoft.SqlTools.DataProtocol.Contracts/ClientCapabilities/ClientCapabilities.cs
vendored
Normal file
28
external/Microsoft.SqlTools.DataProtocol.Contracts/ClientCapabilities/ClientCapabilities.cs
vendored
Normal file
@@ -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.
|
||||
//
|
||||
|
||||
using Microsoft.SqlTools.DataProtocol.Contracts.ClientCapabilities.TextDocument;
|
||||
using Microsoft.SqlTools.DataProtocol.Contracts.ClientCapabilities.Workspace;
|
||||
|
||||
namespace Microsoft.SqlTools.DataProtocol.Contracts.ClientCapabilities
|
||||
{
|
||||
public class ClientCapabilities
|
||||
{
|
||||
/// <summary>
|
||||
/// Any experimental client capabilities
|
||||
/// </summary>
|
||||
public object Experimental { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Text document specific client capabilities, can be null
|
||||
/// </summary>
|
||||
public TextDocumentCapabilities TextDocument { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Workspace specific client capabilities, can be null
|
||||
/// </summary>
|
||||
public WorkspaceCapabilities Workspace { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
//
|
||||
// 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.DataProtocol.Contracts.ClientCapabilities
|
||||
{
|
||||
public class DynamicRegistrationCapability
|
||||
{
|
||||
/// <summary>
|
||||
/// Whether the capabilitiy supports dynamic registration
|
||||
/// </summary>
|
||||
public bool? DynamicRegistration { get; set; }
|
||||
}
|
||||
}
|
||||
14
external/Microsoft.SqlTools.DataProtocol.Contracts/ClientCapabilities/TextDocument/CodeAction.cs
vendored
Normal file
14
external/Microsoft.SqlTools.DataProtocol.Contracts/ClientCapabilities/TextDocument/CodeAction.cs
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
//
|
||||
// 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.DataProtocol.Contracts.ClientCapabilities.TextDocument
|
||||
{
|
||||
/// <summary>
|
||||
/// Capabilities specific to textDocument/codeAction requests
|
||||
/// </summary>
|
||||
public class CodeActionCapabilities : DynamicRegistrationCapability
|
||||
{
|
||||
}
|
||||
}
|
||||
14
external/Microsoft.SqlTools.DataProtocol.Contracts/ClientCapabilities/TextDocument/CodeLens.cs
vendored
Normal file
14
external/Microsoft.SqlTools.DataProtocol.Contracts/ClientCapabilities/TextDocument/CodeLens.cs
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
//
|
||||
// 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.DataProtocol.Contracts.ClientCapabilities.TextDocument
|
||||
{
|
||||
/// <summary>
|
||||
/// Capabilities specific to textDocument/codeLens requests
|
||||
/// </summary>
|
||||
public class CodeLensCapabilities : DynamicRegistrationCapability
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
//
|
||||
// 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.DataProtocol.Contracts.ClientCapabilities.TextDocument
|
||||
{
|
||||
/// <summary>
|
||||
/// Capabilities specific to the colorProviderw
|
||||
/// </summary>
|
||||
public class ColorProviderCapabilities : DynamicRegistrationCapability
|
||||
{
|
||||
}
|
||||
}
|
||||
63
external/Microsoft.SqlTools.DataProtocol.Contracts/ClientCapabilities/TextDocument/Completion.cs
vendored
Normal file
63
external/Microsoft.SqlTools.DataProtocol.Contracts/ClientCapabilities/TextDocument/Completion.cs
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
//
|
||||
// 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.DataProtocol.Contracts.Common;
|
||||
|
||||
namespace Microsoft.SqlTools.DataProtocol.Contracts.ClientCapabilities.TextDocument
|
||||
{
|
||||
/// <summary>
|
||||
/// Capabilities specific to the 'textDocument/completion' request
|
||||
/// </summary>
|
||||
public class CompletionCapabilities : DynamicRegistrationCapability
|
||||
{
|
||||
/// <summary>
|
||||
/// Client supports these CompletionItem specific capabilities. Can be <c>null</c>
|
||||
/// </summary>
|
||||
public CompletionItemCapabilities CompletionItem { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Client supports these CompletionItemKinds as responses to completion requests
|
||||
/// </summary>
|
||||
public CompletionItemKindCapabiltities CompletionItemKind { get; set; }
|
||||
}
|
||||
|
||||
public class CompletionItemCapabilities
|
||||
{
|
||||
/// <summary>
|
||||
/// Whether client supports snippet formats as completion results
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// A snippet can define tab stops and placeholders with <c>$1</c>, <c>$2</c> and
|
||||
/// <c>${3:foo}</c>. <c>$0</c> defines the final tab stop, it defaults to the end of
|
||||
/// the snippet. Placeholders with equal identifiers are linked, that is typing in one
|
||||
/// will update others, too.
|
||||
/// </remarks>
|
||||
public bool? SnippetSupport { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether client supports commit characters on a completion item
|
||||
/// </summary>
|
||||
public bool? CommitCharactersSpport { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Client supports these content formats for the documentation property. The order
|
||||
/// describes the preferred format of the client. May be <c>null</c>
|
||||
/// </summary>
|
||||
public MarkupKind[] DocumentationFormat { get; set; }
|
||||
}
|
||||
|
||||
public class CompletionItemKindCapabiltities
|
||||
{
|
||||
/// <summary>
|
||||
/// Completion item kind values the client supports. When this property exists, the
|
||||
/// client also guarantees that it will handle values outside its set gracefully and
|
||||
/// falls back to a default value when unknown.
|
||||
///
|
||||
/// If this property is not present, the client only supports the completion item kinds
|
||||
/// from Text to Reference as defined in the initial version of the protocol.
|
||||
/// </summary>
|
||||
public CompletionItemKinds? ValueSet { get; set; }
|
||||
}
|
||||
}
|
||||
14
external/Microsoft.SqlTools.DataProtocol.Contracts/ClientCapabilities/TextDocument/Definition.cs
vendored
Normal file
14
external/Microsoft.SqlTools.DataProtocol.Contracts/ClientCapabilities/TextDocument/Definition.cs
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
//
|
||||
// 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.DataProtocol.Contracts.ClientCapabilities.TextDocument
|
||||
{
|
||||
/// <summary>
|
||||
/// Capabilities specific to textDocument/definition requests
|
||||
/// </summary>
|
||||
public class DefinitionCapabilities : DynamicRegistrationCapability
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
//
|
||||
// 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.DataProtocol.Contracts.ClientCapabilities.TextDocument
|
||||
{
|
||||
/// <summary>
|
||||
/// Capabilities specific to textDocument/documentHighlight requests
|
||||
/// </summary>
|
||||
public class DocumentHighlightCapabilities : DynamicRegistrationCapability
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
//
|
||||
// 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.DataProtocol.Contracts.ClientCapabilities.TextDocument
|
||||
{
|
||||
/// <summary>
|
||||
/// Capabilities specific to textDocument/documentLink requests
|
||||
/// </summary>
|
||||
public class DocumentLinkCapabilities : DynamicRegistrationCapability
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
//
|
||||
// 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.DataProtocol.Contracts.Common;
|
||||
|
||||
namespace Microsoft.SqlTools.DataProtocol.Contracts.ClientCapabilities.TextDocument
|
||||
{
|
||||
/// <summary>
|
||||
/// Capabilities specific to textDocument/documentSymbol requests
|
||||
/// </summary>
|
||||
public class DocumentSymbolCapabilities : DynamicRegistrationCapability
|
||||
{
|
||||
/// <summary>
|
||||
/// Specific capabilities for the SymbolKind
|
||||
/// </summary>
|
||||
public DocumentSymbolKindCapabilities SymbolKind { get; set; }
|
||||
}
|
||||
|
||||
public class DocumentSymbolKindCapabilities
|
||||
{
|
||||
/// <summary>
|
||||
/// Symbol kind values the client supports. When this property exists, the client also
|
||||
/// guarantees that it will handle values outside its set gracefully and falls back to a
|
||||
/// default value when unknown.
|
||||
///
|
||||
/// If this property is not present, the client only supports the symbol kinds from File to
|
||||
/// Array as defined in the initial version of the protocol
|
||||
/// </summary>
|
||||
public SymbolKinds? ValueSet { get; set; }
|
||||
}
|
||||
}
|
||||
14
external/Microsoft.SqlTools.DataProtocol.Contracts/ClientCapabilities/TextDocument/Formatting.cs
vendored
Normal file
14
external/Microsoft.SqlTools.DataProtocol.Contracts/ClientCapabilities/TextDocument/Formatting.cs
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//w
|
||||
|
||||
namespace Microsoft.SqlTools.DataProtocol.Contracts.ClientCapabilities.TextDocument
|
||||
{
|
||||
/// <summary>
|
||||
/// Capabilities specific to textDocument/formatting requests
|
||||
/// </summary>
|
||||
public class FormattingCapabilities : DynamicRegistrationCapability
|
||||
{
|
||||
}
|
||||
}
|
||||
21
external/Microsoft.SqlTools.DataProtocol.Contracts/ClientCapabilities/TextDocument/Hover.cs
vendored
Normal file
21
external/Microsoft.SqlTools.DataProtocol.Contracts/ClientCapabilities/TextDocument/Hover.cs
vendored
Normal file
@@ -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.
|
||||
//
|
||||
|
||||
using Microsoft.SqlTools.DataProtocol.Contracts.Common;
|
||||
|
||||
namespace Microsoft.SqlTools.DataProtocol.Contracts.ClientCapabilities.TextDocument
|
||||
{
|
||||
/// <summary>
|
||||
/// Capabilities specific to textDocument/hover requests
|
||||
/// </summary>
|
||||
public class HoverCapabilities : DynamicRegistrationCapability
|
||||
{
|
||||
/// <summary>
|
||||
/// Client supports these content formats for the content property. The order describes
|
||||
/// the preferred format of the client.
|
||||
/// </summary>
|
||||
public MarkupKind[] ContentFormat { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
//
|
||||
// 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.DataProtocol.Contracts.ClientCapabilities.TextDocument
|
||||
{
|
||||
/// <summary>
|
||||
/// Capabilities specific to textDocument/implementation requests
|
||||
/// </summary>
|
||||
public class ImplementationCapabilities : DynamicRegistrationCapability
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
//
|
||||
// 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.DataProtocol.Contracts.ClientCapabilities.TextDocument
|
||||
{
|
||||
/// <summary>
|
||||
/// Capabilities specific to textDocument/onTypeFormatting requests
|
||||
/// </summary>
|
||||
public class OnTypeFormattingCapabilities : DynamicRegistrationCapability
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// 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.DataProtocol.Contracts.ClientCapabilities.TextDocument
|
||||
{
|
||||
/// <summary>
|
||||
/// Capabilities specific to textDocument/publishDiagnostics requests
|
||||
/// </summary>
|
||||
public class PublishDignosticsCapabilities
|
||||
{
|
||||
/// <summary>
|
||||
/// Whether the client accepts diagnostics with related information
|
||||
/// </summary>
|
||||
public bool? RelatedInformation { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
//
|
||||
// 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.DataProtocol.Contracts.ClientCapabilities.TextDocument
|
||||
{
|
||||
/// <summary>
|
||||
/// Capabilities specific to textDocument/rangeFormatting requests
|
||||
/// </summary>
|
||||
public class RangeFormattingCapabilities : DynamicRegistrationCapability
|
||||
{
|
||||
}
|
||||
}
|
||||
14
external/Microsoft.SqlTools.DataProtocol.Contracts/ClientCapabilities/TextDocument/References.cs
vendored
Normal file
14
external/Microsoft.SqlTools.DataProtocol.Contracts/ClientCapabilities/TextDocument/References.cs
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
//
|
||||
// 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.DataProtocol.Contracts.ClientCapabilities.TextDocument
|
||||
{
|
||||
/// <summary>
|
||||
/// Capabilities specific to textDocument/reference requests
|
||||
/// </summary>
|
||||
public class ReferencesCapabilities : DynamicRegistrationCapability
|
||||
{
|
||||
}
|
||||
}
|
||||
14
external/Microsoft.SqlTools.DataProtocol.Contracts/ClientCapabilities/TextDocument/Rename.cs
vendored
Normal file
14
external/Microsoft.SqlTools.DataProtocol.Contracts/ClientCapabilities/TextDocument/Rename.cs
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
//
|
||||
// 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.DataProtocol.Contracts.ClientCapabilities.TextDocument
|
||||
{
|
||||
/// <summary>
|
||||
/// Capabilities specific to textDocument/rename requests
|
||||
/// </summary>
|
||||
public class RenameCapabilities : DynamicRegistrationCapability
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
//
|
||||
// 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.DataProtocol.Contracts.Common;
|
||||
|
||||
namespace Microsoft.SqlTools.DataProtocol.Contracts.ClientCapabilities.TextDocument
|
||||
{
|
||||
/// <summary>
|
||||
/// Capabilities specific to textDocument/signatureHelp requests
|
||||
/// </summary>
|
||||
public class SignatureHelpCapabilities : DynamicRegistrationCapability
|
||||
{
|
||||
/// <summary>
|
||||
/// Client supports these SignatureInformation specific properties
|
||||
/// </summary>
|
||||
public SignatureInformationCapabilities SignatureInformation { get; set; }
|
||||
}
|
||||
|
||||
public class SignatureInformationCapabilities
|
||||
{
|
||||
/// <summary>
|
||||
/// Client supports these content formats for the documentation property. The order
|
||||
/// describes the preferred format of the client.
|
||||
/// </summary>
|
||||
public MarkupKind[] DocumentFormat { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -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.DataProtocol.Contracts.ClientCapabilities.TextDocument
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines which synchonization capabilities the client supports
|
||||
/// </summary>
|
||||
public class SynchronizationCapabilities : DynamicRegistrationCapability
|
||||
{
|
||||
/// <summary>
|
||||
/// Whether the client supports sending "will save" notifications
|
||||
/// </summary>
|
||||
public bool? WillSave { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether the client supports sending "did save" notifications
|
||||
/// </summary>
|
||||
public bool? DidSave { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
//
|
||||
// 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.DataProtocol.Contracts.ClientCapabilities.TextDocument
|
||||
{
|
||||
/// <summary>
|
||||
/// Text document specific client capabilities
|
||||
/// </summary>
|
||||
public class TextDocumentCapabilities
|
||||
{
|
||||
/// <summary>
|
||||
/// Capabilities specific to the textDocument/codeAction request. Can be <c>null</c>
|
||||
/// </summary>
|
||||
public CodeActionCapabilities CodeAction { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Capabilities specific to the colorProvider. Can be <c>null</c>
|
||||
/// </summary>
|
||||
public ColorProviderCapabilities ColorProvider { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Capabilities specific to the textDocument/completion request. Can be <c>null</c>
|
||||
/// </summary>
|
||||
public CompletionCapabilities Completion { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Capabilities specific to the textDocument/definition request. Can be <c>null</c>
|
||||
/// </summary>
|
||||
public DefinitionCapabilities Definition { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Capabilities specific to the textDocument/highlight request. Can be <c>null</c>
|
||||
/// </summary>
|
||||
public DocumentHighlightCapabilities DocumentHighlight { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Capabilities specific to the textDocument/documentLink request. Can be <c>null</c>
|
||||
/// </summary>
|
||||
public DocumentLinkCapabilities DocumentLink { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Capabilities specific to the textDocument/documentSymbol request. Can be <c>null</c>
|
||||
/// </summary>
|
||||
public DocumentSymbolCapabilities DocumentSymbol { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Capabilities specific to the textDocument/formatting request. Can be <c>null</c>
|
||||
/// </summary>
|
||||
public FormattingCapabilities Formatting { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Capabilities specific to the textDocument/hover request. Can be <c>null</c>
|
||||
/// </summary>
|
||||
public HoverCapabilities Hover { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Capabilities specific to the textDocument/implementation request. Can be <c>null</c>
|
||||
/// </summary>
|
||||
public ImplementationCapabilities Implementation { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Capabilities specific to the textDocument/onTypeFormatting request. Can be <c>null</c>
|
||||
/// </summary>
|
||||
public OnTypeFormattingCapabilities OnTypeFormatting { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Capabilities specific to the textDocument/publishDiagnostics request. Can be <c>null</c>
|
||||
/// </summary>
|
||||
public PublishDignosticsCapabilities PublishDiagnostics { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Capabilities specific to the textDocument/rangeFormatting request. Can be <c>null</c>
|
||||
/// </summary>
|
||||
public RangeFormattingCapabilities RangeFormatting { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Capabilities specific to the textDocument/references request. Can be <c>null</c>
|
||||
/// </summary>
|
||||
public ReferencesCapabilities References { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Capabilities specific to the textDocument/rename request. Can be <c>null</c>
|
||||
/// </summary>
|
||||
public RenameCapabilities Rename { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Capabilities specific to the textDocument/signatureHelp request. Can be <c>null</c>
|
||||
/// </summary>
|
||||
public SignatureHelpCapabilities SignatureHelp { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Defines which synchronization capabilities the client supports. Can be <c>null</c>
|
||||
/// </summary>
|
||||
public SynchronizationCapabilities Synchronization { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Capabilities specific to the textDocument/typeDefinition requests. Can be <c>null</c>
|
||||
/// </summary>
|
||||
public TypeDefinitionCapabilities TypeDefinition { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
//
|
||||
// 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.DataProtocol.Contracts.ClientCapabilities.TextDocument
|
||||
{
|
||||
/// <summary>
|
||||
/// Capabilities specific to textDocument/typeDefinition requests
|
||||
/// </summary>
|
||||
public class TypeDefinitionCapabilities : DynamicRegistrationCapability
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
//
|
||||
// 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.DataProtocol.Contracts.ClientCapabilities.Workspace
|
||||
{
|
||||
/// <summary>
|
||||
/// Capabilities specific to the workspace/didChangeConfiguration notification
|
||||
/// </summary>
|
||||
public class DidChangeConfigurationCapabilities : DynamicRegistrationCapability
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
//
|
||||
// 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.DataProtocol.Contracts.ClientCapabilities.Workspace
|
||||
{
|
||||
/// <summary>
|
||||
/// Capabilities specific to the workspace/didChangeWatchedFiles notificiation
|
||||
/// </summary>
|
||||
public class DidChangeWatchedFilesCapabilities : DynamicRegistrationCapability
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
//
|
||||
// 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.DataProtocol.Contracts.ClientCapabilities.Workspace
|
||||
{
|
||||
/// <summary>
|
||||
/// Capabilities specific to the workspace/executeCommand request
|
||||
/// </summary>
|
||||
public class ExecuteCommandCapabilities : DynamicRegistrationCapability
|
||||
{
|
||||
}
|
||||
}
|
||||
37
external/Microsoft.SqlTools.DataProtocol.Contracts/ClientCapabilities/Workspace/Symbol.cs
vendored
Normal file
37
external/Microsoft.SqlTools.DataProtocol.Contracts/ClientCapabilities/Workspace/Symbol.cs
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
//
|
||||
// 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.DataProtocol.Contracts.Common;
|
||||
|
||||
namespace Microsoft.SqlTools.DataProtocol.Contracts.ClientCapabilities.Workspace
|
||||
{
|
||||
/// <summary>
|
||||
/// Capabilities specific to the workspace/symbol request
|
||||
/// </summary>
|
||||
public class SymbolCapabilities : DynamicRegistrationCapability
|
||||
{
|
||||
/// <summary>
|
||||
/// Specific capabilities for the SymbolKind in a workspace/symbol request. Can be
|
||||
/// <c>null</c>
|
||||
/// </summary>
|
||||
public SymbolKindCapabilities SymbolKind { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Specific capabilities for the SymbolKind in a workspace/symbol request
|
||||
/// </summary>
|
||||
public class SymbolKindCapabilities
|
||||
{
|
||||
/// <summary>
|
||||
/// The symbol kind values the client supports. When this property exists, the client also
|
||||
/// guarantees that it will handle values outside its set gracefully and falls back to a
|
||||
/// default value when unknown.
|
||||
///
|
||||
/// If this property is not present the client only supports the symbol kinds from File to
|
||||
/// Array as defined in the initial version of the protocol.
|
||||
/// </summary>
|
||||
public SymbolKinds? ValueSet { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
//
|
||||
// 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.DataProtocol.Contracts.ClientCapabilities.Workspace
|
||||
{
|
||||
/// <summary>
|
||||
/// Workspace specific client capabilities
|
||||
/// </summary>
|
||||
public class WorkspaceCapabilities
|
||||
{
|
||||
/// <summary>
|
||||
/// Client support applying batche edits to the workspace by supporting the
|
||||
/// workspace/applyEdit request
|
||||
/// </summary>
|
||||
public bool? ApplyEdit { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether the client supports workspace/configuration requests
|
||||
/// </summary>
|
||||
public bool? Configuration { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Capabilities specific to the workspace/didChangeConfiguration notification. Can be
|
||||
/// <c>null</c>
|
||||
/// </summary>
|
||||
public DidChangeConfigurationCapabilities DidChangeConfiguration { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Capabilities specific to the workspace/executeCommand request. Can be <c>null</c>
|
||||
/// </summary>
|
||||
public ExecuteCommandCapabilities ExecuteCommand { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Capabilities specific to the workspace/didChangeWatchedFiles notificiation. Can be
|
||||
/// <c>null</c>
|
||||
/// </summary>
|
||||
public DidChangeWatchedFilesCapabilities DidChangeWatchedFiles { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Capabilities specific to the workspace/symbol request. Can be <c>null</c>
|
||||
/// </summary>
|
||||
public SymbolCapabilities Symbol { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Capabilities specific to WorkspaceEdit requests
|
||||
/// </summary>
|
||||
public WorkspaceEditCapabilities WorkspaceEdit { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether the client supports multiple workspace folders open at a time. If true, the
|
||||
/// open workspace folders will be provided during initialization via
|
||||
/// <see cref="InitializeRequest{TInitializationOptions}.WorkspaceFolders"/>
|
||||
/// </summary>
|
||||
public bool? WorkspaceFolders { get; set; }
|
||||
}
|
||||
}
|
||||
18
external/Microsoft.SqlTools.DataProtocol.Contracts/ClientCapabilities/Workspace/WorkspaceEdit.cs
vendored
Normal file
18
external/Microsoft.SqlTools.DataProtocol.Contracts/ClientCapabilities/Workspace/WorkspaceEdit.cs
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// 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.DataProtocol.Contracts.ClientCapabilities.Workspace
|
||||
{
|
||||
/// <summary>
|
||||
/// Capabilities specific to WorkspaceEdit requests
|
||||
/// </summary>
|
||||
public class WorkspaceEditCapabilities
|
||||
{
|
||||
/// <summary>
|
||||
/// Whether the client supports versioned document changes in WorkspaceEdit requests
|
||||
/// </summary>
|
||||
public bool? DocumentChanges { get; set; }
|
||||
}
|
||||
}
|
||||
91
external/Microsoft.SqlTools.DataProtocol.Contracts/Common/CompletionItemKind.cs
vendored
Normal file
91
external/Microsoft.SqlTools.DataProtocol.Contracts/Common/CompletionItemKind.cs
vendored
Normal file
@@ -0,0 +1,91 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using System;
|
||||
using Microsoft.SqlTools.DataProtocol.Contracts.Utilities;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Microsoft.SqlTools.DataProtocol.Contracts.Common
|
||||
{
|
||||
[Flags]
|
||||
[JsonConverter(typeof(FlagsIntConverter))]
|
||||
public enum CompletionItemKinds
|
||||
{
|
||||
[FlagsIntConverter.SerializeValue(1)]
|
||||
Text = 1 << 0,
|
||||
|
||||
[FlagsIntConverter.SerializeValue(2)]
|
||||
Method = 1 << 1,
|
||||
|
||||
[FlagsIntConverter.SerializeValue(3)]
|
||||
Function = 1 << 2,
|
||||
|
||||
[FlagsIntConverter.SerializeValue(4)]
|
||||
Constructor = 1 << 3,
|
||||
|
||||
[FlagsIntConverter.SerializeValue(5)]
|
||||
Field = 1 << 4,
|
||||
|
||||
[FlagsIntConverter.SerializeValue(6)]
|
||||
Variable = 1 << 5,
|
||||
|
||||
[FlagsIntConverter.SerializeValue(7)]
|
||||
Class = 1 << 6,
|
||||
|
||||
[FlagsIntConverter.SerializeValue(8)]
|
||||
Interface = 1 << 7,
|
||||
|
||||
[FlagsIntConverter.SerializeValue(9)]
|
||||
Module = 1 << 8,
|
||||
|
||||
[FlagsIntConverter.SerializeValue(10)]
|
||||
Property = 1 << 9,
|
||||
|
||||
[FlagsIntConverter.SerializeValue(11)]
|
||||
Unit = 1 << 10,
|
||||
|
||||
[FlagsIntConverter.SerializeValue(12)]
|
||||
Value = 1 << 11,
|
||||
|
||||
[FlagsIntConverter.SerializeValue(13)]
|
||||
Enum = 1 << 12,
|
||||
|
||||
[FlagsIntConverter.SerializeValue(14)]
|
||||
Keyword = 1 << 13,
|
||||
|
||||
[FlagsIntConverter.SerializeValue(15)]
|
||||
Snippet = 1 << 14,
|
||||
|
||||
[FlagsIntConverter.SerializeValue(16)]
|
||||
Color = 1 << 15,
|
||||
|
||||
[FlagsIntConverter.SerializeValue(17)]
|
||||
File = 1 << 16,
|
||||
|
||||
[FlagsIntConverter.SerializeValue(18)]
|
||||
Reference = 1 << 17,
|
||||
|
||||
[FlagsIntConverter.SerializeValue(19)]
|
||||
Folder = 1 << 18,
|
||||
|
||||
[FlagsIntConverter.SerializeValue(20)]
|
||||
EnumMember = 1 << 19,
|
||||
|
||||
[FlagsIntConverter.SerializeValue(21)]
|
||||
Constant = 1 << 20,
|
||||
|
||||
[FlagsIntConverter.SerializeValue(22)]
|
||||
Struct = 1 << 21,
|
||||
|
||||
[FlagsIntConverter.SerializeValue(23)]
|
||||
Event = 1 << 22,
|
||||
|
||||
[FlagsIntConverter.SerializeValue(24)]
|
||||
Operator = 1 << 23,
|
||||
|
||||
[FlagsIntConverter.SerializeValue(25)]
|
||||
TypeParameter = 1 << 24
|
||||
}
|
||||
}
|
||||
24
external/Microsoft.SqlTools.DataProtocol.Contracts/Common/MarkupKind.cs
vendored
Normal file
24
external/Microsoft.SqlTools.DataProtocol.Contracts/Common/MarkupKind.cs
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
namespace Microsoft.SqlTools.DataProtocol.Contracts.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// Describes the content type that a client supports in various result literals like Hover,
|
||||
/// ParameterInfo, or CompletionItem.
|
||||
///
|
||||
/// Please note that MarkupKinds must not start with a '$'. These kinds are reserved for
|
||||
/// internal usage.
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public enum MarkupKind
|
||||
{
|
||||
PlainText = 1,
|
||||
Markdown = 2
|
||||
}
|
||||
}
|
||||
94
external/Microsoft.SqlTools.DataProtocol.Contracts/Common/SymbolKinds.cs
vendored
Normal file
94
external/Microsoft.SqlTools.DataProtocol.Contracts/Common/SymbolKinds.cs
vendored
Normal file
@@ -0,0 +1,94 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using System;
|
||||
using Microsoft.SqlTools.DataProtocol.Contracts.Utilities;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Microsoft.SqlTools.DataProtocol.Contracts.Common
|
||||
{
|
||||
[Flags]
|
||||
[JsonConverter(typeof(FlagsIntConverter))]
|
||||
public enum SymbolKinds
|
||||
{
|
||||
[FlagsIntConverter.SerializeValue(1)]
|
||||
File = 1 << 0,
|
||||
|
||||
[FlagsIntConverter.SerializeValue(2)]
|
||||
Module = 1 << 1,
|
||||
|
||||
[FlagsIntConverter.SerializeValue(3)]
|
||||
Namespace = 1 << 2,
|
||||
|
||||
[FlagsIntConverter.SerializeValue(4)]
|
||||
Package = 1 << 3,
|
||||
|
||||
[FlagsIntConverter.SerializeValue(5)]
|
||||
Class = 1 << 4,
|
||||
|
||||
[FlagsIntConverter.SerializeValue(6)]
|
||||
Method = 1 << 5,
|
||||
|
||||
[FlagsIntConverter.SerializeValue(7)]
|
||||
Property = 1 << 6,
|
||||
|
||||
[FlagsIntConverter.SerializeValue(8)]
|
||||
Field = 1 << 7,
|
||||
|
||||
[FlagsIntConverter.SerializeValue(9)]
|
||||
Constructor = 1 << 8,
|
||||
|
||||
[FlagsIntConverter.SerializeValue(10)]
|
||||
Enum = 1 << 9,
|
||||
|
||||
[FlagsIntConverter.SerializeValue(11)]
|
||||
Interface = 1 << 10,
|
||||
|
||||
[FlagsIntConverter.SerializeValue(12)]
|
||||
Function = 1 << 11,
|
||||
|
||||
[FlagsIntConverter.SerializeValue(13)]
|
||||
Variable = 1 << 12,
|
||||
|
||||
[FlagsIntConverter.SerializeValue(14)]
|
||||
Constant = 1 << 13,
|
||||
|
||||
[FlagsIntConverter.SerializeValue(15)]
|
||||
String = 1 << 14,
|
||||
|
||||
[FlagsIntConverter.SerializeValue(16)]
|
||||
Number = 1 << 15,
|
||||
|
||||
[FlagsIntConverter.SerializeValue(17)]
|
||||
Boolean = 1 << 16,
|
||||
|
||||
[FlagsIntConverter.SerializeValue(18)]
|
||||
Array = 1 << 17,
|
||||
|
||||
[FlagsIntConverter.SerializeValue(19)]
|
||||
Object = 1 << 18,
|
||||
|
||||
[FlagsIntConverter.SerializeValue(20)]
|
||||
Key = 1 << 19,
|
||||
|
||||
[FlagsIntConverter.SerializeValue(21)]
|
||||
Null = 1 << 20,
|
||||
|
||||
[FlagsIntConverter.SerializeValue(22)]
|
||||
EnumMember = 1 << 21,
|
||||
|
||||
[FlagsIntConverter.SerializeValue(23)]
|
||||
Struct = 1 << 22,
|
||||
|
||||
[FlagsIntConverter.SerializeValue(24)]
|
||||
Event = 1 << 23,
|
||||
|
||||
[FlagsIntConverter.SerializeValue(25)]
|
||||
Operator = 1 << 24,
|
||||
|
||||
[FlagsIntConverter.SerializeValue(26)]
|
||||
TypeParameter = 1 << 25
|
||||
}
|
||||
}
|
||||
20
external/Microsoft.SqlTools.DataProtocol.Contracts/Common/WorkspaceFolder.cs
vendored
Normal file
20
external/Microsoft.SqlTools.DataProtocol.Contracts/Common/WorkspaceFolder.cs
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// 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.DataProtocol.Contracts.Common
|
||||
{
|
||||
public class WorkspaceFolder
|
||||
{
|
||||
/// <summary>
|
||||
/// Name of the workspace folder. Defaults to <see cref="Uri"/>'s basename
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Associated URI for this workspace folder
|
||||
/// </summary>
|
||||
public string Uri { get; set; }
|
||||
}
|
||||
}
|
||||
24
external/Microsoft.SqlTools.DataProtocol.Contracts/Connection/CancelConnectParams.cs
vendored
Normal file
24
external/Microsoft.SqlTools.DataProtocol.Contracts/Connection/CancelConnectParams.cs
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// 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.DataProtocol.Contracts.Connection
|
||||
{
|
||||
/// <summary>
|
||||
/// Parameters for the Cancel Connect Request.
|
||||
/// </summary>
|
||||
public class CancelConnectParams
|
||||
{
|
||||
/// <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>
|
||||
/// The type of connection we are trying to cancel
|
||||
/// </summary>
|
||||
public string Type { get; set; } = ConnectionType.Default;
|
||||
}
|
||||
}
|
||||
19
external/Microsoft.SqlTools.DataProtocol.Contracts/Connection/CancelConnectRequest.cs
vendored
Normal file
19
external/Microsoft.SqlTools.DataProtocol.Contracts/Connection/CancelConnectRequest.cs
vendored
Normal file
@@ -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.Hosting.Contracts;
|
||||
|
||||
namespace Microsoft.SqlTools.DataProtocol.Contracts.Connection
|
||||
{
|
||||
/// <summary>
|
||||
/// Cancel connect request mapping entry
|
||||
/// </summary>
|
||||
public class CancelConnectRequest
|
||||
{
|
||||
public static readonly
|
||||
RequestType<CancelConnectParams, bool> Type =
|
||||
RequestType<CancelConnectParams, bool>.Create("connection/cancelconnect");
|
||||
}
|
||||
}
|
||||
23
external/Microsoft.SqlTools.DataProtocol.Contracts/Connection/ChangeDatabaseParams.cs
vendored
Normal file
23
external/Microsoft.SqlTools.DataProtocol.Contracts/Connection/ChangeDatabaseParams.cs
vendored
Normal file
@@ -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.DataProtocol.Contracts.Connection
|
||||
{
|
||||
/// <summary>
|
||||
/// Parameters for the List Databases Request.
|
||||
/// </summary>
|
||||
public class ChangeDatabaseParams
|
||||
{
|
||||
/// <summary>
|
||||
/// URI of the owner of the connection requesting the list of databases.
|
||||
/// </summary>
|
||||
public string OwnerUri { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The database to change to
|
||||
/// </summary>
|
||||
public string NewDatabase { get; set; }
|
||||
}
|
||||
}
|
||||
19
external/Microsoft.SqlTools.DataProtocol.Contracts/Connection/ChangeDatabaseRequest.cs
vendored
Normal file
19
external/Microsoft.SqlTools.DataProtocol.Contracts/Connection/ChangeDatabaseRequest.cs
vendored
Normal file
@@ -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.Hosting.Contracts;
|
||||
|
||||
namespace Microsoft.SqlTools.DataProtocol.Contracts.Connection
|
||||
{
|
||||
/// <summary>
|
||||
/// List databases request mapping entry
|
||||
/// </summary>
|
||||
public class ChangeDatabaseRequest
|
||||
{
|
||||
public static readonly
|
||||
RequestType<ChangeDatabaseParams, bool> Type =
|
||||
RequestType<ChangeDatabaseParams, bool>.Create("connection/changedatabase");
|
||||
}
|
||||
}
|
||||
37
external/Microsoft.SqlTools.DataProtocol.Contracts/Connection/ConnectParams.cs
vendored
Normal file
37
external/Microsoft.SqlTools.DataProtocol.Contracts/Connection/ConnectParams.cs
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
//
|
||||
// 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.DataProtocol.Contracts.Connection
|
||||
{
|
||||
/// <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>
|
||||
/// The type of this connection. By default, this is set to ConnectionType.Default.
|
||||
/// </summary>
|
||||
public string Type { get; set; } = ConnectionType.Default;
|
||||
|
||||
/// <summary>
|
||||
/// The porpose of the connection to keep track of open connections
|
||||
/// </summary>
|
||||
public string Purpose { get; set; } = ConnectionType.GeneralConnection;
|
||||
}
|
||||
}
|
||||
19
external/Microsoft.SqlTools.DataProtocol.Contracts/Connection/ConnectionChangedNotification.cs
vendored
Normal file
19
external/Microsoft.SqlTools.DataProtocol.Contracts/Connection/ConnectionChangedNotification.cs
vendored
Normal file
@@ -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.Hosting.Contracts;
|
||||
|
||||
namespace Microsoft.SqlTools.DataProtocol.Contracts.Connection
|
||||
{
|
||||
/// <summary>
|
||||
/// ConnectionChanged notification mapping entry
|
||||
/// </summary>
|
||||
public class ConnectionChangedNotification
|
||||
{
|
||||
public static readonly
|
||||
EventType<ConnectionChangedParams> Type =
|
||||
EventType<ConnectionChangedParams>.Create("connection/connectionchanged");
|
||||
}
|
||||
}
|
||||
23
external/Microsoft.SqlTools.DataProtocol.Contracts/Connection/ConnectionChangedParams.cs
vendored
Normal file
23
external/Microsoft.SqlTools.DataProtocol.Contracts/Connection/ConnectionChangedParams.cs
vendored
Normal file
@@ -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.DataProtocol.Contracts.Connection
|
||||
{
|
||||
/// <summary>
|
||||
/// Parameters for the ConnectionChanged Notification.
|
||||
/// </summary>
|
||||
public class ConnectionChangedParams
|
||||
{
|
||||
/// <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 high-level properties about the connection, for display to the user.
|
||||
/// </summary>
|
||||
public ConnectionSummary Connection { get; set; }
|
||||
}
|
||||
}
|
||||
66
external/Microsoft.SqlTools.DataProtocol.Contracts/Connection/ConnectionCompleteNotification.cs
vendored
Normal file
66
external/Microsoft.SqlTools.DataProtocol.Contracts/Connection/ConnectionCompleteNotification.cs
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
//
|
||||
// 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.Hosting.Contracts;
|
||||
|
||||
namespace Microsoft.SqlTools.DataProtocol.Contracts.Connection
|
||||
{
|
||||
/// <summary>
|
||||
/// Parameters to be sent back with a connection complete event
|
||||
/// </summary>
|
||||
public class ConnectionCompleteParams
|
||||
{
|
||||
/// <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>
|
||||
/// A GUID representing a unique connection ID
|
||||
/// </summary>
|
||||
public string ConnectionId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets any detailed connection error messages.
|
||||
/// </summary>
|
||||
public string Messages { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Error message returned from the engine for a connection failure reason, if any.
|
||||
/// </summary>
|
||||
public string ErrorMessage { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Error number returned from the engine for connection failure reason, if any.
|
||||
/// </summary>
|
||||
public int ErrorNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Information about the connected server.
|
||||
/// </summary>
|
||||
public ServerInfo ServerInfo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the actual Connection established, including Database Name
|
||||
/// </summary>
|
||||
public ConnectionSummary ConnectionSummary { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The type of connection that this notification is for
|
||||
/// </summary>
|
||||
public string Type { get; set; } = ConnectionType.Default;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ConnectionComplete notification mapping entry
|
||||
/// </summary>
|
||||
public class ConnectionCompleteNotification
|
||||
{
|
||||
public static readonly
|
||||
EventType<ConnectionCompleteParams> Type =
|
||||
EventType<ConnectionCompleteParams>.Create("connection/complete");
|
||||
}
|
||||
}
|
||||
525
external/Microsoft.SqlTools.DataProtocol.Contracts/Connection/ConnectionDetails.cs
vendored
Normal file
525
external/Microsoft.SqlTools.DataProtocol.Contracts/Connection/ConnectionDetails.cs
vendored
Normal file
@@ -0,0 +1,525 @@
|
||||
//
|
||||
// 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.DataProtocol.Contracts.Connection
|
||||
{
|
||||
/// <summary>
|
||||
/// Message format for the initial connection request
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// If this contract is ever changed, be sure to update ConnectionDetailsExtensions methods.
|
||||
/// </remarks>
|
||||
public class ConnectionDetails : GeneralRequestDetails, IConnectionSummary
|
||||
{
|
||||
public ConnectionDetails() : base()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the connection password
|
||||
/// </summary>
|
||||
public string Password
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetOptionValue<string>("password");
|
||||
}
|
||||
set
|
||||
{
|
||||
SetOptionValue("password", value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the connection server name
|
||||
/// </summary>
|
||||
public string ServerName
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetOptionValue<string>("server");
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
SetOptionValue("server", value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the connection database name
|
||||
/// </summary>
|
||||
public string DatabaseName
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetOptionValue<string>("database");
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
SetOptionValue("database", value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the connection user name
|
||||
/// </summary>
|
||||
public string UserName
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetOptionValue<string>("user");
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
SetOptionValue("user", value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the authentication to use.
|
||||
/// </summary>
|
||||
public string AuthenticationType
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetOptionValue<string>("authenticationType");
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
SetOptionValue("authenticationType", value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a Boolean value that indicates whether SQL Server uses SSL encryption for all data sent between the client and server if the server has a certificate installed.
|
||||
/// </summary>
|
||||
public bool? Encrypt
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetOptionValue<bool?>("encrypt");
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
SetOptionValue("encrypt", value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value that indicates whether the channel will be encrypted while bypassing walking the certificate chain to validate trust.
|
||||
/// </summary>
|
||||
public bool? TrustServerCertificate
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetOptionValue<bool?>("trustServerCertificate");
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
SetOptionValue("trustServerCertificate", value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a Boolean value that indicates if security-sensitive information, such as the password, is not returned as part of the connection if the connection is open or has ever been in an open state.
|
||||
/// </summary>
|
||||
public bool? PersistSecurityInfo
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetOptionValue<bool?>("persistSecurityInfo");
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
SetOptionValue("persistSecurityInfo", value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the length of time (in seconds) to wait for a connection to the server before terminating the attempt and generating an error.
|
||||
/// </summary>
|
||||
public int? ConnectTimeout
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetOptionValue<int?>("connectTimeout");
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
SetOptionValue("connectTimeout", value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The number of reconnections attempted after identifying that there was an idle connection failure.
|
||||
/// </summary>
|
||||
public int? ConnectRetryCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetOptionValue<int?>("connectRetryCount");
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
SetOptionValue("connectRetryCount", value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Amount of time (in seconds) between each reconnection attempt after identifying that there was an idle connection failure.
|
||||
/// </summary>
|
||||
public int? ConnectRetryInterval
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetOptionValue<int?>("connectRetryInterval");
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
SetOptionValue("connectRetryInterval", value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the application associated with the connection string.
|
||||
/// </summary>
|
||||
public string ApplicationName
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetOptionValue<string>("applicationName");
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
SetOptionValue("applicationName", value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the workstation connecting to SQL Server.
|
||||
/// </summary>
|
||||
public string WorkstationId
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetOptionValue<string>("workstationId");
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
SetOptionValue("workstationId", value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Declares the application workload type when connecting to a database in an SQL Server Availability Group.
|
||||
/// </summary>
|
||||
public string ApplicationIntent
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetOptionValue<string>("applicationIntent");
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
SetOptionValue("applicationIntent", value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the SQL Server Language record name.
|
||||
/// </summary>
|
||||
public string CurrentLanguage
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetOptionValue<string>("currentLanguage");
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
SetOptionValue("currentLanguage", value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a Boolean value that indicates whether the connection will be pooled or explicitly opened every time that the connection is requested.
|
||||
/// </summary>
|
||||
public bool? Pooling
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetOptionValue<bool?>("pooling");
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
SetOptionValue("pooling", value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the maximum number of connections allowed in the connection pool for this specific connection string.
|
||||
/// </summary>
|
||||
public int? MaxPoolSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetOptionValue<int?>("maxPoolSize");
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
SetOptionValue("maxPoolSize", value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the minimum number of connections allowed in the connection pool for this specific connection string.
|
||||
/// </summary>
|
||||
public int? MinPoolSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetOptionValue<int?>("minPoolSize");
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
SetOptionValue("minPoolSize", value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the minimum time, in seconds, for the connection to live in the connection pool before being destroyed.
|
||||
/// </summary>
|
||||
public int? LoadBalanceTimeout
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetOptionValue<int?>("loadBalanceTimeout");
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
SetOptionValue("loadBalanceTimeout", value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a Boolean value that indicates whether replication is supported using the connection.
|
||||
/// </summary>
|
||||
public bool? Replication
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetOptionValue<bool?>("replication");
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
SetOptionValue("replication", value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a string that contains the name of the primary data file. This includes the full path name of an attachable database.
|
||||
/// </summary>
|
||||
public string AttachDbFilename
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetOptionValue<string>("attachDbFilename");
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
SetOptionValue("attachDbFilename", value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name or address of the partner server to connect to if the primary server is down.
|
||||
/// </summary>
|
||||
public string FailoverPartner
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetOptionValue<string>("failoverPartner");
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
SetOptionValue("failoverPartner", value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// If your application is connecting to an AlwaysOn availability group (AG) on different subnets, setting MultiSubnetFailover=true provides faster detection of and connection to the (currently) active server.
|
||||
/// </summary>
|
||||
public bool? MultiSubnetFailover
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetOptionValue<bool?>("multiSubnetFailover");
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
SetOptionValue("multiSubnetFailover", value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When true, an application can maintain multiple active result sets (MARS).
|
||||
/// </summary>
|
||||
public bool? MultipleActiveResultSets
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetOptionValue<bool?>("multipleActiveResultSets");
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
SetOptionValue("multipleActiveResultSets", value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the size in bytes of the network packets used to communicate with an instance of SQL Server.
|
||||
/// </summary>
|
||||
public int? PacketSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetOptionValue<int?>("packetSize");
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
SetOptionValue("packetSize", value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the port to use for the TCP/IP connection
|
||||
/// </summary>
|
||||
public int? Port
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetOptionValue<int?>("port");
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
SetOptionValue("port", value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a string value that indicates the type system the application expects.
|
||||
/// </summary>
|
||||
public string TypeSystemVersion
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetOptionValue<string>("typeSystemVersion");
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
SetOptionValue("typeSystemVersion", value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a string value to be used as the connection string. If given, all other options will be ignored.
|
||||
/// </summary>
|
||||
public string ConnectionString
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetOptionValue<string>("connectionString");
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
SetOptionValue("connectionString", value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the group ID
|
||||
/// </summary>
|
||||
public string GroupId
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetOptionValue<string>("groupId");
|
||||
}
|
||||
set
|
||||
{
|
||||
SetOptionValue("groupId", value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the database display name
|
||||
/// </summary>
|
||||
public string DatabaseDisplayName
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetOptionValue<string>("databaseDisplayName");
|
||||
}
|
||||
set
|
||||
{
|
||||
SetOptionValue("databaseDisplayName", value);
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsComparableTo(ConnectionDetails other)
|
||||
{
|
||||
if (other == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ServerName != other.ServerName
|
||||
|| AuthenticationType != other.AuthenticationType
|
||||
|| UserName != other.UserName)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// For database name, only compare if neither is empty. This is important
|
||||
// Since it allows for handling of connections to the default database, but is
|
||||
// not a 100% accurate heuristic.
|
||||
if (!string.IsNullOrEmpty(DatabaseName)
|
||||
&& !string.IsNullOrEmpty(other.DatabaseName)
|
||||
&& DatabaseName != other.DatabaseName)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
51
external/Microsoft.SqlTools.DataProtocol.Contracts/Connection/ConnectionDetailsExtensions.cs
vendored
Normal file
51
external/Microsoft.SqlTools.DataProtocol.Contracts/Connection/ConnectionDetailsExtensions.cs
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
//
|
||||
// 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.DataProtocol.Contracts.Connection
|
||||
{
|
||||
/// <summary>
|
||||
/// Extension methods for the ConnectionDetails contract class
|
||||
/// </summary>
|
||||
public static class ConnectionDetailsExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Create a copy of a connection details object.
|
||||
/// </summary>
|
||||
public static ConnectionDetails Clone(this ConnectionDetails details)
|
||||
{
|
||||
return new ConnectionDetails()
|
||||
{
|
||||
ServerName = details.ServerName,
|
||||
DatabaseName = details.DatabaseName,
|
||||
UserName = details.UserName,
|
||||
Password = details.Password,
|
||||
AuthenticationType = details.AuthenticationType,
|
||||
Encrypt = details.Encrypt,
|
||||
TrustServerCertificate = details.TrustServerCertificate,
|
||||
PersistSecurityInfo = details.PersistSecurityInfo,
|
||||
ConnectTimeout = details.ConnectTimeout,
|
||||
ConnectRetryCount = details.ConnectRetryCount,
|
||||
ConnectRetryInterval = details.ConnectRetryInterval,
|
||||
ApplicationName = details.ApplicationName,
|
||||
WorkstationId = details.WorkstationId,
|
||||
ApplicationIntent = details.ApplicationIntent,
|
||||
CurrentLanguage = details.CurrentLanguage,
|
||||
Pooling = details.Pooling,
|
||||
MaxPoolSize = details.MaxPoolSize,
|
||||
MinPoolSize = details.MinPoolSize,
|
||||
LoadBalanceTimeout = details.LoadBalanceTimeout,
|
||||
Replication = details.Replication,
|
||||
AttachDbFilename = details.AttachDbFilename,
|
||||
FailoverPartner = details.FailoverPartner,
|
||||
MultiSubnetFailover = details.MultiSubnetFailover,
|
||||
MultipleActiveResultSets = details.MultipleActiveResultSets,
|
||||
PacketSize = details.PacketSize,
|
||||
TypeSystemVersion = details.TypeSystemVersion,
|
||||
ConnectionString = details.ConnectionString,
|
||||
Port = details.Port
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
19
external/Microsoft.SqlTools.DataProtocol.Contracts/Connection/ConnectionRequest.cs
vendored
Normal file
19
external/Microsoft.SqlTools.DataProtocol.Contracts/Connection/ConnectionRequest.cs
vendored
Normal file
@@ -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.Hosting.Contracts;
|
||||
|
||||
namespace Microsoft.SqlTools.DataProtocol.Contracts.Connection
|
||||
{
|
||||
/// <summary>
|
||||
/// Connect request mapping entry
|
||||
/// </summary>
|
||||
public class ConnectionRequest
|
||||
{
|
||||
public static readonly
|
||||
RequestType<ConnectParams, bool> Type =
|
||||
RequestType<ConnectParams, bool>.Create("connection/connect");
|
||||
}
|
||||
}
|
||||
48
external/Microsoft.SqlTools.DataProtocol.Contracts/Connection/ConnectionSummary.cs
vendored
Normal file
48
external/Microsoft.SqlTools.DataProtocol.Contracts/Connection/ConnectionSummary.cs
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
//
|
||||
// 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.DataProtocol.Contracts.Connection
|
||||
{
|
||||
|
||||
public interface IConnectionSummary
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the connection server name
|
||||
/// </summary>
|
||||
string ServerName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the connection database name
|
||||
/// </summary>
|
||||
string DatabaseName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the connection user name
|
||||
/// </summary>
|
||||
string UserName { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Provides high level information about a connection.
|
||||
/// </summary>
|
||||
public class ConnectionSummary : IConnectionSummary
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the connection server name
|
||||
/// </summary>
|
||||
public virtual string ServerName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the connection database name
|
||||
/// </summary>
|
||||
public virtual string DatabaseName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the connection user name
|
||||
/// </summary>
|
||||
public virtual string UserName { get; set; }
|
||||
}
|
||||
}
|
||||
53
external/Microsoft.SqlTools.DataProtocol.Contracts/Connection/ConnectionSummaryComparer.cs
vendored
Normal file
53
external/Microsoft.SqlTools.DataProtocol.Contracts/Connection/ConnectionSummaryComparer.cs
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.SqlTools.DataProtocol.Contracts.Connection
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Treats connections as the same if their server, db and usernames all match
|
||||
/// </summary>
|
||||
public class ConnectionSummaryComparer : IEqualityComparer<ConnectionSummary>
|
||||
{
|
||||
public bool Equals(ConnectionSummary x, ConnectionSummary y)
|
||||
{
|
||||
if(x == y) { return true; }
|
||||
else if(x != null)
|
||||
{
|
||||
if(y == null) { return false; }
|
||||
|
||||
// Compare server, db, username. Note: server is case-insensitive in the driver
|
||||
return string.Compare(x.ServerName, y.ServerName, StringComparison.OrdinalIgnoreCase) == 0
|
||||
&& string.Compare(x.DatabaseName, y.DatabaseName, StringComparison.Ordinal) == 0
|
||||
&& string.Compare(x.UserName, y.UserName, StringComparison.Ordinal) == 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public int GetHashCode(ConnectionSummary obj)
|
||||
{
|
||||
int hashcode = 31;
|
||||
if(obj != null)
|
||||
{
|
||||
if(obj.ServerName != null)
|
||||
{
|
||||
hashcode ^= obj.ServerName.GetHashCode();
|
||||
}
|
||||
if (obj.DatabaseName != null)
|
||||
{
|
||||
hashcode ^= obj.DatabaseName.GetHashCode();
|
||||
}
|
||||
if (obj.UserName != null)
|
||||
{
|
||||
hashcode ^= obj.UserName.GetHashCode();
|
||||
}
|
||||
}
|
||||
return hashcode;
|
||||
}
|
||||
}
|
||||
}
|
||||
26
external/Microsoft.SqlTools.DataProtocol.Contracts/Connection/ConnectionSummaryExtensions.cs
vendored
Normal file
26
external/Microsoft.SqlTools.DataProtocol.Contracts/Connection/ConnectionSummaryExtensions.cs
vendored
Normal file
@@ -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.DataProtocol.Contracts.Connection
|
||||
{
|
||||
/// <summary>
|
||||
/// Extension methods to ConnectionSummary
|
||||
/// </summary>
|
||||
public static class ConnectionSummaryExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Create a copy of a ConnectionSummary object
|
||||
/// </summary>
|
||||
public static ConnectionSummary Clone(this IConnectionSummary summary)
|
||||
{
|
||||
return new ConnectionSummary()
|
||||
{
|
||||
ServerName = summary.ServerName,
|
||||
DatabaseName = summary.DatabaseName,
|
||||
UserName = summary.UserName
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
23
external/Microsoft.SqlTools.DataProtocol.Contracts/Connection/ConnectionType.cs
vendored
Normal file
23
external/Microsoft.SqlTools.DataProtocol.Contracts/Connection/ConnectionType.cs
vendored
Normal file
@@ -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.DataProtocol.Contracts.Connection
|
||||
{
|
||||
/// <summary>
|
||||
/// String constants that represent connection types.
|
||||
///
|
||||
/// Default: Connection used by the editor. Opened by the editor upon the initial connection.
|
||||
/// Query: Connection used for executing queries. Opened when the first query is executed.
|
||||
/// </summary>
|
||||
public static class ConnectionType
|
||||
{
|
||||
public const string Default = "Default";
|
||||
public const string Query = "Query";
|
||||
public const string Edit = "Edit";
|
||||
public const string ObjectExplorer = "ObjectExplorer";
|
||||
public const string Dashboard = "Dashboard";
|
||||
public const string GeneralConnection = "GeneralConnection";
|
||||
}
|
||||
}
|
||||
25
external/Microsoft.SqlTools.DataProtocol.Contracts/Connection/DisconnectParams.cs
vendored
Normal file
25
external/Microsoft.SqlTools.DataProtocol.Contracts/Connection/DisconnectParams.cs
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// 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.DataProtocol.Contracts.Connection
|
||||
{
|
||||
/// <summary>
|
||||
/// Parameters for the Disconnect Request.
|
||||
/// </summary>
|
||||
public class DisconnectParams
|
||||
{
|
||||
/// <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>
|
||||
/// The type of connection we are disconnecting. If null, we will disconnect all connections.
|
||||
/// connections.
|
||||
/// </summary>
|
||||
public string Type { get; set; }
|
||||
}
|
||||
}
|
||||
19
external/Microsoft.SqlTools.DataProtocol.Contracts/Connection/DisconnectRequest.cs
vendored
Normal file
19
external/Microsoft.SqlTools.DataProtocol.Contracts/Connection/DisconnectRequest.cs
vendored
Normal file
@@ -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.Hosting.Contracts;
|
||||
|
||||
namespace Microsoft.SqlTools.DataProtocol.Contracts.Connection
|
||||
{
|
||||
/// <summary>
|
||||
/// Disconnect request mapping entry
|
||||
/// </summary>
|
||||
public class DisconnectRequest
|
||||
{
|
||||
public static readonly
|
||||
RequestType<DisconnectParams, bool> Type =
|
||||
RequestType<DisconnectParams, bool>.Create("connection/disconnect");
|
||||
}
|
||||
}
|
||||
42
external/Microsoft.SqlTools.DataProtocol.Contracts/Connection/LanguageFlavorChange.cs
vendored
Normal file
42
external/Microsoft.SqlTools.DataProtocol.Contracts/Connection/LanguageFlavorChange.cs
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
//
|
||||
// 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.Hosting.Contracts;
|
||||
|
||||
namespace Microsoft.SqlTools.DataProtocol.Contracts.Connection
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Parameters for the Language Flavor Change notification.
|
||||
/// </summary>
|
||||
public class LanguageFlavorChangeParams
|
||||
{
|
||||
/// <summary>
|
||||
/// A URI identifying the affected resource
|
||||
/// </summary>
|
||||
public string Uri { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The primary language
|
||||
/// </summary>
|
||||
public string Language { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The specific language flavor that is being set
|
||||
/// </summary>
|
||||
public string Flavor { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Defines an event that is sent from the client to notify that
|
||||
/// the client is exiting and the server should as well.
|
||||
/// </summary>
|
||||
public class LanguageFlavorChangeNotification
|
||||
{
|
||||
public static readonly
|
||||
EventType<LanguageFlavorChangeParams> Type =
|
||||
EventType<LanguageFlavorChangeParams>.Create("connection/languageflavorchanged");
|
||||
}
|
||||
}
|
||||
18
external/Microsoft.SqlTools.DataProtocol.Contracts/Connection/ListDatabasesParams.cs
vendored
Normal file
18
external/Microsoft.SqlTools.DataProtocol.Contracts/Connection/ListDatabasesParams.cs
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// 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.DataProtocol.Contracts.Connection
|
||||
{
|
||||
/// <summary>
|
||||
/// Parameters for the List Databases Request.
|
||||
/// </summary>
|
||||
public class ListDatabasesParams
|
||||
{
|
||||
/// <summary>
|
||||
/// URI of the owner of the connection requesting the list of databases.
|
||||
/// </summary>
|
||||
public string OwnerUri { get; set; }
|
||||
}
|
||||
}
|
||||
19
external/Microsoft.SqlTools.DataProtocol.Contracts/Connection/ListDatabasesRequest.cs
vendored
Normal file
19
external/Microsoft.SqlTools.DataProtocol.Contracts/Connection/ListDatabasesRequest.cs
vendored
Normal file
@@ -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.Hosting.Contracts;
|
||||
|
||||
namespace Microsoft.SqlTools.DataProtocol.Contracts.Connection
|
||||
{
|
||||
/// <summary>
|
||||
/// List databases request mapping entry
|
||||
/// </summary>
|
||||
public class ListDatabasesRequest
|
||||
{
|
||||
public static readonly
|
||||
RequestType<ListDatabasesParams, ListDatabasesResponse> Type =
|
||||
RequestType<ListDatabasesParams, ListDatabasesResponse>.Create("connection/listdatabases");
|
||||
}
|
||||
}
|
||||
18
external/Microsoft.SqlTools.DataProtocol.Contracts/Connection/ListDatabasesResponse.cs
vendored
Normal file
18
external/Microsoft.SqlTools.DataProtocol.Contracts/Connection/ListDatabasesResponse.cs
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// 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.DataProtocol.Contracts.Connection
|
||||
{
|
||||
/// <summary>
|
||||
/// Message format for the list databases response
|
||||
/// </summary>
|
||||
public class ListDatabasesResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the list of database names.
|
||||
/// </summary>
|
||||
public string[] DatabaseNames { get; set; }
|
||||
}
|
||||
}
|
||||
68
external/Microsoft.SqlTools.DataProtocol.Contracts/Connection/ServerInfo.cs
vendored
Normal file
68
external/Microsoft.SqlTools.DataProtocol.Contracts/Connection/ServerInfo.cs
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
//
|
||||
// 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.DataProtocol.Contracts.Connection
|
||||
{
|
||||
/// <summary>
|
||||
/// Contract for information on the connected SQL Server instance.
|
||||
/// </summary>
|
||||
public class ServerInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// The major version of the SQL Server instance.
|
||||
/// </summary>
|
||||
public int ServerMajorVersion { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The minor version of the SQL Server instance.
|
||||
/// </summary>
|
||||
public int ServerMinorVersion { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The build of the SQL Server instance.
|
||||
/// </summary>
|
||||
public int ServerReleaseVersion { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The ID of the engine edition of the SQL Server instance.
|
||||
/// </summary>
|
||||
public int EngineEditionId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// String containing the full server version text.
|
||||
/// </summary>
|
||||
public string ServerVersion { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// String describing the product level of the server.
|
||||
/// </summary>
|
||||
public string ServerLevel { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The edition of the SQL Server instance.
|
||||
/// </summary>
|
||||
public string ServerEdition { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether the SQL Server instance is running in the cloud (Azure) or not.
|
||||
/// </summary>
|
||||
public bool IsCloud { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The version of Azure that the SQL Server instance is running on, if applicable.
|
||||
/// </summary>
|
||||
public int AzureVersion { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The Operating System version string of the machine running the SQL Server instance.
|
||||
/// </summary>
|
||||
public string OsVersion { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The Operating System version string of the machine running the SQL Server instance.
|
||||
/// </summary>
|
||||
public string MachineName { get; set; }
|
||||
}
|
||||
}
|
||||
53
external/Microsoft.SqlTools.DataProtocol.Contracts/Explorer/CloseSessionRequest.cs
vendored
Normal file
53
external/Microsoft.SqlTools.DataProtocol.Contracts/Explorer/CloseSessionRequest.cs
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
//
|
||||
// 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.Hosting.Contracts;
|
||||
using Microsoft.SqlTools.DataProtocol.Contracts.Connection;
|
||||
|
||||
namespace Microsoft.SqlTools.DataProtocol.Contracts.Explorer
|
||||
{
|
||||
/// <summary>
|
||||
/// Information returned from a <see cref="CloseSessionRequest"/>.
|
||||
/// Contains success information, a <see cref="SessionId"/> to be used when
|
||||
/// requesting closing an existing session.
|
||||
/// </summary>
|
||||
public class CloseSessionResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// Boolean indicating if the session was closed successfully
|
||||
/// </summary>
|
||||
public bool Success { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Unique ID to use when sending any requests for objects in the
|
||||
/// tree under the node
|
||||
/// </summary>
|
||||
public string SessionId { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parameters to the <see cref="CloseSessionRequest"/>.
|
||||
/// </summary>
|
||||
public class CloseSessionParams
|
||||
{
|
||||
/// <summary>
|
||||
/// The Id returned from a <see cref="CreateSessionRequest"/>. This
|
||||
/// is used to disambiguate between different trees.
|
||||
/// </summary>
|
||||
public string SessionId { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Establishes an Object Explorer tree session for a specific connection.
|
||||
/// This will create a connection to a specific server or database, register
|
||||
/// it for use in the
|
||||
/// </summary>
|
||||
public class CloseSessionRequest
|
||||
{
|
||||
public static readonly
|
||||
RequestType<CloseSessionParams, CloseSessionResponse> Type =
|
||||
RequestType<CloseSessionParams, CloseSessionResponse>.Create("explorer/closesession");
|
||||
}
|
||||
}
|
||||
65
external/Microsoft.SqlTools.DataProtocol.Contracts/Explorer/CreateSessionRequest.cs
vendored
Normal file
65
external/Microsoft.SqlTools.DataProtocol.Contracts/Explorer/CreateSessionRequest.cs
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
//
|
||||
// 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.Hosting.Contracts;
|
||||
using Microsoft.SqlTools.DataProtocol.Contracts.Connection;
|
||||
|
||||
namespace Microsoft.SqlTools.DataProtocol.Contracts.Explorer
|
||||
{
|
||||
/// <summary>
|
||||
/// Information returned from a <see cref="CreateSessionRequest"/>.
|
||||
/// Contains success information, a <see cref="SessionId"/> to be used when
|
||||
/// requesting expansion of nodes, and a root node to display for this area.
|
||||
/// </summary>
|
||||
public class CreateSessionResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// Unique ID to use when sending any requests for objects in the
|
||||
/// tree under the node
|
||||
/// </summary>
|
||||
public string SessionId { get; set; }
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Information returned from a <see cref="CreateSessionRequest"/>.
|
||||
/// Contains success information, a <see cref="SessionId"/> to be used when
|
||||
/// requesting expansion of nodes, and a root node to display for this area.
|
||||
/// </summary>
|
||||
public class SessionCreatedParameters
|
||||
{
|
||||
/// <summary>
|
||||
/// Boolean indicating if the connection was successful
|
||||
/// </summary>
|
||||
public bool Success { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Unique ID to use when sending any requests for objects in the
|
||||
/// tree under the node
|
||||
/// </summary>
|
||||
public string SessionId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Information describing the base node in the tree
|
||||
/// </summary>
|
||||
public NodeInfo RootNode { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Error message returned from the engine for a object explorer session failure reason, if any.
|
||||
/// </summary>
|
||||
public string ErrorMessage { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Session notification mapping entry
|
||||
/// </summary>
|
||||
public class CreateSessionCompleteNotification
|
||||
{
|
||||
public static readonly
|
||||
EventType<SessionCreatedParameters> Type =
|
||||
EventType<SessionCreatedParameters>.Create("explorer/sessioncreated");
|
||||
}
|
||||
}
|
||||
76
external/Microsoft.SqlTools.DataProtocol.Contracts/Explorer/ExpandRequest.cs
vendored
Normal file
76
external/Microsoft.SqlTools.DataProtocol.Contracts/Explorer/ExpandRequest.cs
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
//
|
||||
// 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.Hosting.Contracts;
|
||||
|
||||
namespace Microsoft.SqlTools.DataProtocol.Contracts.Explorer
|
||||
{
|
||||
/// <summary>
|
||||
/// Information returned from a <see cref="ExpandRequest"/>.
|
||||
/// </summary>
|
||||
public class ExpandResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// Unique ID to use when sending any requests for objects in the
|
||||
/// tree under the node
|
||||
/// </summary>
|
||||
public string SessionId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Information describing the expanded nodes in the tree
|
||||
/// </summary>
|
||||
public NodeInfo[] Nodes { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Path identifying the node to expand. See <see cref="NodeInfo.NodePath"/> for details
|
||||
/// </summary>
|
||||
public string NodePath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Error message returned from the engine for a object explorer expand failure reason, if any.
|
||||
/// </summary>
|
||||
public string ErrorMessage { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parameters to the <see cref="ExpandRequest"/>.
|
||||
/// </summary>
|
||||
public class ExpandParams
|
||||
{
|
||||
/// <summary>
|
||||
/// The Id returned from a <see cref="CreateSessionRequest"/>. This
|
||||
/// is used to disambiguate between different trees.
|
||||
/// </summary>
|
||||
public string SessionId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Path identifying the node to expand. See <see cref="NodeInfo.NodePath"/> for details
|
||||
/// </summary>
|
||||
public string NodePath { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A request to expand a node in the tree
|
||||
/// </summary>
|
||||
public class ExpandRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns children of a given node as a <see cref="NodeInfo"/> array.
|
||||
/// </summary>
|
||||
public static readonly
|
||||
RequestType<ExpandParams, bool> Type =
|
||||
RequestType<ExpandParams, bool>.Create("explorer/expand");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Expand notification mapping entry
|
||||
/// </summary>
|
||||
public class ExpandCompleteNotification
|
||||
{
|
||||
public static readonly
|
||||
EventType<ExpandResponse> Type =
|
||||
EventType<ExpandResponse>.Create("explorer/expandCompleted");
|
||||
}
|
||||
}
|
||||
55
external/Microsoft.SqlTools.DataProtocol.Contracts/Explorer/FindNodesRequest.cs
vendored
Normal file
55
external/Microsoft.SqlTools.DataProtocol.Contracts/Explorer/FindNodesRequest.cs
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.SqlTools.Hosting.Contracts;
|
||||
using Microsoft.SqlTools.DataProtocol.Contracts.Connection;
|
||||
|
||||
namespace Microsoft.SqlTools.DataProtocol.Contracts.Explorer
|
||||
{
|
||||
/// <summary>
|
||||
/// Information returned from a <see cref="FindNodesRequest"/>.
|
||||
/// </summary>
|
||||
public class FindNodesResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// Information describing the matching nodes in the tree
|
||||
/// </summary>
|
||||
public List<NodeInfo> Nodes { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parameters to the <see cref="FindNodesRequest"/>.
|
||||
/// </summary>
|
||||
public class FindNodesParams
|
||||
{
|
||||
/// <summary>
|
||||
/// The Id returned from a <see cref="CreateSessionRequest"/>. This
|
||||
/// is used to disambiguate between different trees.
|
||||
/// </summary>
|
||||
public string SessionId { get; set; }
|
||||
|
||||
public string Type { get; set; }
|
||||
|
||||
public string Schema { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
public string Database { get; set; }
|
||||
|
||||
public List<string> ParentObjectNames { get; set; }
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// TODO
|
||||
/// </summary>
|
||||
public class FindNodesRequest
|
||||
{
|
||||
public static readonly
|
||||
RequestType<FindNodesParams, FindNodesResponse> Type =
|
||||
RequestType<FindNodesParams, FindNodesResponse>.Create("explorer/findnodes");
|
||||
}
|
||||
}
|
||||
63
external/Microsoft.SqlTools.DataProtocol.Contracts/Explorer/NodeInfo.cs
vendored
Normal file
63
external/Microsoft.SqlTools.DataProtocol.Contracts/Explorer/NodeInfo.cs
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
//
|
||||
// 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.DataProtocol.Contracts.Metadata;
|
||||
|
||||
namespace Microsoft.SqlTools.DataProtocol.Contracts.Explorer
|
||||
{
|
||||
/// <summary>
|
||||
/// Information describing a Node in the Object Explorer tree.
|
||||
/// Contains information required to display the Node to the user and
|
||||
/// to know whether actions such as expanding children is possible
|
||||
/// the node
|
||||
/// </summary>
|
||||
public class NodeInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// Path identifying this node: for example a table will be at ["server", "database", "tables", "tableName"].
|
||||
/// This enables rapid navigation of the tree without the need for a global registry of elements.
|
||||
/// The path functions as a unique ID and is used to disambiguate the node when sending requests for expansion.
|
||||
/// A common ID is needed since processes do not share address space and need a unique identifier
|
||||
/// </summary>
|
||||
public string NodePath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The type of the node - for example Server, Database, Folder, Table
|
||||
/// </summary>
|
||||
public string NodeType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Label to display to the user, describing this node.
|
||||
/// </summary>
|
||||
public string Label { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Node Sub type - for example a key can have type as "Key" and sub type as "PrimaryKey"
|
||||
/// </summary>
|
||||
public string NodeSubType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Node status - for example login can be disabled/enabled
|
||||
/// </summary>
|
||||
public string NodeStatus { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Is this a leaf node (in which case no children can be generated) or
|
||||
/// is it expandable?
|
||||
/// </summary>
|
||||
public bool IsLeaf { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Object Metadata for smo objects to be used for scripting
|
||||
/// </summary>
|
||||
public ObjectMetadata Metadata { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Error message returned from the engine for a object explorer node failure reason, if any.
|
||||
/// </summary>
|
||||
public string ErrorMessage { get; set; }
|
||||
}
|
||||
}
|
||||
29
external/Microsoft.SqlTools.DataProtocol.Contracts/Explorer/RefreshRequest.cs
vendored
Normal file
29
external/Microsoft.SqlTools.DataProtocol.Contracts/Explorer/RefreshRequest.cs
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
//
|
||||
// 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.Hosting.Contracts;
|
||||
|
||||
namespace Microsoft.SqlTools.DataProtocol.Contracts.Explorer
|
||||
{
|
||||
/// <summary>
|
||||
/// Parameters to the <see cref="ExpandRequest"/>.
|
||||
/// </summary>
|
||||
public class RefreshParams: ExpandParams
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A request to expand a
|
||||
/// </summary>
|
||||
public class RefreshRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns children of a given node as a <see cref="NodeInfo"/> array.
|
||||
/// </summary>
|
||||
public static readonly
|
||||
RequestType<RefreshParams, bool> Type =
|
||||
RequestType<RefreshParams, bool>.Create("explorer/refresh");
|
||||
}
|
||||
}
|
||||
114
external/Microsoft.SqlTools.DataProtocol.Contracts/GeneralRequestDetails.cs
vendored
Normal file
114
external/Microsoft.SqlTools.DataProtocol.Contracts/GeneralRequestDetails.cs
vendored
Normal file
@@ -0,0 +1,114 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Microsoft.SqlTools.DataProtocol.Contracts
|
||||
{
|
||||
public class GeneralRequestDetails
|
||||
{
|
||||
public GeneralRequestDetails()
|
||||
{
|
||||
Options = new Dictionary<string, object>();
|
||||
}
|
||||
|
||||
public T GetOptionValue<T>(string name)
|
||||
{
|
||||
T result = default(T);
|
||||
if (Options != null && Options.ContainsKey(name))
|
||||
{
|
||||
object value = Options[name];
|
||||
try
|
||||
{
|
||||
result = GetValueAs<T>(value);
|
||||
}
|
||||
catch
|
||||
{
|
||||
result = default(T);
|
||||
// TODO move logger to a utilities project
|
||||
// Logger.Write(TraceEventType.Warning, string.Format(CultureInfo.InvariantCulture,
|
||||
// "Cannot convert option value {0}:{1} to {2}", name, value ?? "", typeof(T)));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static T GetValueAs<T>(object value)
|
||||
{
|
||||
T result = default(T);
|
||||
|
||||
if (value != null && (typeof(T) != value.GetType()))
|
||||
{
|
||||
if (typeof(T) == typeof(int) || typeof(T) == typeof(int?))
|
||||
{
|
||||
value = Convert.ToInt32(value);
|
||||
}
|
||||
else if (typeof(T) == typeof(bool) || typeof(T) == typeof(bool?))
|
||||
{
|
||||
value = Convert.ToBoolean(value);
|
||||
}
|
||||
else if (typeof(T).IsEnum)
|
||||
{
|
||||
object enumValue;
|
||||
if (TryParseEnum<T>(typeof(T), value.ToString(), out enumValue))
|
||||
{
|
||||
value = (T)enumValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (value != null && (typeof(T).IsEnum))
|
||||
{
|
||||
object enumValue;
|
||||
if (TryParseEnum<T>(typeof(T), value.ToString(), out enumValue))
|
||||
{
|
||||
value = enumValue;
|
||||
}
|
||||
}
|
||||
result = value != null ? (T)value : default(T);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This method exists because in NetStandard the Enum.TryParse methods that accept in a type
|
||||
/// are not present, and the generic TryParse method requires the type T to be non-nullable which
|
||||
/// is hard to check. This is different to the NetCore definition for some reason.
|
||||
/// It seems easier to implement our own than work around this.
|
||||
/// </summary>
|
||||
private static bool TryParseEnum<T>(Type t, string value, out object enumValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
enumValue = Enum.Parse(t, value);
|
||||
return true;
|
||||
}
|
||||
catch(Exception)
|
||||
{
|
||||
enumValue = default(T);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected void SetOptionValue<T>(string name, T value)
|
||||
{
|
||||
Options = Options ?? new Dictionary<string, object>();
|
||||
if (Options.ContainsKey(name))
|
||||
{
|
||||
Options[name] = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
Options.Add(name, value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets the options
|
||||
/// </summary>
|
||||
public Dictionary<string, object> Options { get; set; }
|
||||
}
|
||||
}
|
||||
94
external/Microsoft.SqlTools.DataProtocol.Contracts/InitializeRequest.cs
vendored
Normal file
94
external/Microsoft.SqlTools.DataProtocol.Contracts/InitializeRequest.cs
vendored
Normal file
@@ -0,0 +1,94 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using System;
|
||||
using Microsoft.SqlTools.DataProtocol.Contracts.Common;
|
||||
using Microsoft.SqlTools.Hosting.Contracts;
|
||||
|
||||
namespace Microsoft.SqlTools.DataProtocol.Contracts
|
||||
{
|
||||
public enum TraceOptions
|
||||
{
|
||||
Off,
|
||||
Messages,
|
||||
Verbose
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parameters provided with an initialize request
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This is the initialize request parameters used by VSCode language server. These are
|
||||
/// provided here for convenience of implementing initialization request handlers when the
|
||||
/// server is expected to be used by the VSCode language client. You are not obligated to use
|
||||
/// these initialization params when writing your server, nor are you even obligated to
|
||||
/// implement an initialize handler. However, the VSCode language client will always send an
|
||||
/// initialize request when starting the server and will not consider the server "ready" until
|
||||
/// a response to the init request has been received.
|
||||
/// </remarks>
|
||||
public class InitializeParameters
|
||||
{
|
||||
/// <summary>
|
||||
/// Capabilities of the initializing client
|
||||
/// </summary>
|
||||
public ClientCapabilities.ClientCapabilities Capabilities { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Root path of the workspace, is null if no folder is open.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This function has been deprecated in favor of workspace folders
|
||||
/// </remarks>
|
||||
[Obsolete("Deprecated in favor of rootUri")]
|
||||
public string RootPath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Root URI of the workspace, is null if no folder is open. If both <see cref="RootPath"/>
|
||||
/// and <see cref="RootUri"/> are set, <see cref="RootUri"/> should be used.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This function has been deprecated in favor of workspace folders
|
||||
/// </remarks>
|
||||
[Obsolete("Deprecated in favor of workspace folders")]
|
||||
public string RootUri { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initial trace setting. If omitted, trace is disabled <see cref="TraceOptions.Off"/>
|
||||
/// </summary>
|
||||
public TraceOptions? Trace { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Workspace folders that are open at the time of initialization. If this is provided, it
|
||||
/// takes precedence over <see cref="RootUri"/> and <see cref="RootPath"/>
|
||||
/// </summary>
|
||||
public WorkspaceFolder[] WorkspaceFolders { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parameters provided as a result to an initialize request
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This is the initialize result parameters used by VSCode language server. These are provided
|
||||
/// for convenience of implementing initialization request handlers when the server is expected
|
||||
/// to be used by the VSCode language client. You are not obligated to use these initialization
|
||||
/// params when writing your server, nor are you even obligated to implement an initialize
|
||||
/// handler. However, the VSCode language client will always send an initialize request when
|
||||
/// starting the server and will not consider the server "ready" until a response to the init
|
||||
/// request has been received.
|
||||
/// </remarks>
|
||||
public class InitializeResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// Capabilities that this server provides
|
||||
/// </summary>
|
||||
public ServerCapabilities.ServerCapabilities Capabilities { get; set; }
|
||||
}
|
||||
|
||||
public class InitializeRequest
|
||||
{
|
||||
public static readonly RequestType<InitializeParameters, InitializeResponse> Type =
|
||||
RequestType<InitializeParameters, InitializeResponse>.Create("initialize");
|
||||
}
|
||||
}
|
||||
49
external/Microsoft.SqlTools.DataProtocol.Contracts/InitializeRequestWithOptions.cs
vendored
Normal file
49
external/Microsoft.SqlTools.DataProtocol.Contracts/InitializeRequestWithOptions.cs
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
//
|
||||
// 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.Hosting.Contracts;
|
||||
|
||||
namespace Microsoft.SqlTools.DataProtocol.Contracts
|
||||
{
|
||||
/// <summary>
|
||||
/// Parameters provided with an initialize request with extra options provided by the client
|
||||
/// </summary>
|
||||
/// <typeparam name="TInitializationOptions">
|
||||
/// Type of the initialization options expected from the client, can be any reference type
|
||||
/// </typeparam>
|
||||
public class InitializeParametersWithOptions<TInitializationOptions> : InitializeParameters where TInitializationOptions : class
|
||||
{
|
||||
/// <summary>
|
||||
/// Initialization options provided by the client, can be null
|
||||
/// </summary>
|
||||
public TInitializationOptions InitializationOptions { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Request definition for initialization of the server. This version provides optional extra
|
||||
/// parameters that can be used to pass extra information between client and server during
|
||||
/// initialization. If these extra options aren't needed, use <see cref="InitializeRequest"/>.
|
||||
/// </summary>
|
||||
/// <typeparam name="TInitializeOptions">
|
||||
/// Type to use for extra parameters in the initialize request. These appear as
|
||||
/// <see cref="InitializeParametersWithOptions{TInitializationOptions}.InitializationOptions"/>.
|
||||
/// If these extra options are not expected, but extra response options are, simply use
|
||||
/// <c>object</c> as the type.
|
||||
/// </typeparam>
|
||||
/// <typeparam name="TInitializeResponse">
|
||||
/// Type to use for the initialize response. Due to VSCode's protocol definition, any extra
|
||||
/// params that should be sent back to the client are defined as dictionary of key/value pairs.
|
||||
/// This can be emulated by defining a class that extends <see cref="InitializeResponse"/> with
|
||||
/// whatever extra params are expected. If no extra options are needed, but extra request
|
||||
/// options are, simply use <see cref="InitializeResponse"/> as the type.
|
||||
/// </typeparam>
|
||||
public class InitializeRequestWithOptions<TInitializeOptions, TInitializeResponse>
|
||||
where TInitializeOptions : class
|
||||
where TInitializeResponse : InitializeResponse
|
||||
{
|
||||
public static readonly RequestType<InitializeParametersWithOptions<TInitializeOptions>, TInitializeResponse> Type =
|
||||
RequestType<InitializeParametersWithOptions<TInitializeOptions>, TInitializeResponse>.Create("initialize");
|
||||
}
|
||||
}
|
||||
36
external/Microsoft.SqlTools.DataProtocol.Contracts/Metadata/ObjectMetadata.cs
vendored
Normal file
36
external/Microsoft.SqlTools.DataProtocol.Contracts/Metadata/ObjectMetadata.cs
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
//
|
||||
// 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.DataProtocol.Contracts.Metadata
|
||||
{
|
||||
/// <summary>
|
||||
/// Metadata type enumeration
|
||||
/// </summary>
|
||||
public enum MetadataType
|
||||
{
|
||||
Table = 0,
|
||||
View = 1,
|
||||
SProc = 2,
|
||||
Function = 3,
|
||||
Schema = 4,
|
||||
Database = 5
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Object metadata information
|
||||
/// </summary>
|
||||
public class ObjectMetadata
|
||||
{
|
||||
public MetadataType MetadataType { get; set; }
|
||||
|
||||
public string MetadataTypeName { get; set; }
|
||||
|
||||
public string Schema { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
public string Urn { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<PackageDescription>
|
||||
The contract types used for communication over the VSCode Language Server Protocol and the Database Management Protocol.
|
||||
</PackageDescription>
|
||||
<Description>$(PackageDescription)</Description>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Microsoft.SqlTools.Hosting.Contracts\Microsoft.SqlTools.Hosting.Contracts.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
19
external/Microsoft.SqlTools.DataProtocol.Contracts/ServerCapabilities/CodeLensOptions.cs
vendored
Normal file
19
external/Microsoft.SqlTools.DataProtocol.Contracts/ServerCapabilities/CodeLensOptions.cs
vendored
Normal file
@@ -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.
|
||||
//
|
||||
|
||||
namespace Microsoft.SqlTools.DataProtocol.Contracts.ServerCapabilities
|
||||
{
|
||||
/// <summary>
|
||||
/// Options about Code Lens that the server supports
|
||||
/// </summary>
|
||||
public class CodeLensOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Code lens has a resolve provider, as well
|
||||
/// TODO: WTF does this mean??
|
||||
/// </summary>
|
||||
public bool? ResolveProvider { get; set; }
|
||||
}
|
||||
}
|
||||
30
external/Microsoft.SqlTools.DataProtocol.Contracts/ServerCapabilities/CompletionOptions.cs
vendored
Normal file
30
external/Microsoft.SqlTools.DataProtocol.Contracts/ServerCapabilities/CompletionOptions.cs
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
//
|
||||
// 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.DataProtocol.Contracts.ServerCapabilities
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines completion options that the server can support
|
||||
/// </summary>
|
||||
public class CompletionOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Most tools trigger completion request automatically without explicitly requesting it
|
||||
/// using a keyboard shortcut (eg, ctrl+space). Typically they do so when the user starts
|
||||
/// to type an identifier. For example if the user types 'c' in a JavaScript file, code
|
||||
/// completion will automatically pop up and present 'console' besides others as a
|
||||
/// completion item. Characters that make up identifiers don't need to be listed here.
|
||||
///
|
||||
/// If code completion should automatically be triggered on characters not being valid
|
||||
/// inside an identifier (for example '.' in JavaScript) list them in this.
|
||||
/// </summary>
|
||||
public string[] TriggerCharacters { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Server provides support to resolve additional information about a completion item
|
||||
/// </summary>
|
||||
public bool? ResolveProvider { get; set; }
|
||||
}
|
||||
}
|
||||
19
external/Microsoft.SqlTools.DataProtocol.Contracts/ServerCapabilities/DocumentLinkOptions.cs
vendored
Normal file
19
external/Microsoft.SqlTools.DataProtocol.Contracts/ServerCapabilities/DocumentLinkOptions.cs
vendored
Normal file
@@ -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.
|
||||
//
|
||||
|
||||
namespace Microsoft.SqlTools.DataProtocol.Contracts.ServerCapabilities
|
||||
{
|
||||
/// <summary>
|
||||
/// Options the server support for document links
|
||||
/// </summary>
|
||||
public class DocumentLinkOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Document links have a resolve provider, as well
|
||||
/// TODO: WTF does this mean?
|
||||
/// </summary>
|
||||
public bool? ResolveProvider { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -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.DataProtocol.Contracts.ServerCapabilities
|
||||
{
|
||||
/// <summary>
|
||||
/// Options the server supports regarding formatting a document on type
|
||||
/// </summary>
|
||||
public class DocumentOnTypeFormattingOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Character on which formatting should be triggered, eg '}'
|
||||
/// </summary>
|
||||
public string FirstTriggerCharacter { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// More charactres that trigger formatting
|
||||
/// </summary>
|
||||
public string[] MoreTriggerCharacters { get; set; }
|
||||
}
|
||||
}
|
||||
18
external/Microsoft.SqlTools.DataProtocol.Contracts/ServerCapabilities/ExecuteCommandOptions.cs
vendored
Normal file
18
external/Microsoft.SqlTools.DataProtocol.Contracts/ServerCapabilities/ExecuteCommandOptions.cs
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// 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.DataProtocol.Contracts.ServerCapabilities
|
||||
{
|
||||
/// <summary>
|
||||
/// Options the server supports regarding command execution
|
||||
/// </summary>
|
||||
public class ExecuteCommandOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Commands the server can execute
|
||||
/// </summary>
|
||||
public string[] Commands { get; set; }
|
||||
}
|
||||
}
|
||||
18
external/Microsoft.SqlTools.DataProtocol.Contracts/ServerCapabilities/SaveOptions.cs
vendored
Normal file
18
external/Microsoft.SqlTools.DataProtocol.Contracts/ServerCapabilities/SaveOptions.cs
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// 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.DataProtocol.Contracts.ServerCapabilities
|
||||
{
|
||||
/// <summary>
|
||||
/// Options the server supports for saving
|
||||
/// </summary>
|
||||
public class SaveOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Whether the client is supposed to include the content on save
|
||||
/// </summary>
|
||||
public bool? IncludeText { get; set; }
|
||||
}
|
||||
}
|
||||
122
external/Microsoft.SqlTools.DataProtocol.Contracts/ServerCapabilities/ServerCapabilities.cs
vendored
Normal file
122
external/Microsoft.SqlTools.DataProtocol.Contracts/ServerCapabilities/ServerCapabilities.cs
vendored
Normal file
@@ -0,0 +1,122 @@
|
||||
//
|
||||
// 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.DataProtocol.Contracts.ServerCapabilities
|
||||
{
|
||||
public class ServerCapabilities
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines how text documents are synced. Is either a detailed structure defining each
|
||||
/// notification or for backwards compatibility the TextDocumentSyncKind number.
|
||||
/// </summary>
|
||||
/// TODO: Use the Union type
|
||||
public TextDocumentSyncKind TextDocumentSync { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether the server provides code actions. Can be <c>null</c>
|
||||
/// </summary>
|
||||
public bool? CodeActionProvider { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Options that the server provides for code lens. Can be <c>null</c> to indicate code
|
||||
/// lens is not supported.
|
||||
/// </summary>
|
||||
public CodeLensOptions CodeLensProvider { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Options that the server supports for completion. Can be <c>null</c> to indicate
|
||||
/// completion is not supported.
|
||||
/// </summary>
|
||||
public CompletionOptions CompletionProvider { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether the server provides goto definition support. Can be <c>null</c>
|
||||
/// </summary>
|
||||
public bool? DefinitionProvider { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether the server provides document formatting. Can be <c>null</c>
|
||||
/// </summary>
|
||||
public bool? DocumentFormattingProvider { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether the server provides document highlight support. Can be <c>null</c>
|
||||
/// </summary>
|
||||
public bool? DocumentHighlightProvider { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Options the server supports for document linking. Can be <c>null</c> to indicate the
|
||||
/// feature is not supported
|
||||
/// </summary>
|
||||
public DocumentLinkOptions DocumentLinkProvider { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Options that the server supports for document formatting on type. Can be <c>null</c> to
|
||||
/// indicate the feature is not supported
|
||||
/// </summary>
|
||||
public DocumentOnTypeFormattingOptions DocumentOnTypeFormattingProvider { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether the server provides document symbol support. Can be <c>null</c>
|
||||
/// </summary>
|
||||
public bool? DocumentSymbolProvider { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Options the server supports for executing commands. Can be <c>null</c> to indicate the
|
||||
/// feature is not supported.
|
||||
/// </summary>
|
||||
public ExecuteCommandOptions ExecuteCommandProvider { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Any experimental features the server supports
|
||||
/// </summary>
|
||||
/// TODO: Should this be a parameterized type?
|
||||
public object Experimental { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether or not the server supports goto implementation requests. Can be <c>null</c>
|
||||
/// </summary>
|
||||
/// TODO: Union type
|
||||
public bool? ImplementationProvider { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether the server provides hover support. Can be <c>null</c>
|
||||
/// </summary>
|
||||
public bool? HoverProvider { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether the server provides find references support. Can be <c>null</c>
|
||||
/// </summary>
|
||||
public bool? ReferencesProvider { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether the server provides support for renaming. Can be <c>null</c>
|
||||
/// </summary>
|
||||
public bool? RenameProvider { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Options that the server supports for signature help. Can be <c>null</c> to indicate
|
||||
/// completion is not supported
|
||||
/// </summary>
|
||||
public SignatureHelpOptions SignatureHelpProvider { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether the server provides goto type definition support. Can be <c>null</c>
|
||||
/// </summary>
|
||||
/// TODO: Union type
|
||||
public bool? TypeDefinitionProvider { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Options specific to workspaces the server supoorts. Can be <c>null</c> to indicate the
|
||||
/// server does not support workspace requests.
|
||||
/// </summary>
|
||||
public WorkspaceCapabilities Workspace { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether the server provides workpace symbol support. Can be <c>null</c>
|
||||
/// </summary>
|
||||
public bool? WorkspaceSymbolProvider { get; set; }
|
||||
}
|
||||
}
|
||||
18
external/Microsoft.SqlTools.DataProtocol.Contracts/ServerCapabilities/SignatureHelpOptions.cs
vendored
Normal file
18
external/Microsoft.SqlTools.DataProtocol.Contracts/ServerCapabilities/SignatureHelpOptions.cs
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// 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.DataProtocol.Contracts.ServerCapabilities
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines options for signature help that the server supports
|
||||
/// </summary>
|
||||
public class SignatureHelpOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Characters that trigger signature help automatically
|
||||
/// </summary>
|
||||
public string[] TriggerCharacters { get; set; }
|
||||
}
|
||||
}
|
||||
76
external/Microsoft.SqlTools.DataProtocol.Contracts/ServerCapabilities/TextDocument.cs
vendored
Normal file
76
external/Microsoft.SqlTools.DataProtocol.Contracts/ServerCapabilities/TextDocument.cs
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
//
|
||||
// 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.DataProtocol.Contracts.Utilities;
|
||||
|
||||
namespace Microsoft.SqlTools.DataProtocol.Contracts.ServerCapabilities
|
||||
{
|
||||
public enum TextDocumentSyncKind
|
||||
{
|
||||
None = 0,
|
||||
Full = 1,
|
||||
Incremental = 2
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Defines options for sae notifications
|
||||
/// </summary>
|
||||
public class TextDocumentSaveOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Whether the client should send the content of the file being saved with the save notification
|
||||
/// </summary>
|
||||
public bool? IncludeText { get; set; }
|
||||
}
|
||||
|
||||
public class TextDocumentSync : Union<TextDocumentSyncOptions, TextDocumentSyncKind?>
|
||||
{
|
||||
public static TextDocumentSync FromTextDocumentSyncKind(TextDocumentSyncKind value)
|
||||
{
|
||||
return new TextDocumentSync
|
||||
{
|
||||
value1 = null,
|
||||
value2 = value
|
||||
};
|
||||
}
|
||||
|
||||
public static TextDocumentSync FromTextDocumentSyncOptions(TextDocumentSyncOptions value)
|
||||
{
|
||||
return new TextDocumentSync
|
||||
{
|
||||
value1 = value,
|
||||
value2 = null
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public class TextDocumentSyncOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// What kind of change notifications are sent to the server
|
||||
/// </summary>
|
||||
public TextDocumentSyncKind? Change { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether open and close notifications are sent to the server
|
||||
/// </summary>
|
||||
public bool? OpenClose { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Options for save notifications
|
||||
/// </summary>
|
||||
public TextDocumentSaveOptions SaveOptions { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether notifications indicating the client will save are sent to the server
|
||||
/// </summary>
|
||||
public bool? WillSave { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether requests should be sent to the server when the client is about to save
|
||||
/// </summary>
|
||||
public bool? WillSaveWaitUntil { get; set; }
|
||||
}
|
||||
}
|
||||
118
external/Microsoft.SqlTools.DataProtocol.Contracts/ServerCapabilities/Workspace.cs
vendored
Normal file
118
external/Microsoft.SqlTools.DataProtocol.Contracts/ServerCapabilities/Workspace.cs
vendored
Normal file
@@ -0,0 +1,118 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using System;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Microsoft.SqlTools.DataProtocol.Contracts.ServerCapabilities
|
||||
{
|
||||
public class WorkspaceCapabilities
|
||||
{
|
||||
/// <summary>
|
||||
/// Options specific to workspace folders the server supports
|
||||
/// </summary>
|
||||
public WorkspaceFolderCapabilities WorkspaceFolders { get; set; }
|
||||
}
|
||||
|
||||
public class WorkspaceFolderCapabilities
|
||||
{
|
||||
/// <summary>
|
||||
/// Whether or not the server supports multiple workspace folders
|
||||
/// </summary>
|
||||
public bool? Supported { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether the server wants to receive workspace folder change notifications
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// If a string is provided, the string is treated as an ID under which the notification is
|
||||
/// registered on the client side. The ID can be used to unregister for these events using
|
||||
/// the client/unregisterCapability request
|
||||
/// </remarks>
|
||||
public WorkspaceChangeNotification ChangeNotifications { get; set; }
|
||||
}
|
||||
|
||||
[JsonConverter(typeof(WorkspaceChangeNotificationJsonConverter))]
|
||||
public class WorkspaceChangeNotification
|
||||
{
|
||||
public bool BooleanValue { get; }
|
||||
|
||||
public string UnregisterId { get; }
|
||||
|
||||
private WorkspaceChangeNotification(bool booleanValue, string unregisterId)
|
||||
{
|
||||
BooleanValue = booleanValue;
|
||||
UnregisterId = unregisterId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates that this server can accept notifications that the workspace has changed
|
||||
/// </summary>
|
||||
public static WorkspaceChangeNotification True => new WorkspaceChangeNotification(true, null);
|
||||
|
||||
/// <summary>
|
||||
/// Indicates that this server cannot accept notifications that the workspace has changed
|
||||
/// </summary>
|
||||
public static WorkspaceChangeNotification False => new WorkspaceChangeNotification(false, null);
|
||||
|
||||
/// <summary>
|
||||
/// Indicates that this server can accept notifications that the workspace has changed but
|
||||
/// reserves the right to unsubscribe from receiving workspace change notifications
|
||||
/// </summary>
|
||||
/// <param name="unregisterId">ID to use when unregistering for workspace change notifications</param>
|
||||
public static WorkspaceChangeNotification WithId(string unregisterId)
|
||||
{
|
||||
return unregisterId == null ? null : new WorkspaceChangeNotification(true, unregisterId);
|
||||
}
|
||||
}
|
||||
|
||||
internal class WorkspaceChangeNotificationJsonConverter : JsonConverter
|
||||
{
|
||||
public override bool CanRead => true;
|
||||
public override bool CanWrite => true;
|
||||
|
||||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
writer.WriteNull();
|
||||
return;
|
||||
}
|
||||
|
||||
WorkspaceChangeNotification castValue = (WorkspaceChangeNotification) value;
|
||||
if (castValue.UnregisterId != null)
|
||||
{
|
||||
writer.WriteValue(castValue.UnregisterId);
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.WriteValue(castValue.BooleanValue);
|
||||
}
|
||||
}
|
||||
|
||||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
|
||||
{
|
||||
JToken jToken = JToken.Load(reader);
|
||||
if (jToken.Type == JTokenType.Null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (jToken.Type == JTokenType.Boolean)
|
||||
{
|
||||
return jToken.Value<bool>()
|
||||
? WorkspaceChangeNotification.True
|
||||
: WorkspaceChangeNotification.False;
|
||||
}
|
||||
|
||||
return WorkspaceChangeNotification.WithId(jToken.Value<string>());
|
||||
}
|
||||
|
||||
public override bool CanConvert(Type objectType)
|
||||
{
|
||||
return objectType == typeof(WorkspaceChangeNotificationJsonConverter);
|
||||
}
|
||||
}
|
||||
}
|
||||
92
external/Microsoft.SqlTools.DataProtocol.Contracts/Utilities/FlagsIntConverter.cs
vendored
Normal file
92
external/Microsoft.SqlTools.DataProtocol.Contracts/Utilities/FlagsIntConverter.cs
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Microsoft.SqlTools.DataProtocol.Contracts.Utilities
|
||||
{
|
||||
internal class FlagsIntConverter : JsonConverter
|
||||
{
|
||||
public override bool CanWrite => true;
|
||||
public override bool CanRead => true;
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public override bool CanConvert(Type objectType)
|
||||
{
|
||||
return objectType.IsEnum && objectType.GetCustomAttribute(typeof(FlagsAttribute)) != null;
|
||||
}
|
||||
|
||||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
|
||||
{
|
||||
var jToken = JToken.Load(reader);
|
||||
if (jToken.Type == JTokenType.Null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
int[] values = ((JArray)jToken).Values<int>().ToArray();
|
||||
var pureType = NullableUtils.GetUnderlyingTypeIfNullable(objectType);
|
||||
|
||||
FieldInfo[] enumFields = pureType.GetFields(BindingFlags.Public | BindingFlags.Static);
|
||||
int setFlags = 0;
|
||||
foreach (FieldInfo enumField in enumFields)
|
||||
{
|
||||
int enumValue = (int)enumField.GetValue(null);
|
||||
|
||||
// If there is a serialize value set for the enum value, look for that instead of the int value
|
||||
SerializeValueAttribute serializeValue = enumField.GetCustomAttribute<SerializeValueAttribute>();
|
||||
int searchValue = serializeValue?.Value ?? enumValue;
|
||||
if (Array.IndexOf(values, searchValue) >= 0)
|
||||
{
|
||||
setFlags |= enumValue;
|
||||
}
|
||||
}
|
||||
|
||||
return Enum.ToObject(pureType, setFlags);
|
||||
}
|
||||
|
||||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
|
||||
{
|
||||
FieldInfo[] enumFields = value.GetType().GetFields(BindingFlags.Public | BindingFlags.Static);
|
||||
List<int> setFlags = new List<int>();
|
||||
foreach (FieldInfo enumField in enumFields)
|
||||
{
|
||||
// Make sure the flag is set before doing expensive reflection
|
||||
int enumValue = (int)enumField.GetValue(null);
|
||||
if (((int)value & enumValue) == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// If there is a serialize value set for the member, use that instead of the int value
|
||||
SerializeValueAttribute serializeValue = enumField.GetCustomAttribute<SerializeValueAttribute>();
|
||||
int flagValue = serializeValue?.Value ?? enumValue;
|
||||
setFlags.Add(flagValue);
|
||||
}
|
||||
|
||||
string joinedFlags = string.Join(", ", setFlags);
|
||||
writer.WriteRawValue($"[{joinedFlags}]");
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
internal class SerializeValueAttribute : Attribute
|
||||
{
|
||||
public int Value { get; }
|
||||
|
||||
public SerializeValueAttribute(int value)
|
||||
{
|
||||
Value = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
101
external/Microsoft.SqlTools.DataProtocol.Contracts/Utilities/FlagsStringConverter.cs
vendored
Normal file
101
external/Microsoft.SqlTools.DataProtocol.Contracts/Utilities/FlagsStringConverter.cs
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
|
||||
namespace Microsoft.SqlTools.DataProtocol.Contracts.Utilities
|
||||
{
|
||||
internal class FlagsStringConverter : JsonConverter
|
||||
{
|
||||
public override bool CanWrite => true;
|
||||
public override bool CanRead => true;
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public override bool CanConvert(Type objectType)
|
||||
{
|
||||
return objectType.IsEnum && objectType.GetCustomAttribute(typeof(FlagsAttribute)) != null;
|
||||
}
|
||||
|
||||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
|
||||
{
|
||||
JToken jToken = JToken.Load(reader);
|
||||
if (jToken.Type == JTokenType.Null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
string[] values = ((JArray)jToken).Values<string>().ToArray();
|
||||
var pureType = NullableUtils.GetUnderlyingTypeIfNullable(objectType);
|
||||
|
||||
FieldInfo[] enumFields = pureType.GetFields(BindingFlags.Public | BindingFlags.Static);
|
||||
int setFlags = 0;
|
||||
foreach (FieldInfo enumField in enumFields)
|
||||
{
|
||||
// If there is a serialize value set for the enum value, look for the instead of the int value
|
||||
SerializeValueAttribute serializeValue = enumField.GetCustomAttribute<SerializeValueAttribute>();
|
||||
string searchValue = serializeValue?.Value ?? enumField.Name;
|
||||
if (serializer.ContractResolver is CamelCasePropertyNamesContractResolver)
|
||||
{
|
||||
searchValue = char.ToLowerInvariant(searchValue[0]) + searchValue.Substring(1);
|
||||
}
|
||||
|
||||
// If the value is in the json array, or the int value into the flags
|
||||
if (Array.IndexOf(values, searchValue) >= 0)
|
||||
{
|
||||
setFlags |= (int)enumField.GetValue(null);
|
||||
}
|
||||
}
|
||||
|
||||
return Enum.ToObject(pureType, setFlags);
|
||||
}
|
||||
|
||||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
|
||||
{
|
||||
FieldInfo[] enumFields = value.GetType().GetFields(BindingFlags.Public | BindingFlags.Static);
|
||||
List<string> setFlags = new List<string>();
|
||||
foreach (FieldInfo enumField in enumFields)
|
||||
{
|
||||
// Make sure the flag is set before doing any other work
|
||||
int enumValue = (int)enumField.GetValue(null);
|
||||
if (((int)value & enumValue) == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// If there is a serialize value set for the member, use that instead of the int value
|
||||
SerializeValueAttribute serializeValue = enumField.GetCustomAttribute<SerializeValueAttribute>();
|
||||
string flagValue = serializeValue?.Value ?? enumField.Name;
|
||||
if (serializer.ContractResolver is CamelCasePropertyNamesContractResolver)
|
||||
{
|
||||
flagValue = char.ToLowerInvariant(flagValue[0]) + flagValue.Substring(1);
|
||||
}
|
||||
setFlags.Add($"\"{flagValue}\"");
|
||||
}
|
||||
|
||||
string joinedFlags = string.Join(", ", setFlags);
|
||||
writer.WriteRawValue($"[{joinedFlags}]");
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
internal class SerializeValueAttribute : Attribute
|
||||
{
|
||||
public string Value { get; }
|
||||
|
||||
public SerializeValueAttribute(string value)
|
||||
{
|
||||
Value = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
36
external/Microsoft.SqlTools.DataProtocol.Contracts/Utilities/NullableUtils.cs
vendored
Normal file
36
external/Microsoft.SqlTools.DataProtocol.Contracts/Utilities/NullableUtils.cs
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using System;
|
||||
|
||||
namespace Microsoft.SqlTools.DataProtocol.Contracts.Utilities
|
||||
{
|
||||
internal static class NullableUtils
|
||||
{
|
||||
/// <summary>
|
||||
/// Determines whether the type is <see cref="Nullable{T}"/>.
|
||||
/// </summary>
|
||||
/// <param name="t">The type.</param>
|
||||
/// <returns>
|
||||
/// <c>true</c> if <paramref name="t"/> is <see cref="Nullable{T}"/>; otherwise, <c>false</c>.
|
||||
/// </returns>
|
||||
public static bool IsNullable(Type t)
|
||||
{
|
||||
return t.IsGenericType && t.GetGenericTypeDefinition() == typeof(Nullable<>);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unwraps the <see cref="Nullable{T}"/> if necessary and returns the underlying value type.
|
||||
/// </summary>
|
||||
/// <param name="t">The type.</param>
|
||||
/// <returns>The underlying value type the <see cref="Nullable{T}"/> type was produced from,
|
||||
/// or the <paramref name="t"/> type if the type is not <see cref="Nullable{T}"/>.
|
||||
/// </returns>
|
||||
public static Type GetUnderlyingTypeIfNullable(Type t)
|
||||
{
|
||||
return IsNullable(t) ? Nullable.GetUnderlyingType(t) : t;
|
||||
}
|
||||
}
|
||||
}
|
||||
103
external/Microsoft.SqlTools.DataProtocol.Contracts/Utilities/Union.cs
vendored
Normal file
103
external/Microsoft.SqlTools.DataProtocol.Contracts/Utilities/Union.cs
vendored
Normal file
@@ -0,0 +1,103 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using System;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Microsoft.SqlTools.DataProtocol.Contracts.Utilities
|
||||
{
|
||||
internal interface IUnion
|
||||
{
|
||||
object Value { get; set; }
|
||||
}
|
||||
|
||||
[JsonConverter(typeof(UnionJsonSerializer))]
|
||||
public class Union<T1, T2> : IUnion
|
||||
{
|
||||
protected T1 value1;
|
||||
protected T2 value2;
|
||||
|
||||
internal Union() {}
|
||||
|
||||
public object Value
|
||||
{
|
||||
get => (object) value1 ?? value2;
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
throw new ArgumentException();
|
||||
}
|
||||
|
||||
if (value is T1)
|
||||
{
|
||||
value1 = (T1) value;
|
||||
}
|
||||
else if (value is T2)
|
||||
{
|
||||
value2 = (T2) value;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class UnionJsonSerializer : JsonConverter
|
||||
{
|
||||
public override bool CanRead => true;
|
||||
public override bool CanWrite => true;
|
||||
|
||||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
|
||||
{
|
||||
writer.WriteValue(((IUnion)value).Value);
|
||||
}
|
||||
|
||||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
|
||||
{
|
||||
// Check for null first
|
||||
JToken jToken = JToken.Load(reader);
|
||||
if (jToken.Type == JTokenType.Null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// Cast to an object
|
||||
JObject jObject = (JObject)jToken;
|
||||
|
||||
// Try to convert to
|
||||
object value = null;
|
||||
foreach (Type t in objectType.GenericTypeArguments)
|
||||
{
|
||||
try
|
||||
{
|
||||
value = jObject.ToObject(t);
|
||||
break;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// Ignore any failure to cast, we'll throw if we exhaust all the conversion options
|
||||
}
|
||||
}
|
||||
|
||||
if (value == null)
|
||||
{
|
||||
throw new InvalidCastException();
|
||||
}
|
||||
|
||||
IUnion result = (IUnion)Activator.CreateInstance(objectType);
|
||||
result.Value = value;
|
||||
return result;
|
||||
}
|
||||
|
||||
public override bool CanConvert(Type objectType)
|
||||
{
|
||||
return objectType.IsAssignableFrom(typeof(IUnion));
|
||||
}
|
||||
}
|
||||
}
|
||||
21
external/Microsoft.SqlTools.DataProtocol.Contracts/Workspace/Configuration.cs
vendored
Normal file
21
external/Microsoft.SqlTools.DataProtocol.Contracts/Workspace/Configuration.cs
vendored
Normal file
@@ -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.
|
||||
//
|
||||
|
||||
using Microsoft.SqlTools.Hosting.Contracts;
|
||||
|
||||
namespace Microsoft.SqlTools.DataProtocol.Contracts.Workspace
|
||||
{
|
||||
public class DidChangeConfigurationNotification<TConfig>
|
||||
{
|
||||
public static readonly
|
||||
EventType<DidChangeConfigurationParams<TConfig>> Type =
|
||||
EventType<DidChangeConfigurationParams<TConfig>>.Create("workspace/didChangeConfiguration");
|
||||
}
|
||||
|
||||
public class DidChangeConfigurationParams<TConfig>
|
||||
{
|
||||
public TConfig Settings { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user