diff --git a/eng/Versions.props b/eng/Versions.props index bba99f1fb9478..6e814ebc0eb8c 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -29,7 +29,6 @@ 6.0.0-rtm.21518.12 6.0.0-rtm.21518.12 17.7.4-preview - 17.8.9-preview 17.8.36711 17.3.2 @@ -169,9 +168,6 @@ 15.8.27812-alpha $(VisualStudioEditorPackagesVersion) $(VisualStudioEditorPackagesVersion) - $(MicrosoftVisualStudioLanguageServerProtocolPackagesVersion) - $(MicrosoftVisualStudioLanguageServerProtocolPackagesVersion) - $(MicrosoftVisualStudioLanguageServerProtocolPackagesVersion) $(MicrosoftVisualStudioLanguageServerClientPackagesVersion) $(MicrosoftVisualStudioLanguageServerClientPackagesVersion) $(VisualStudioEditorPackagesVersion) diff --git a/src/EditorFeatures/Core/Classification/Syntactic/SyntacticClassificationTaggerProvider.TagComputer.cs b/src/EditorFeatures/Core/Classification/Syntactic/SyntacticClassificationTaggerProvider.TagComputer.cs index 93af689fab9e5..096f0e2bfaecb 100644 --- a/src/EditorFeatures/Core/Classification/Syntactic/SyntacticClassificationTaggerProvider.TagComputer.cs +++ b/src/EditorFeatures/Core/Classification/Syntactic/SyntacticClassificationTaggerProvider.TagComputer.cs @@ -15,9 +15,9 @@ using Microsoft.CodeAnalysis.Shared.TestHooks; using Microsoft.CodeAnalysis.Text; using Microsoft.CodeAnalysis.Text.Shared.Extensions; -using Microsoft.VisualStudio.LanguageServer.Protocol; using Microsoft.VisualStudio.Text; using Microsoft.VisualStudio.Text.Tagging; +using Roslyn.LanguageServer.Protocol; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.Classification; diff --git a/src/EditorFeatures/Core/Extensions/LSPExtensions.cs b/src/EditorFeatures/Core/Extensions/LSPExtensions.cs new file mode 100644 index 0000000000000..84e3e448d5b73 --- /dev/null +++ b/src/EditorFeatures/Core/Extensions/LSPExtensions.cs @@ -0,0 +1,36 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Linq; + +namespace Microsoft.CodeAnalysis.Extensions; + +internal static class VSEditorLSPExtensions +{ + public static Roslyn.Core.Imaging.ImageId ToLSPImageId(this VisualStudio.Core.Imaging.ImageId imageId) + => new(imageId.Guid, imageId.Id); + + public static Roslyn.Text.Adornments.ImageElement ToLSPImageElement(this VisualStudio.Text.Adornments.ImageElement imageElement) + => new(imageElement.ImageId.ToLSPImageId(), imageElement.AutomationName); + + public static Roslyn.Text.Adornments.ClassifiedTextRun ToLSPRun(this VisualStudio.Text.Adornments.ClassifiedTextRun run) + => new(run.ClassificationTypeName, run.Text, (Roslyn.Text.Adornments.ClassifiedTextRunStyle)run.Style, run.MarkerTagType, run.NavigationAction, run.Tooltip); + + public static Roslyn.Text.Adornments.ClassifiedTextElement ToLSPElement(this VisualStudio.Text.Adornments.ClassifiedTextElement element) + => new(element.Runs.Select(r => r.ToLSPRun())); + + public static Roslyn.Text.Adornments.ContainerElement ToLSPElement(this VisualStudio.Text.Adornments.ContainerElement element) + => new((Roslyn.Text.Adornments.ContainerElementStyle)element.Style, element.Elements.Select(ToLSPElement)); + + private static object? ToLSPElement(object? value) + => value switch + { + VisualStudio.Core.Imaging.ImageId imageId => ToLSPImageId(imageId), + VisualStudio.Text.Adornments.ImageElement element => ToLSPImageElement(element), + VisualStudio.Text.Adornments.ContainerElement element => ToLSPElement(element), + VisualStudio.Text.Adornments.ClassifiedTextElement element => ToLSPElement(element), + VisualStudio.Text.Adornments.ClassifiedTextRun run => ToLSPRun(run), + _ => value, + }; +} diff --git a/src/EditorFeatures/Core/ExternalAccess/VSTypeScript/Api/AbstractVSTypeScriptRequestHandler.cs b/src/EditorFeatures/Core/ExternalAccess/VSTypeScript/Api/AbstractVSTypeScriptRequestHandler.cs index f2df904d91bce..bb128f92430dd 100644 --- a/src/EditorFeatures/Core/ExternalAccess/VSTypeScript/Api/AbstractVSTypeScriptRequestHandler.cs +++ b/src/EditorFeatures/Core/ExternalAccess/VSTypeScript/Api/AbstractVSTypeScriptRequestHandler.cs @@ -8,7 +8,7 @@ using Microsoft.CodeAnalysis.LanguageServer; using Microsoft.CodeAnalysis.LanguageServer.Handler; using Microsoft.CommonLanguageServerProtocol.Framework; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.ExternalAccess.VSTypeScript.Api; diff --git a/src/EditorFeatures/Core/ExternalAccess/VSTypeScript/Api/IVSTypeScriptCapabilitiesProvider.cs b/src/EditorFeatures/Core/ExternalAccess/VSTypeScript/Api/IVSTypeScriptCapabilitiesProvider.cs index a563d7bb42ade..f3f046f811b1b 100644 --- a/src/EditorFeatures/Core/ExternalAccess/VSTypeScript/Api/IVSTypeScriptCapabilitiesProvider.cs +++ b/src/EditorFeatures/Core/ExternalAccess/VSTypeScript/Api/IVSTypeScriptCapabilitiesProvider.cs @@ -2,9 +2,10 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.ExternalAccess.VSTypeScript.Api; + internal interface IVSTypeScriptCapabilitiesProvider { /// diff --git a/src/EditorFeatures/Core/ExternalAccess/VSTypeScript/VSTypeScriptInProcLanguageClient.cs b/src/EditorFeatures/Core/ExternalAccess/VSTypeScript/VSTypeScriptInProcLanguageClient.cs index 130dbfeb3afb7..912bb62d9e082 100644 --- a/src/EditorFeatures/Core/ExternalAccess/VSTypeScript/VSTypeScriptInProcLanguageClient.cs +++ b/src/EditorFeatures/Core/ExternalAccess/VSTypeScript/VSTypeScriptInProcLanguageClient.cs @@ -13,12 +13,11 @@ using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.LanguageServer; using Microsoft.CodeAnalysis.Options; -using Microsoft.CodeAnalysis.Shared.TestHooks; using Microsoft.VisualStudio.Composition; using Microsoft.VisualStudio.LanguageServer.Client; -using Microsoft.VisualStudio.LanguageServer.Protocol; using Microsoft.VisualStudio.Utilities; using Newtonsoft.Json; +using Roslyn.LanguageServer.Protocol; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.ExternalAccess.VSTypeScript diff --git a/src/EditorFeatures/Core/LanguageServer/AbstractInProcLanguageClient.cs b/src/EditorFeatures/Core/LanguageServer/AbstractInProcLanguageClient.cs index b22dfda918ede..59deff7f61645 100644 --- a/src/EditorFeatures/Core/LanguageServer/AbstractInProcLanguageClient.cs +++ b/src/EditorFeatures/Core/LanguageServer/AbstractInProcLanguageClient.cs @@ -17,9 +17,9 @@ using Microsoft.CommonLanguageServerProtocol.Framework; using Microsoft.VisualStudio.Composition; using Microsoft.VisualStudio.LanguageServer.Client; -using Microsoft.VisualStudio.LanguageServer.Protocol; using Microsoft.VisualStudio.Threading; using Nerdbank.Streams; +using Roslyn.LanguageServer.Protocol; using StreamJsonRpc; namespace Microsoft.CodeAnalysis.Editor.Implementation.LanguageClient diff --git a/src/EditorFeatures/Core/LanguageServer/AlwaysActivateInProcLanguageClient.cs b/src/EditorFeatures/Core/LanguageServer/AlwaysActivateInProcLanguageClient.cs index 2c0d9a3415051..bea2259bffb48 100644 --- a/src/EditorFeatures/Core/LanguageServer/AlwaysActivateInProcLanguageClient.cs +++ b/src/EditorFeatures/Core/LanguageServer/AlwaysActivateInProcLanguageClient.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System; -using System.Collections; using System.Collections.Generic; using System.Collections.Immutable; using System.ComponentModel.Composition; @@ -15,11 +14,10 @@ using Microsoft.CodeAnalysis.LanguageServer.Handler.Diagnostics; using Microsoft.CodeAnalysis.LanguageServer.Handler.SemanticTokens; using Microsoft.CodeAnalysis.Options; -using Microsoft.CodeAnalysis.Shared.TestHooks; using Microsoft.VisualStudio.Composition; using Microsoft.VisualStudio.LanguageServer.Client; -using Microsoft.VisualStudio.LanguageServer.Protocol; using Microsoft.VisualStudio.Utilities; +using Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.Editor.Implementation.LanguageClient { diff --git a/src/EditorFeatures/Core/LanguageServer/EditorHoverCreationService.cs b/src/EditorFeatures/Core/LanguageServer/EditorHoverCreationService.cs index e25ad717f4bff..70029355e3faf 100644 --- a/src/EditorFeatures/Core/LanguageServer/EditorHoverCreationService.cs +++ b/src/EditorFeatures/Core/LanguageServer/EditorHoverCreationService.cs @@ -8,12 +8,13 @@ using System.Threading.Tasks; using Microsoft.CodeAnalysis.Classification; using Microsoft.CodeAnalysis.Editor.Implementation.IntelliSense.QuickInfo; +using Microsoft.CodeAnalysis.Extensions; using Microsoft.CodeAnalysis.Formatting; using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.LanguageServer.Handler; using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.QuickInfo; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer { @@ -50,6 +51,7 @@ await document.GetLineFormattingOptionsAsync(_globalOptions, cancellationToken). asynchronousOperationListener: null, streamingPresenter: null); + var element = await IntellisenseQuickInfoBuilder.BuildContentWithoutNavigationActionsAsync(info, context, cancellationToken).ConfigureAwait(false); return new VSInternalHover { Range = ProtocolConversions.TextSpanToRange(info.Span, text), @@ -57,7 +59,7 @@ await document.GetLineFormattingOptionsAsync(_globalOptions, cancellationToken). // Build the classified text without navigation actions - they are not serializable. // TODO - Switch to markup content once it supports classifications. // https://devdiv.visualstudio.com/DevDiv/_workitems/edit/918138 - RawContent = await IntellisenseQuickInfoBuilder.BuildContentWithoutNavigationActionsAsync(info, context, cancellationToken).ConfigureAwait(false) + RawContent = element.ToLSPElement(), }; } } diff --git a/src/EditorFeatures/Core/LanguageServer/EditorLspCompletionResultCreationService.cs b/src/EditorFeatures/Core/LanguageServer/EditorLspCompletionResultCreationService.cs index 24dcd042d685e..e79d0c7744cdb 100644 --- a/src/EditorFeatures/Core/LanguageServer/EditorLspCompletionResultCreationService.cs +++ b/src/EditorFeatures/Core/LanguageServer/EditorLspCompletionResultCreationService.cs @@ -9,13 +9,14 @@ using System.Threading.Tasks; using Microsoft.CodeAnalysis.Completion; using Microsoft.CodeAnalysis.Editor.Shared.Extensions; +using Microsoft.CodeAnalysis.Extensions; using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.LanguageServer.Handler.Completion; using Microsoft.CodeAnalysis.LanguageService; using Microsoft.CodeAnalysis.Text; -using Microsoft.VisualStudio.Text.Adornments; +using Roslyn.Text.Adornments; using Roslyn.Utilities; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer { @@ -42,7 +43,7 @@ public EditorLspCompletionResultCreationService() var lspItem = new LSP.VSInternalCompletionItem { Label = item.GetEntireDisplayText(), - Icon = new ImageElement(item.Tags.GetFirstGlyph().GetImageId()) + Icon = new ImageElement(item.Tags.GetFirstGlyph().GetImageId().ToLSPImageId()), }; // Complex text edits (e.g. override and partial method completions) are always populated in the diff --git a/src/EditorFeatures/Core/LanguageServer/EditorLspReferencesResultCreationService.cs b/src/EditorFeatures/Core/LanguageServer/EditorLspReferencesResultCreationService.cs index cd39902d5abc6..4931a55761710 100644 --- a/src/EditorFeatures/Core/LanguageServer/EditorLspReferencesResultCreationService.cs +++ b/src/EditorFeatures/Core/LanguageServer/EditorLspReferencesResultCreationService.cs @@ -6,12 +6,13 @@ using System.Collections.Immutable; using System.Composition; using Microsoft.CodeAnalysis.Editor.Shared.Extensions; +using Microsoft.CodeAnalysis.Extensions; using Microsoft.CodeAnalysis.FindSymbols.Finders; using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.LanguageServer.Handler; -using Microsoft.VisualStudio.LanguageServer.Protocol; -using Microsoft.VisualStudio.Text.Adornments; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; +using Roslyn.Text.Adornments; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer { @@ -24,7 +25,7 @@ public EditorLspReferencesResultCreationService() { } - public SumType? CreateReference( + public SumType? CreateReference( int definitionId, int id, ClassifiedTextElement text, @@ -33,15 +34,16 @@ public EditorLspReferencesResultCreationService() ClassifiedTextElement? definitionText, Glyph definitionGlyph, SymbolUsageInfo? symbolUsageInfo, - VisualStudio.LanguageServer.Protocol.Location? location) + Roslyn.LanguageServer.Protocol.Location? location) { // TO-DO: The Origin property should be added once Rich-Nav is completed. // https://github.com/dotnet/roslyn/issues/42847 + var imageId = definitionGlyph.GetImageId(); var result = new VSInternalReferenceItem { DefinitionId = definitionId, DefinitionText = definitionText, // Only definitions should have a non-null DefinitionText - DefinitionIcon = new ImageElement(definitionGlyph.GetImageId()), + DefinitionIcon = new ImageElement(imageId.ToLSPImageId()), DisplayPath = location?.Uri.LocalPath, Id = id, Kind = symbolUsageInfo.HasValue ? ProtocolConversions.SymbolUsageInfoToReferenceKinds(symbolUsageInfo.Value) : Array.Empty(), diff --git a/src/EditorFeatures/Core/LanguageServer/EditorLspSymbolInformationCreationService.cs b/src/EditorFeatures/Core/LanguageServer/EditorLspSymbolInformationCreationService.cs index de4a1a09930a1..2359a42ccc472 100644 --- a/src/EditorFeatures/Core/LanguageServer/EditorLspSymbolInformationCreationService.cs +++ b/src/EditorFeatures/Core/LanguageServer/EditorLspSymbolInformationCreationService.cs @@ -7,8 +7,8 @@ using Microsoft.CodeAnalysis.Editor.Shared.Extensions; using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.LanguageServer.Handler; -using Microsoft.VisualStudio.LanguageServer.Protocol; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer { diff --git a/src/EditorFeatures/Core/LanguageServer/LiveShareInProcLanguageClient.cs b/src/EditorFeatures/Core/LanguageServer/LiveShareInProcLanguageClient.cs index 6e309a3613eb9..646d1c44a31f5 100644 --- a/src/EditorFeatures/Core/LanguageServer/LiveShareInProcLanguageClient.cs +++ b/src/EditorFeatures/Core/LanguageServer/LiveShareInProcLanguageClient.cs @@ -9,13 +9,11 @@ using Microsoft.CodeAnalysis.Editor.Shared.Utilities; using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.LanguageServer; -using Microsoft.CodeAnalysis.LanguageServer.Handler; using Microsoft.CodeAnalysis.Options; -using Microsoft.CodeAnalysis.Shared.TestHooks; using Microsoft.VisualStudio.Composition; using Microsoft.VisualStudio.LanguageServer.Client; -using Microsoft.VisualStudio.LanguageServer.Protocol; using Microsoft.VisualStudio.Utilities; +using Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.Editor.Implementation.LanguageClient { diff --git a/src/EditorFeatures/Core/LanguageServer/RazorInProcLanguageClient.cs b/src/EditorFeatures/Core/LanguageServer/RazorInProcLanguageClient.cs index 48887156637c5..be106ea02839e 100644 --- a/src/EditorFeatures/Core/LanguageServer/RazorInProcLanguageClient.cs +++ b/src/EditorFeatures/Core/LanguageServer/RazorInProcLanguageClient.cs @@ -16,8 +16,8 @@ using Microsoft.CodeAnalysis.Options; using Microsoft.VisualStudio.Composition; using Microsoft.VisualStudio.LanguageServer.Client; -using Microsoft.VisualStudio.LanguageServer.Protocol; using Microsoft.VisualStudio.Utilities; +using Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.Editor.Implementation.LanguageClient { diff --git a/src/EditorFeatures/TestUtilities/LanguageServer/AbstractLanguageServerProtocolTests.InitializationOptions.cs b/src/EditorFeatures/TestUtilities/LanguageServer/AbstractLanguageServerProtocolTests.InitializationOptions.cs index 07bee136d13a3..73429d5d17291 100644 --- a/src/EditorFeatures/TestUtilities/LanguageServer/AbstractLanguageServerProtocolTests.InitializationOptions.cs +++ b/src/EditorFeatures/TestUtilities/LanguageServer/AbstractLanguageServerProtocolTests.InitializationOptions.cs @@ -7,7 +7,7 @@ using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.LanguageServer; using Microsoft.CodeAnalysis.Options; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Roslyn.Test.Utilities { diff --git a/src/EditorFeatures/TestUtilities/LanguageServer/AbstractLanguageServerProtocolTests.cs b/src/EditorFeatures/TestUtilities/LanguageServer/AbstractLanguageServerProtocolTests.cs index 23f5f5a45b2ec..b906254e7a545 100644 --- a/src/EditorFeatures/TestUtilities/LanguageServer/AbstractLanguageServerProtocolTests.cs +++ b/src/EditorFeatures/TestUtilities/LanguageServer/AbstractLanguageServerProtocolTests.cs @@ -17,6 +17,7 @@ using Microsoft.CodeAnalysis.Editor.Test; using Microsoft.CodeAnalysis.Editor.UnitTests; using Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces; +using Microsoft.CodeAnalysis.Extensions; using Microsoft.CodeAnalysis.Host; using Microsoft.CodeAnalysis.LanguageServer; using Microsoft.CodeAnalysis.LanguageServer.Handler; @@ -37,7 +38,7 @@ using StreamJsonRpc; using Xunit; using Xunit.Abstractions; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Roslyn.Test.Utilities { @@ -102,7 +103,7 @@ public Task> MapSpansAsync(Document document, I } } - protected class OrderLocations : Comparer + private protected class OrderLocations : Comparer { public override int Compare(LSP.Location x, LSP.Location y) => CompareLocations(x, y); } @@ -112,18 +113,17 @@ protected class OrderLocations : Comparer private protected virtual TestAnalyzerReferenceByLanguage CreateTestAnalyzersReference() => new(DiagnosticExtensions.GetCompilerDiagnosticAnalyzersMap()); - protected static LSP.ClientCapabilities CapabilitiesWithVSExtensions => new LSP.VSInternalClientCapabilities { SupportsVisualStudioExtensions = true }; + private protected static LSP.ClientCapabilities CapabilitiesWithVSExtensions => new LSP.VSInternalClientCapabilities { SupportsVisualStudioExtensions = true }; - protected static LSP.ClientCapabilities GetCapabilities(bool isVS) + private protected static LSP.ClientCapabilities GetCapabilities(bool isVS) => isVS ? CapabilitiesWithVSExtensions : new LSP.ClientCapabilities(); /// /// Asserts two objects are equivalent by converting to JSON and ignoring whitespace. /// - /// the JSON object type. /// the expected object to be converted to JSON. /// the actual object to be converted to JSON. - public static void AssertJsonEquals(T expected, T actual) + public static void AssertJsonEquals(T1 expected, T2 actual) { var expectedStr = JsonConvert.SerializeObject(expected); var actualStr = JsonConvert.SerializeObject(actual); @@ -141,7 +141,7 @@ protected static void AssertEqualIgnoringWhitespace(string expected, string actu /// Assert that two location lists are equivalent. /// Locations are not always returned in a consistent order so they must be sorted. /// - protected static void AssertLocationsEqual(IEnumerable expectedLocations, IEnumerable actualLocations) + private protected static void AssertLocationsEqual(IEnumerable expectedLocations, IEnumerable actualLocations) { var orderedActualLocations = actualLocations.OrderBy(CompareLocations); var orderedExpectedLocations = expectedLocations.OrderBy(CompareLocations); @@ -149,21 +149,21 @@ protected static void AssertLocationsEqual(IEnumerable expectedLoc AssertJsonEquals(orderedExpectedLocations, orderedActualLocations); } - protected static int CompareLocations(LSP.Location l1, LSP.Location l2) + private protected static int CompareLocations(LSP.Location l1, LSP.Location l2) { var compareDocument = l1.Uri.AbsoluteUri.CompareTo(l2.Uri.AbsoluteUri); var compareRange = CompareRange(l1.Range, l2.Range); return compareDocument != 0 ? compareDocument : compareRange; } - protected static int CompareRange(LSP.Range r1, LSP.Range r2) + private protected static int CompareRange(LSP.Range r1, LSP.Range r2) { var compareLine = r1.Start.Line.CompareTo(r2.Start.Line); var compareChar = r1.Start.Character.CompareTo(r2.Start.Character); return compareLine != 0 ? compareLine : compareChar; } - protected static string ApplyTextEdits(LSP.TextEdit[] edits, SourceText originalMarkup) + private protected static string ApplyTextEdits(LSP.TextEdit[] edits, SourceText originalMarkup) { var text = originalMarkup; foreach (var edit in edits) @@ -196,7 +196,7 @@ internal static LSP.SymbolInformation CreateSymbolInformation(LSP.SymbolKind kin return info; } - protected static LSP.TextDocumentIdentifier CreateTextDocumentIdentifier(Uri uri, ProjectId? projectContext = null) + private protected static LSP.TextDocumentIdentifier CreateTextDocumentIdentifier(Uri uri, ProjectId? projectContext = null) { var documentIdentifier = new LSP.VSTextDocumentIdentifier { Uri = uri }; @@ -209,21 +209,21 @@ protected static LSP.TextDocumentIdentifier CreateTextDocumentIdentifier(Uri uri return documentIdentifier; } - protected static LSP.TextDocumentPositionParams CreateTextDocumentPositionParams(LSP.Location caret, ProjectId? projectContext = null) + private protected static LSP.TextDocumentPositionParams CreateTextDocumentPositionParams(LSP.Location caret, ProjectId? projectContext = null) => new LSP.TextDocumentPositionParams() { TextDocument = CreateTextDocumentIdentifier(caret.Uri, projectContext), Position = caret.Range.Start }; - protected static LSP.MarkupContent CreateMarkupContent(LSP.MarkupKind kind, string value) + private protected static LSP.MarkupContent CreateMarkupContent(LSP.MarkupKind kind, string value) => new LSP.MarkupContent() { Kind = kind, Value = value }; - protected static LSP.CompletionParams CreateCompletionParams( + private protected static LSP.CompletionParams CreateCompletionParams( LSP.Location caret, LSP.VSInternalCompletionInvokeKind invokeKind, string triggerCharacter, @@ -240,7 +240,7 @@ protected static LSP.CompletionParams CreateCompletionParams( } }; - protected static async Task CreateCompletionItemAsync( + private protected static async Task CreateCompletionItemAsync( string label, LSP.CompletionItemKind kind, string[] tags, @@ -280,7 +280,7 @@ protected static LSP.CompletionParams CreateCompletionParams( }; if (tags != null) - item.Icon = tags.ToImmutableArray().GetFirstGlyph().GetImageElement(); + item.Icon = tags.ToImmutableArray().GetFirstGlyph().GetImageElement().ToLSPImageElement(); if (commitCharacters != null) item.CommitCharacters = commitCharacters.Value.Select(c => c.ToString()).ToArray(); @@ -288,7 +288,7 @@ protected static LSP.CompletionParams CreateCompletionParams( return item; } - protected static LSP.TextEdit GenerateTextEdit(string newText, int startLine, int startChar, int endLine, int endChar) + private protected static LSP.TextEdit GenerateTextEdit(string newText, int startLine, int startChar, int endLine, int endChar) => new LSP.TextEdit { NewText = newText, @@ -441,7 +441,7 @@ protected static void AddMappedDocument(Workspace workspace, string markup) workspace.TryApplyChanges(newSolution); } - public static async Task>> GetAnnotatedLocationsAsync(TestWorkspace workspace, Solution solution) + internal static async Task>> GetAnnotatedLocationsAsync(TestWorkspace workspace, Solution solution) { var locations = new Dictionary>(); foreach (var testDocument in workspace.Documents) @@ -475,7 +475,7 @@ static LSP.Location ConvertTextSpanWithTextToLocation(TextSpan span, SourceText } } - protected static LSP.Location GetLocationPlusOne(LSP.Location originalLocation) + private protected static LSP.Location GetLocationPlusOne(LSP.Location originalLocation) { var newPosition = new LSP.Position { Character = originalLocation.Range.Start.Character + 1, Line = originalLocation.Range.Start.Line }; return new LSP.Location diff --git a/src/EditorFeatures/TestUtilities/Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities.csproj b/src/EditorFeatures/TestUtilities/Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities.csproj index 478f9de53cc99..95e0b2c87eaef 100644 --- a/src/EditorFeatures/TestUtilities/Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities.csproj +++ b/src/EditorFeatures/TestUtilities/Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities.csproj @@ -93,6 +93,7 @@ + diff --git a/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer.UnitTests/LspFileChangeWatcherTests.cs b/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer.UnitTests/LspFileChangeWatcherTests.cs index 56b21809f6b2b..c7b1b6b940865 100644 --- a/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer.UnitTests/LspFileChangeWatcherTests.cs +++ b/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer.UnitTests/LspFileChangeWatcherTests.cs @@ -6,12 +6,12 @@ using Microsoft.CodeAnalysis.LanguageServer.HostWorkspace.FileWatching; using Microsoft.CodeAnalysis.Shared.TestHooks; using Microsoft.CodeAnalysis.Test.Utilities; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using StreamJsonRpc; using Xunit.Abstractions; -using FileSystemWatcher = Microsoft.VisualStudio.LanguageServer.Protocol.FileSystemWatcher; +using FileSystemWatcher = Roslyn.LanguageServer.Protocol.FileSystemWatcher; namespace Microsoft.CodeAnalysis.LanguageServer.UnitTests; diff --git a/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer.UnitTests/ServerInitializationTests.cs b/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer.UnitTests/ServerInitializationTests.cs index 68de69c6802ca..e0b3bc0a79f96 100644 --- a/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer.UnitTests/ServerInitializationTests.cs +++ b/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer.UnitTests/ServerInitializationTests.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Xunit.Abstractions; namespace Microsoft.CodeAnalysis.LanguageServer.UnitTests; @@ -37,7 +37,7 @@ public async Task TestServerHandlesTextSyncRequestsAsync() [ new TextDocumentContentChangeEvent { - Range = new VisualStudio.LanguageServer.Protocol.Range { Start = new Position(0, 0), End = new Position(0, 0) }, + Range = new Roslyn.LanguageServer.Protocol.Range { Start = new Position(0, 0), End = new Position(0, 0) }, Text = "Console." } ] diff --git a/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer.UnitTests/Utilities/AbstractLanguageServerHostTests.cs b/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer.UnitTests/Utilities/AbstractLanguageServerHostTests.cs index 0d0e52c99dc8e..628c98933de55 100644 --- a/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer.UnitTests/Utilities/AbstractLanguageServerHostTests.cs +++ b/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer.UnitTests/Utilities/AbstractLanguageServerHostTests.cs @@ -5,9 +5,8 @@ using Microsoft.CodeAnalysis.LanguageServer.LanguageServer; using Microsoft.Extensions.Logging; using Microsoft.VisualStudio.Composition; -using Microsoft.VisualStudio.LanguageServer.Protocol; using Nerdbank.Streams; -using Roslyn.Utilities; +using Roslyn.LanguageServer.Protocol; using StreamJsonRpc; using Xunit.Abstractions; @@ -32,7 +31,7 @@ protected sealed class TestLspServer : IAsyncDisposable private readonly Task _languageServerHostCompletionTask; private readonly JsonRpc _clientRpc; - public static async Task CreateAsync(ClientCapabilities clientCapabilities, TestOutputLogger logger, bool includeDevKitComponents = true) + internal static async Task CreateAsync(ClientCapabilities clientCapabilities, TestOutputLogger logger, bool includeDevKitComponents = true) { var exportProvider = await LanguageServerTestComposition.CreateExportProviderAsync(logger.Factory, includeDevKitComponents); var testLspServer = new TestLspServer(exportProvider, logger); diff --git a/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/BrokeredServices/ServiceBrokerConnectHandler.cs b/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/BrokeredServices/ServiceBrokerConnectHandler.cs index ea8dc39c00e83..8c6d5c693539c 100644 --- a/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/BrokeredServices/ServiceBrokerConnectHandler.cs +++ b/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/BrokeredServices/ServiceBrokerConnectHandler.cs @@ -2,17 +2,11 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using System; -using System.Collections.Generic; using System.Composition; -using System.Linq; using System.Runtime.Serialization; -using System.Text; -using System.Threading.Tasks; using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.LanguageServer.Handler; using Microsoft.CommonLanguageServerProtocol.Framework; -using Microsoft.VisualStudio.Text.Editor.Commanding.Commands; namespace Microsoft.CodeAnalysis.LanguageServer.BrokeredServices; diff --git a/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/FileWatching/LspContractTypes.cs b/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/FileWatching/LspContractTypes.cs index 7635ee9c55452..89a3613e08fe5 100644 --- a/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/FileWatching/LspContractTypes.cs +++ b/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/FileWatching/LspContractTypes.cs @@ -5,7 +5,7 @@ using System.Runtime.Serialization; using Newtonsoft.Json; -namespace Microsoft.VisualStudio.LanguageServer.Protocol; +namespace Roslyn.LanguageServer.Protocol; [DataContract] internal class DidChangeWatchedFilesRegistrationOptions diff --git a/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/FileWatching/LspDidChangeWatchedFilesHandler.cs b/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/FileWatching/LspDidChangeWatchedFilesHandler.cs index 04faf2d4433a3..da93cef394d36 100644 --- a/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/FileWatching/LspDidChangeWatchedFilesHandler.cs +++ b/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/FileWatching/LspDidChangeWatchedFilesHandler.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. @@ -6,7 +6,7 @@ using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.LanguageServer.Handler; using Microsoft.CommonLanguageServerProtocol.Framework; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.HostWorkspace.FileWatching; @@ -30,4 +30,4 @@ Task INotificationHandler.HandleNot } public event EventHandler? NotificationRaised; -} \ No newline at end of file +} diff --git a/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/FileWatching/LspFileChangeWatcher.cs b/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/FileWatching/LspFileChangeWatcher.cs index 33e4e58dad4b5..a6e3d506bf119 100644 --- a/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/FileWatching/LspFileChangeWatcher.cs +++ b/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/FileWatching/LspFileChangeWatcher.cs @@ -2,15 +2,15 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using System.Collections.Immutable; +using Microsoft.CodeAnalysis.LanguageServer.Handler; using Microsoft.CodeAnalysis.LanguageServer.LanguageServer; using Microsoft.CodeAnalysis.ProjectSystem; using Microsoft.CodeAnalysis.Shared.TestHooks; -using Microsoft.VisualStudio.LanguageServer.Protocol; -using System.Collections.Immutable; +using Roslyn.LanguageServer.Protocol; using Roslyn.Utilities; -using FileSystemWatcher = Microsoft.VisualStudio.LanguageServer.Protocol.FileSystemWatcher; -using Microsoft.CodeAnalysis.LanguageServer.Handler; using StreamJsonRpc; +using FileSystemWatcher = Roslyn.LanguageServer.Protocol.FileSystemWatcher; namespace Microsoft.CodeAnalysis.LanguageServer.HostWorkspace.FileWatching; diff --git a/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/LanguageServerProjectSystem.cs b/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/LanguageServerProjectSystem.cs index 488ef5e0b26fa..920570ab596fc 100644 --- a/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/LanguageServerProjectSystem.cs +++ b/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/LanguageServerProjectSystem.cs @@ -14,7 +14,6 @@ using Microsoft.CodeAnalysis.MSBuild; using Microsoft.CodeAnalysis.MSBuild.Logging; using Microsoft.CodeAnalysis.Options; -using Microsoft.CodeAnalysis.PooledObjects; using Microsoft.CodeAnalysis.ProjectSystem; using Microsoft.CodeAnalysis.Shared.TestHooks; using Microsoft.CodeAnalysis.Workspaces.ProjectSystem; @@ -22,7 +21,7 @@ using Microsoft.VisualStudio.Composition; using Roslyn.Utilities; using static Microsoft.CodeAnalysis.MSBuild.BuildHostProcessManager; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.HostWorkspace; diff --git a/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/LanguageServerWorkspace.cs b/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/LanguageServerWorkspace.cs index 9a1526d3d49fe..4d4268f4a1db0 100644 --- a/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/LanguageServerWorkspace.cs +++ b/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/LanguageServerWorkspace.cs @@ -2,11 +2,10 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using System.Collections.Immutable; using Microsoft.CodeAnalysis.Host; using Microsoft.CodeAnalysis.Text; using Microsoft.CodeAnalysis.Workspaces.ProjectSystem; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.HostWorkspace; diff --git a/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/LanguageServer/Handler/DebugConfiguration/WorkspaceDebugConfigurationParams.cs b/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/LanguageServer/Handler/DebugConfiguration/WorkspaceDebugConfigurationParams.cs index a286f9bdf9f4a..1d3b795be6ba1 100644 --- a/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/LanguageServer/Handler/DebugConfiguration/WorkspaceDebugConfigurationParams.cs +++ b/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/LanguageServer/Handler/DebugConfiguration/WorkspaceDebugConfigurationParams.cs @@ -2,10 +2,9 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using System; using System.Runtime.Serialization; -using Microsoft.VisualStudio.LanguageServer.Protocol; using Newtonsoft.Json; +using Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler.DebugConfiguration; diff --git a/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/LanguageServer/Handler/Restore/RestoreParams.cs b/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/LanguageServer/Handler/Restore/RestoreParams.cs index 8be4c80ef0e46..44bf12762fc65 100644 --- a/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/LanguageServer/Handler/Restore/RestoreParams.cs +++ b/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/LanguageServer/Handler/Restore/RestoreParams.cs @@ -3,8 +3,8 @@ // See the LICENSE file in the project root for more information. using System.Runtime.Serialization; -using Microsoft.VisualStudio.LanguageServer.Protocol; using Newtonsoft.Json; +using Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler; diff --git a/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/LanguageServer/ServerCapabilitiesProvider.cs b/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/LanguageServer/ServerCapabilitiesProvider.cs index 1b8b495b941ef..cc21693eb3c6e 100644 --- a/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/LanguageServer/ServerCapabilitiesProvider.cs +++ b/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/LanguageServer/ServerCapabilitiesProvider.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.LanguageServer; diff --git a/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/Logging/LspLogMessageLogger.cs b/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/Logging/LspLogMessageLogger.cs index 24437f41ce921..dbacfd7867b96 100644 --- a/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/Logging/LspLogMessageLogger.cs +++ b/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/Logging/LspLogMessageLogger.cs @@ -2,11 +2,9 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using System.Composition; using Microsoft.CodeAnalysis.LanguageServer.LanguageServer; using Microsoft.Extensions.Logging; -using Microsoft.VisualStudio.LanguageServer.Protocol; -using StreamJsonRpc; +using Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Logging; diff --git a/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/Logging/ShowToastNotification.cs b/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/Logging/ShowToastNotification.cs index 9690e247e0a8a..b9b7ea2f7a8b8 100644 --- a/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/Logging/ShowToastNotification.cs +++ b/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/Logging/ShowToastNotification.cs @@ -5,7 +5,7 @@ using System.Runtime.Serialization; using Microsoft.CodeAnalysis.LanguageServer.LanguageServer; using Roslyn.Utilities; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer; diff --git a/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/Microsoft.CodeAnalysis.LanguageServer.csproj b/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/Microsoft.CodeAnalysis.LanguageServer.csproj index ee87a9ae047e7..57331ae211af7 100644 --- a/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/Microsoft.CodeAnalysis.LanguageServer.csproj +++ b/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/Microsoft.CodeAnalysis.LanguageServer.csproj @@ -79,7 +79,6 @@ - diff --git a/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/Testing/RunTestsHandler.cs b/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/Testing/RunTestsHandler.cs index ea6be6641855b..59314c35dee47 100644 --- a/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/Testing/RunTestsHandler.cs +++ b/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/Testing/RunTestsHandler.cs @@ -10,7 +10,7 @@ using Microsoft.Extensions.Logging; using Microsoft.TestPlatform.VsTestConsole.TranslationLayer; using Roslyn.Utilities; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Testing; diff --git a/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/Testing/TestDiscoverer.cs b/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/Testing/TestDiscoverer.cs index 3aea99770153b..62bfe8514d51c 100644 --- a/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/Testing/TestDiscoverer.cs +++ b/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/Testing/TestDiscoverer.cs @@ -14,7 +14,7 @@ using Microsoft.TestPlatform.VsTestConsole.TranslationLayer; using Microsoft.VisualStudio.TestPlatform.ObjectModel; using Roslyn.Utilities; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Testing; diff --git a/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework.Example/CapabilitiesManager.cs b/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework.Example/CapabilitiesManager.cs index 9fa2db348e9bb..a13a2965ecfda 100644 --- a/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework.Example/CapabilitiesManager.cs +++ b/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework.Example/CapabilitiesManager.cs @@ -3,7 +3,7 @@ // See the LICENSE file in the project root for more information. using System; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; namespace Microsoft.CommonLanguageServerProtocol.Framework.Example; diff --git a/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework.Example/ExampleLanguageServer.cs b/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework.Example/ExampleLanguageServer.cs index 6b52478246d36..5c2fc79a0c3b4 100644 --- a/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework.Example/ExampleLanguageServer.cs +++ b/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework.Example/ExampleLanguageServer.cs @@ -5,7 +5,7 @@ using System; using Microsoft.CommonLanguageServerProtocol.Framework.Handlers; using Microsoft.Extensions.DependencyInjection; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using StreamJsonRpc; namespace Microsoft.CommonLanguageServerProtocol.Framework.Example; diff --git a/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework.Example/Microsoft.CommonLanguageServerProtocol.Framework.Example.csproj b/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework.Example/Microsoft.CommonLanguageServerProtocol.Framework.Example.csproj index 611886a1afede..b4507a11df45b 100644 --- a/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework.Example/Microsoft.CommonLanguageServerProtocol.Framework.Example.csproj +++ b/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework.Example/Microsoft.CommonLanguageServerProtocol.Framework.Example.csproj @@ -11,10 +11,10 @@ - + diff --git a/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework.Example/MultiRegisteringHandler.cs b/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework.Example/MultiRegisteringHandler.cs index 3cfcaf701705d..52e7823adde8e 100644 --- a/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework.Example/MultiRegisteringHandler.cs +++ b/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework.Example/MultiRegisteringHandler.cs @@ -4,7 +4,7 @@ using System.Threading; using System.Threading.Tasks; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; namespace Microsoft.CommonLanguageServerProtocol.Framework.Example; @@ -16,19 +16,19 @@ public class MultiRegisteringHandler : public bool MutatesSolutionState => throw new System.NotImplementedException(); [LanguageServerEndpoint(Methods.TextDocumentDidCloseName)] - public Task HandleNotificationAsync(DidCloseTextDocumentParams request, ExampleRequestContext requestContext, CancellationToken cancellationToken) + Task INotificationHandler.HandleNotificationAsync(DidCloseTextDocumentParams request, ExampleRequestContext requestContext, CancellationToken cancellationToken) { throw new System.NotImplementedException(); } [LanguageServerEndpoint(Methods.TextDocumentDidOpenName)] - public Task HandleRequestAsync(DidOpenTextDocumentParams request, ExampleRequestContext context, CancellationToken cancellationToken) + Task IRequestHandler.HandleRequestAsync(DidOpenTextDocumentParams request, ExampleRequestContext context, CancellationToken cancellationToken) { throw new System.NotImplementedException(); } [LanguageServerEndpoint(Methods.TextDocumentDidChangeName)] - public Task HandleRequestAsync(DidChangeTextDocumentParams request, ExampleRequestContext context, CancellationToken cancellationToken) + Task IRequestHandler.HandleRequestAsync(DidChangeTextDocumentParams request, ExampleRequestContext context, CancellationToken cancellationToken) { throw new System.NotImplementedException(); } diff --git a/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework.UnitTests/ExampleTests.cs b/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework.UnitTests/ExampleTests.cs index 9fc80b18c4c62..844c1de5cd591 100644 --- a/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework.UnitTests/ExampleTests.cs +++ b/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework.UnitTests/ExampleTests.cs @@ -4,7 +4,7 @@ using System; using System.Threading.Tasks; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Xunit; namespace Microsoft.CommonLanguageServerProtocol.Framework.UnitTests; diff --git a/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework.UnitTests/TestExampleLanguageServer.cs b/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework.UnitTests/TestExampleLanguageServer.cs index 00812d946b36f..a5ac7d0ca75ac 100644 --- a/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework.UnitTests/TestExampleLanguageServer.cs +++ b/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework.UnitTests/TestExampleLanguageServer.cs @@ -7,11 +7,10 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.CommonLanguageServerProtocol.Framework.Example; -using Microsoft.CommonLanguageServerProtocol.Framework; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Microsoft.Extensions.DependencyInjection; using Nerdbank.Streams; +using Roslyn.LanguageServer.Protocol; using StreamJsonRpc; -using Microsoft.Extensions.DependencyInjection; namespace Microsoft.CommonLanguageServerProtocol.Framework.UnitTests; @@ -166,7 +165,7 @@ public class ExtraDidOpenHandler : { public bool MutatesSolutionState => throw new System.NotImplementedException(); - public Task HandleRequestAsync(DidOpenTextDocumentParams request, ExampleRequestContext context, CancellationToken cancellationToken) + Task IRequestHandler.HandleRequestAsync(DidOpenTextDocumentParams request, ExampleRequestContext context, CancellationToken cancellationToken) { throw new System.NotImplementedException(); } diff --git a/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/HandlerProvider.cs b/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/HandlerProvider.cs index 9d79e5d74451c..5f3a335083a4f 100644 --- a/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/HandlerProvider.cs +++ b/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/HandlerProvider.cs @@ -134,20 +134,50 @@ static string GetRequestHandlerMethod(Type handlerType, Type? requestType, Type static LanguageServerEndpointAttribute? GetMethodAttributeFromHandlerMethod(Type handlerType, Type? requestType, Type contextType, Type? responseType) { - var methodInfo = (requestType != null, responseType != null) switch + const string handleRequestName = nameof(IRequestHandler.HandleRequestAsync); + const string handleNotificationName = nameof(INotificationHandler.HandleNotificationAsync); + + foreach (var methodInfo in handlerType.GetRuntimeMethods()) { - (true, true) => handlerType.GetMethod(nameof(IRequestHandler.HandleRequestAsync), new Type[] { requestType!, contextType, typeof(CancellationToken) }), - (false, true) => handlerType.GetMethod(nameof(IRequestHandler.HandleRequestAsync), new Type[] { contextType, typeof(CancellationToken) }), - (true, false) => handlerType.GetMethod(nameof(INotificationHandler.HandleNotificationAsync), new Type[] { requestType!, contextType, typeof(CancellationToken) }), - (false, false) => handlerType.GetMethod(nameof(INotificationHandler.HandleNotificationAsync), new Type[] { contextType, typeof(CancellationToken) }) - }; + if (MethodInfoMatches(methodInfo)) + return methodInfo.GetCustomAttribute(); + } + + throw new InvalidOperationException("Somehow we are missing the method for our registered handler"); - if (methodInfo is null) + bool MethodInfoMatches(MethodInfo methodInfo) { - throw new InvalidOperationException("Somehow we are missing the method for our registered handler"); + switch (requestType != null, responseType != null) + { + case (true, true): + return (methodInfo.Name == handleRequestName || methodInfo.Name.EndsWith("." + handleRequestName)) && + TypesMatch(methodInfo, [requestType!, contextType, typeof(CancellationToken)]); + case (false, true): + return (methodInfo.Name == handleRequestName || methodInfo.Name.EndsWith("." + handleRequestName)) && + TypesMatch(methodInfo, [contextType, typeof(CancellationToken)]); + case (true, false): + return (methodInfo.Name == handleNotificationName || methodInfo.Name.EndsWith("." + handleNotificationName)) && + TypesMatch(methodInfo, [requestType!, contextType, typeof(CancellationToken)]); + case (false, false): + return (methodInfo.Name == handleNotificationName || methodInfo.Name.EndsWith("." + handleNotificationName)) && + TypesMatch(methodInfo, [contextType, typeof(CancellationToken)]); + } } - return methodInfo.GetCustomAttribute(); + bool TypesMatch(MethodInfo methodInfo, Type[] types) + { + var parameters = methodInfo.GetParameters(); + if (parameters.Length != types.Length) + return false; + + for (int i = 0, n = parameters.Length; i < n; i++) + { + if (!Equals(types[i], parameters[i].ParameterType)) + return false; + } + + return true; + } } static LanguageServerEndpointAttribute? GetMethodAttributeFromClassOrInterface(Type type) diff --git a/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/xlf/LSPFrameworkResources.cs.xlf b/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/xlf/LSPFrameworkResources.cs.xlf new file mode 100644 index 0000000000000..ac445cd3039c9 --- /dev/null +++ b/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/xlf/LSPFrameworkResources.cs.xlf @@ -0,0 +1,42 @@ + + + + + + Unable to deserialize Uri. Unexpected value encountered: {0} + Unable to deserialize Uri. Unexpected value encountered: {0} + + + + Unable to deserialize MarkupContent. Unexpected value encountered: {0} + Unable to deserialize MarkupContent. Unexpected value encountered: {0} + + + + A SumType cannot have another SumType as type parameter. + A SumType cannot have another SumType as type parameter. + + + + None of the SumType type parameters could be deserialized + None of the SumType type parameters could be deserialized + + + + Type {0} is missing a contructor that takes a single string as parameter. + Type {0} is missing a contructor that takes a single string as parameter. + + + + Unable to deserialize string-based enum. Unexpected data encountered: {0} + Unable to deserialize string-based enum. Unexpected data encountered: {0} + + + + Unable to deserialize TextDocumentSyncOptions. Unexpected value encountered: {0} + Unable to deserialize TextDocumentSyncOptions. Unexpected value encountered: {0} + + + + + \ No newline at end of file diff --git a/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/xlf/LSPFrameworkResources.de.xlf b/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/xlf/LSPFrameworkResources.de.xlf new file mode 100644 index 0000000000000..83fa691c9f6e9 --- /dev/null +++ b/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/xlf/LSPFrameworkResources.de.xlf @@ -0,0 +1,42 @@ + + + + + + Unable to deserialize Uri. Unexpected value encountered: {0} + Unable to deserialize Uri. Unexpected value encountered: {0} + + + + Unable to deserialize MarkupContent. Unexpected value encountered: {0} + Unable to deserialize MarkupContent. Unexpected value encountered: {0} + + + + A SumType cannot have another SumType as type parameter. + A SumType cannot have another SumType as type parameter. + + + + None of the SumType type parameters could be deserialized + None of the SumType type parameters could be deserialized + + + + Type {0} is missing a contructor that takes a single string as parameter. + Type {0} is missing a contructor that takes a single string as parameter. + + + + Unable to deserialize string-based enum. Unexpected data encountered: {0} + Unable to deserialize string-based enum. Unexpected data encountered: {0} + + + + Unable to deserialize TextDocumentSyncOptions. Unexpected value encountered: {0} + Unable to deserialize TextDocumentSyncOptions. Unexpected value encountered: {0} + + + + + \ No newline at end of file diff --git a/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/xlf/LSPFrameworkResources.es.xlf b/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/xlf/LSPFrameworkResources.es.xlf new file mode 100644 index 0000000000000..5c46b41f26f45 --- /dev/null +++ b/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/xlf/LSPFrameworkResources.es.xlf @@ -0,0 +1,42 @@ + + + + + + Unable to deserialize Uri. Unexpected value encountered: {0} + Unable to deserialize Uri. Unexpected value encountered: {0} + + + + Unable to deserialize MarkupContent. Unexpected value encountered: {0} + Unable to deserialize MarkupContent. Unexpected value encountered: {0} + + + + A SumType cannot have another SumType as type parameter. + A SumType cannot have another SumType as type parameter. + + + + None of the SumType type parameters could be deserialized + None of the SumType type parameters could be deserialized + + + + Type {0} is missing a contructor that takes a single string as parameter. + Type {0} is missing a contructor that takes a single string as parameter. + + + + Unable to deserialize string-based enum. Unexpected data encountered: {0} + Unable to deserialize string-based enum. Unexpected data encountered: {0} + + + + Unable to deserialize TextDocumentSyncOptions. Unexpected value encountered: {0} + Unable to deserialize TextDocumentSyncOptions. Unexpected value encountered: {0} + + + + + \ No newline at end of file diff --git a/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/xlf/LSPFrameworkResources.fr.xlf b/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/xlf/LSPFrameworkResources.fr.xlf new file mode 100644 index 0000000000000..2e20e4a3055ae --- /dev/null +++ b/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/xlf/LSPFrameworkResources.fr.xlf @@ -0,0 +1,42 @@ + + + + + + Unable to deserialize Uri. Unexpected value encountered: {0} + Unable to deserialize Uri. Unexpected value encountered: {0} + + + + Unable to deserialize MarkupContent. Unexpected value encountered: {0} + Unable to deserialize MarkupContent. Unexpected value encountered: {0} + + + + A SumType cannot have another SumType as type parameter. + A SumType cannot have another SumType as type parameter. + + + + None of the SumType type parameters could be deserialized + None of the SumType type parameters could be deserialized + + + + Type {0} is missing a contructor that takes a single string as parameter. + Type {0} is missing a contructor that takes a single string as parameter. + + + + Unable to deserialize string-based enum. Unexpected data encountered: {0} + Unable to deserialize string-based enum. Unexpected data encountered: {0} + + + + Unable to deserialize TextDocumentSyncOptions. Unexpected value encountered: {0} + Unable to deserialize TextDocumentSyncOptions. Unexpected value encountered: {0} + + + + + \ No newline at end of file diff --git a/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/xlf/LSPFrameworkResources.it.xlf b/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/xlf/LSPFrameworkResources.it.xlf new file mode 100644 index 0000000000000..fe05ff652f7cf --- /dev/null +++ b/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/xlf/LSPFrameworkResources.it.xlf @@ -0,0 +1,42 @@ + + + + + + Unable to deserialize Uri. Unexpected value encountered: {0} + Unable to deserialize Uri. Unexpected value encountered: {0} + + + + Unable to deserialize MarkupContent. Unexpected value encountered: {0} + Unable to deserialize MarkupContent. Unexpected value encountered: {0} + + + + A SumType cannot have another SumType as type parameter. + A SumType cannot have another SumType as type parameter. + + + + None of the SumType type parameters could be deserialized + None of the SumType type parameters could be deserialized + + + + Type {0} is missing a contructor that takes a single string as parameter. + Type {0} is missing a contructor that takes a single string as parameter. + + + + Unable to deserialize string-based enum. Unexpected data encountered: {0} + Unable to deserialize string-based enum. Unexpected data encountered: {0} + + + + Unable to deserialize TextDocumentSyncOptions. Unexpected value encountered: {0} + Unable to deserialize TextDocumentSyncOptions. Unexpected value encountered: {0} + + + + + \ No newline at end of file diff --git a/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/xlf/LSPFrameworkResources.ja.xlf b/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/xlf/LSPFrameworkResources.ja.xlf new file mode 100644 index 0000000000000..3d48c2e5ab0ba --- /dev/null +++ b/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/xlf/LSPFrameworkResources.ja.xlf @@ -0,0 +1,42 @@ + + + + + + Unable to deserialize Uri. Unexpected value encountered: {0} + Unable to deserialize Uri. Unexpected value encountered: {0} + + + + Unable to deserialize MarkupContent. Unexpected value encountered: {0} + Unable to deserialize MarkupContent. Unexpected value encountered: {0} + + + + A SumType cannot have another SumType as type parameter. + A SumType cannot have another SumType as type parameter. + + + + None of the SumType type parameters could be deserialized + None of the SumType type parameters could be deserialized + + + + Type {0} is missing a contructor that takes a single string as parameter. + Type {0} is missing a contructor that takes a single string as parameter. + + + + Unable to deserialize string-based enum. Unexpected data encountered: {0} + Unable to deserialize string-based enum. Unexpected data encountered: {0} + + + + Unable to deserialize TextDocumentSyncOptions. Unexpected value encountered: {0} + Unable to deserialize TextDocumentSyncOptions. Unexpected value encountered: {0} + + + + + \ No newline at end of file diff --git a/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/xlf/LSPFrameworkResources.ko.xlf b/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/xlf/LSPFrameworkResources.ko.xlf new file mode 100644 index 0000000000000..e46f273675690 --- /dev/null +++ b/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/xlf/LSPFrameworkResources.ko.xlf @@ -0,0 +1,42 @@ + + + + + + Unable to deserialize Uri. Unexpected value encountered: {0} + Unable to deserialize Uri. Unexpected value encountered: {0} + + + + Unable to deserialize MarkupContent. Unexpected value encountered: {0} + Unable to deserialize MarkupContent. Unexpected value encountered: {0} + + + + A SumType cannot have another SumType as type parameter. + A SumType cannot have another SumType as type parameter. + + + + None of the SumType type parameters could be deserialized + None of the SumType type parameters could be deserialized + + + + Type {0} is missing a contructor that takes a single string as parameter. + Type {0} is missing a contructor that takes a single string as parameter. + + + + Unable to deserialize string-based enum. Unexpected data encountered: {0} + Unable to deserialize string-based enum. Unexpected data encountered: {0} + + + + Unable to deserialize TextDocumentSyncOptions. Unexpected value encountered: {0} + Unable to deserialize TextDocumentSyncOptions. Unexpected value encountered: {0} + + + + + \ No newline at end of file diff --git a/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/xlf/LSPFrameworkResources.pl.xlf b/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/xlf/LSPFrameworkResources.pl.xlf new file mode 100644 index 0000000000000..cd4c0e191952a --- /dev/null +++ b/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/xlf/LSPFrameworkResources.pl.xlf @@ -0,0 +1,42 @@ + + + + + + Unable to deserialize Uri. Unexpected value encountered: {0} + Unable to deserialize Uri. Unexpected value encountered: {0} + + + + Unable to deserialize MarkupContent. Unexpected value encountered: {0} + Unable to deserialize MarkupContent. Unexpected value encountered: {0} + + + + A SumType cannot have another SumType as type parameter. + A SumType cannot have another SumType as type parameter. + + + + None of the SumType type parameters could be deserialized + None of the SumType type parameters could be deserialized + + + + Type {0} is missing a contructor that takes a single string as parameter. + Type {0} is missing a contructor that takes a single string as parameter. + + + + Unable to deserialize string-based enum. Unexpected data encountered: {0} + Unable to deserialize string-based enum. Unexpected data encountered: {0} + + + + Unable to deserialize TextDocumentSyncOptions. Unexpected value encountered: {0} + Unable to deserialize TextDocumentSyncOptions. Unexpected value encountered: {0} + + + + + \ No newline at end of file diff --git a/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/xlf/LSPFrameworkResources.pt-BR.xlf b/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/xlf/LSPFrameworkResources.pt-BR.xlf new file mode 100644 index 0000000000000..2ef659b73389d --- /dev/null +++ b/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/xlf/LSPFrameworkResources.pt-BR.xlf @@ -0,0 +1,42 @@ + + + + + + Unable to deserialize Uri. Unexpected value encountered: {0} + Unable to deserialize Uri. Unexpected value encountered: {0} + + + + Unable to deserialize MarkupContent. Unexpected value encountered: {0} + Unable to deserialize MarkupContent. Unexpected value encountered: {0} + + + + A SumType cannot have another SumType as type parameter. + A SumType cannot have another SumType as type parameter. + + + + None of the SumType type parameters could be deserialized + None of the SumType type parameters could be deserialized + + + + Type {0} is missing a contructor that takes a single string as parameter. + Type {0} is missing a contructor that takes a single string as parameter. + + + + Unable to deserialize string-based enum. Unexpected data encountered: {0} + Unable to deserialize string-based enum. Unexpected data encountered: {0} + + + + Unable to deserialize TextDocumentSyncOptions. Unexpected value encountered: {0} + Unable to deserialize TextDocumentSyncOptions. Unexpected value encountered: {0} + + + + + \ No newline at end of file diff --git a/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/xlf/LSPFrameworkResources.ru.xlf b/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/xlf/LSPFrameworkResources.ru.xlf new file mode 100644 index 0000000000000..35165d53b051f --- /dev/null +++ b/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/xlf/LSPFrameworkResources.ru.xlf @@ -0,0 +1,42 @@ + + + + + + Unable to deserialize Uri. Unexpected value encountered: {0} + Unable to deserialize Uri. Unexpected value encountered: {0} + + + + Unable to deserialize MarkupContent. Unexpected value encountered: {0} + Unable to deserialize MarkupContent. Unexpected value encountered: {0} + + + + A SumType cannot have another SumType as type parameter. + A SumType cannot have another SumType as type parameter. + + + + None of the SumType type parameters could be deserialized + None of the SumType type parameters could be deserialized + + + + Type {0} is missing a contructor that takes a single string as parameter. + Type {0} is missing a contructor that takes a single string as parameter. + + + + Unable to deserialize string-based enum. Unexpected data encountered: {0} + Unable to deserialize string-based enum. Unexpected data encountered: {0} + + + + Unable to deserialize TextDocumentSyncOptions. Unexpected value encountered: {0} + Unable to deserialize TextDocumentSyncOptions. Unexpected value encountered: {0} + + + + + \ No newline at end of file diff --git a/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/xlf/LSPFrameworkResources.tr.xlf b/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/xlf/LSPFrameworkResources.tr.xlf new file mode 100644 index 0000000000000..8bf920aad68c0 --- /dev/null +++ b/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/xlf/LSPFrameworkResources.tr.xlf @@ -0,0 +1,42 @@ + + + + + + Unable to deserialize Uri. Unexpected value encountered: {0} + Unable to deserialize Uri. Unexpected value encountered: {0} + + + + Unable to deserialize MarkupContent. Unexpected value encountered: {0} + Unable to deserialize MarkupContent. Unexpected value encountered: {0} + + + + A SumType cannot have another SumType as type parameter. + A SumType cannot have another SumType as type parameter. + + + + None of the SumType type parameters could be deserialized + None of the SumType type parameters could be deserialized + + + + Type {0} is missing a contructor that takes a single string as parameter. + Type {0} is missing a contructor that takes a single string as parameter. + + + + Unable to deserialize string-based enum. Unexpected data encountered: {0} + Unable to deserialize string-based enum. Unexpected data encountered: {0} + + + + Unable to deserialize TextDocumentSyncOptions. Unexpected value encountered: {0} + Unable to deserialize TextDocumentSyncOptions. Unexpected value encountered: {0} + + + + + \ No newline at end of file diff --git a/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/xlf/LSPFrameworkResources.zh-Hans.xlf b/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/xlf/LSPFrameworkResources.zh-Hans.xlf new file mode 100644 index 0000000000000..e89fb20e578c0 --- /dev/null +++ b/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/xlf/LSPFrameworkResources.zh-Hans.xlf @@ -0,0 +1,42 @@ + + + + + + Unable to deserialize Uri. Unexpected value encountered: {0} + Unable to deserialize Uri. Unexpected value encountered: {0} + + + + Unable to deserialize MarkupContent. Unexpected value encountered: {0} + Unable to deserialize MarkupContent. Unexpected value encountered: {0} + + + + A SumType cannot have another SumType as type parameter. + A SumType cannot have another SumType as type parameter. + + + + None of the SumType type parameters could be deserialized + None of the SumType type parameters could be deserialized + + + + Type {0} is missing a contructor that takes a single string as parameter. + Type {0} is missing a contructor that takes a single string as parameter. + + + + Unable to deserialize string-based enum. Unexpected data encountered: {0} + Unable to deserialize string-based enum. Unexpected data encountered: {0} + + + + Unable to deserialize TextDocumentSyncOptions. Unexpected value encountered: {0} + Unable to deserialize TextDocumentSyncOptions. Unexpected value encountered: {0} + + + + + \ No newline at end of file diff --git a/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/xlf/LSPFrameworkResources.zh-Hant.xlf b/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/xlf/LSPFrameworkResources.zh-Hant.xlf new file mode 100644 index 0000000000000..6aa68670d2ba0 --- /dev/null +++ b/src/Features/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/xlf/LSPFrameworkResources.zh-Hant.xlf @@ -0,0 +1,42 @@ + + + + + + Unable to deserialize Uri. Unexpected value encountered: {0} + Unable to deserialize Uri. Unexpected value encountered: {0} + + + + Unable to deserialize MarkupContent. Unexpected value encountered: {0} + Unable to deserialize MarkupContent. Unexpected value encountered: {0} + + + + A SumType cannot have another SumType as type parameter. + A SumType cannot have another SumType as type parameter. + + + + None of the SumType type parameters could be deserialized + None of the SumType type parameters could be deserialized + + + + Type {0} is missing a contructor that takes a single string as parameter. + Type {0} is missing a contructor that takes a single string as parameter. + + + + Unable to deserialize string-based enum. Unexpected data encountered: {0} + Unable to deserialize string-based enum. Unexpected data encountered: {0} + + + + Unable to deserialize TextDocumentSyncOptions. Unexpected value encountered: {0} + Unable to deserialize TextDocumentSyncOptions. Unexpected value encountered: {0} + + + + + \ No newline at end of file diff --git a/src/Features/LanguageServer/Protocol/DefaultCapabilitiesProvider.cs b/src/Features/LanguageServer/Protocol/DefaultCapabilitiesProvider.cs index 5ccde24051114..33fe3beb69c59 100644 --- a/src/Features/LanguageServer/Protocol/DefaultCapabilitiesProvider.cs +++ b/src/Features/LanguageServer/Protocol/DefaultCapabilitiesProvider.cs @@ -13,7 +13,7 @@ using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.LanguageServer.Handler.Completion; using Microsoft.CodeAnalysis.LanguageServer.Handler.SemanticTokens; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer { @@ -60,7 +60,7 @@ public ServerCapabilities GetCapabilities(ClientCapabilities clientCapabilities) }; capabilities.ImplementationProvider = true; capabilities.CodeActionProvider = new CodeActionOptions { CodeActionKinds = [CodeActionKind.QuickFix, CodeActionKind.Refactor], ResolveProvider = true }; - capabilities.CompletionProvider = new VisualStudio.LanguageServer.Protocol.CompletionOptions + capabilities.CompletionProvider = new Roslyn.LanguageServer.Protocol.CompletionOptions { ResolveProvider = true, AllCommitCharacters = commitCharacters, diff --git a/src/Features/LanguageServer/Protocol/Extensions/Extensions.cs b/src/Features/LanguageServer/Protocol/Extensions/Extensions.cs index 31e88ccc68d83..e082cb6476f59 100644 --- a/src/Features/LanguageServer/Protocol/Extensions/Extensions.cs +++ b/src/Features/LanguageServer/Protocol/Extensions/Extensions.cs @@ -15,8 +15,8 @@ using Microsoft.CodeAnalysis.Shared.Collections; using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.Text; -using Microsoft.VisualStudio.LanguageServer.Protocol; -using Microsoft.VisualStudio.Text.Adornments; +using Roslyn.LanguageServer.Protocol; +using Roslyn.Text.Adornments; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.LanguageServer diff --git a/src/Features/LanguageServer/Protocol/Extensions/ProtocolConversions.cs b/src/Features/LanguageServer/Protocol/Extensions/ProtocolConversions.cs index 6859004ed55e3..e01768d2dba37 100644 --- a/src/Features/LanguageServer/Protocol/Extensions/ProtocolConversions.cs +++ b/src/Features/LanguageServer/Protocol/Extensions/ProtocolConversions.cs @@ -23,10 +23,10 @@ using Microsoft.CodeAnalysis.PooledObjects; using Microsoft.CodeAnalysis.Tags; using Microsoft.CodeAnalysis.Text; -using Microsoft.VisualStudio.Text.Adornments; +using Roslyn.Text.Adornments; using Roslyn.Utilities; using Logger = Microsoft.CodeAnalysis.Internal.Log.Logger; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer { diff --git a/src/Features/LanguageServer/Protocol/ExternalAccess/Razor/FormatNewFileParams.cs b/src/Features/LanguageServer/Protocol/ExternalAccess/Razor/FormatNewFileParams.cs index 7544cf5a6aef6..f513d42e385b6 100644 --- a/src/Features/LanguageServer/Protocol/ExternalAccess/Razor/FormatNewFileParams.cs +++ b/src/Features/LanguageServer/Protocol/ExternalAccess/Razor/FormatNewFileParams.cs @@ -3,7 +3,7 @@ // See the LICENSE file in the project root for more information. using System.Runtime.Serialization; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.ExternalAccess.Razor; diff --git a/src/Features/LanguageServer/Protocol/ExternalAccess/Razor/SemanticTokensRangesHandler.cs b/src/Features/LanguageServer/Protocol/ExternalAccess/Razor/SemanticTokensRangesHandler.cs index eaf515e72c16c..f5eeb317f5e83 100644 --- a/src/Features/LanguageServer/Protocol/ExternalAccess/Razor/SemanticTokensRangesHandler.cs +++ b/src/Features/LanguageServer/Protocol/ExternalAccess/Razor/SemanticTokensRangesHandler.cs @@ -2,15 +2,12 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using System; -using System.Composition; using System.Threading; using System.Threading.Tasks; -using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.LanguageServer.Handler; using Microsoft.CodeAnalysis.LanguageServer.Handler.SemanticTokens; using Microsoft.CodeAnalysis.Options; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.LanguageServer.ExternalAccess.Razor; diff --git a/src/Features/LanguageServer/Protocol/ExternalAccess/Razor/SemanticTokensRangesParams.cs b/src/Features/LanguageServer/Protocol/ExternalAccess/Razor/SemanticTokensRangesParams.cs index 7beb9086728d5..1e5d1fc0f4bb7 100644 --- a/src/Features/LanguageServer/Protocol/ExternalAccess/Razor/SemanticTokensRangesParams.cs +++ b/src/Features/LanguageServer/Protocol/ExternalAccess/Razor/SemanticTokensRangesParams.cs @@ -3,7 +3,7 @@ // See the LICENSE file in the project root for more information. using System.Runtime.Serialization; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.ExternalAccess.Razor; diff --git a/src/Features/LanguageServer/Protocol/ExternalAccess/Razor/SimplifyMethodHandler.cs b/src/Features/LanguageServer/Protocol/ExternalAccess/Razor/SimplifyMethodHandler.cs index 1642dba8c5cb1..28d1050bd652f 100644 --- a/src/Features/LanguageServer/Protocol/ExternalAccess/Razor/SimplifyMethodHandler.cs +++ b/src/Features/LanguageServer/Protocol/ExternalAccess/Razor/SimplifyMethodHandler.cs @@ -11,7 +11,7 @@ using Microsoft.CodeAnalysis.LanguageServer.Handler; using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.Simplification; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.ExternalAccess.Razor; diff --git a/src/Features/LanguageServer/Protocol/ExternalAccess/Razor/SimplifyMethodParams.cs b/src/Features/LanguageServer/Protocol/ExternalAccess/Razor/SimplifyMethodParams.cs index 5451914013437..ba7495c8f93a9 100644 --- a/src/Features/LanguageServer/Protocol/ExternalAccess/Razor/SimplifyMethodParams.cs +++ b/src/Features/LanguageServer/Protocol/ExternalAccess/Razor/SimplifyMethodParams.cs @@ -3,7 +3,7 @@ // See the LICENSE file in the project root for more information. using System.Runtime.Serialization; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.ExternalAccess.Razor; diff --git a/src/Features/LanguageServer/Protocol/Handler/AbstractRefreshQueue.cs b/src/Features/LanguageServer/Protocol/Handler/AbstractRefreshQueue.cs index eae9c9f38dfa4..4d988ebd887a8 100644 --- a/src/Features/LanguageServer/Protocol/Handler/AbstractRefreshQueue.cs +++ b/src/Features/LanguageServer/Protocol/Handler/AbstractRefreshQueue.cs @@ -9,7 +9,7 @@ using Microsoft.CodeAnalysis.Collections; using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.Shared.TestHooks; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.LanguageServer.Handler diff --git a/src/Features/LanguageServer/Protocol/Handler/Breakpoints/ValidateBreakableRangeHandler.cs b/src/Features/LanguageServer/Protocol/Handler/Breakpoints/ValidateBreakableRangeHandler.cs index 23f7e327e8e40..7ba5975703810 100644 --- a/src/Features/LanguageServer/Protocol/Handler/Breakpoints/ValidateBreakableRangeHandler.cs +++ b/src/Features/LanguageServer/Protocol/Handler/Breakpoints/ValidateBreakableRangeHandler.cs @@ -10,9 +10,9 @@ using Microsoft.CodeAnalysis.Debugging; using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.Text; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Roslyn.Utilities; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler { diff --git a/src/Features/LanguageServer/Protocol/Handler/CodeActions/CodeActionFixAllResolveHandler.cs b/src/Features/LanguageServer/Protocol/Handler/CodeActions/CodeActionFixAllResolveHandler.cs index 6be55969ff2be..aad78be589aa2 100644 --- a/src/Features/LanguageServer/Protocol/Handler/CodeActions/CodeActionFixAllResolveHandler.cs +++ b/src/Features/LanguageServer/Protocol/Handler/CodeActions/CodeActionFixAllResolveHandler.cs @@ -11,11 +11,9 @@ using Microsoft.CodeAnalysis.CodeRefactorings; using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.Options; -using Microsoft.CodeAnalysis.UnifiedSuggestions; -using Microsoft.VisualStudio.LanguageServer.Protocol; using Newtonsoft.Json.Linq; +using Roslyn.LanguageServer.Protocol; using Roslyn.Utilities; -using StreamJsonRpc; namespace Microsoft.CodeAnalysis.LanguageServer.Handler.CodeActions; diff --git a/src/Features/LanguageServer/Protocol/Handler/CodeActions/CodeActionHelpers.cs b/src/Features/LanguageServer/Protocol/Handler/CodeActions/CodeActionHelpers.cs index 714c6b76df78d..4b8066f465ed2 100644 --- a/src/Features/LanguageServer/Protocol/Handler/CodeActions/CodeActionHelpers.cs +++ b/src/Features/LanguageServer/Protocol/Handler/CodeActions/CodeActionHelpers.cs @@ -14,11 +14,11 @@ using Microsoft.CodeAnalysis.PooledObjects; using Microsoft.CodeAnalysis.Text; using Microsoft.CodeAnalysis.UnifiedSuggestions; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Roslyn.Utilities; using StreamJsonRpc; using CodeAction = Microsoft.CodeAnalysis.CodeActions.CodeAction; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler.CodeActions { diff --git a/src/Features/LanguageServer/Protocol/Handler/CodeActions/CodeActionResolveData.cs b/src/Features/LanguageServer/Protocol/Handler/CodeActions/CodeActionResolveData.cs index 11d17d007dbb3..d7e32c9199d8e 100644 --- a/src/Features/LanguageServer/Protocol/Handler/CodeActions/CodeActionResolveData.cs +++ b/src/Features/LanguageServer/Protocol/Handler/CodeActions/CodeActionResolveData.cs @@ -3,9 +3,8 @@ // See the LICENSE file in the project root for more information. using System.Collections.Immutable; -using Microsoft.VisualStudio.LanguageServer.Protocol; using Newtonsoft.Json; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler.CodeActions { @@ -38,7 +37,7 @@ internal class CodeActionResolveData public string[]? FixAllFlavors { get; } [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public ImmutableArray? NestedCodeActions { get; } + public ImmutableArray? NestedCodeActions { get; } public CodeActionResolveData( string uniqueIdentifier, @@ -47,7 +46,7 @@ public CodeActionResolveData( LSP.TextDocumentIdentifier textDocument, string[] codeActionPath, string[]? fixAllFlavors, - ImmutableArray? nestedCodeActions) + ImmutableArray? nestedCodeActions) { UniqueIdentifier = uniqueIdentifier; CustomTags = customTags; diff --git a/src/Features/LanguageServer/Protocol/Handler/CodeActions/CodeActionResolveHandler.cs b/src/Features/LanguageServer/Protocol/Handler/CodeActions/CodeActionResolveHandler.cs index a3e519bf17fa7..8e5b860923bfd 100644 --- a/src/Features/LanguageServer/Protocol/Handler/CodeActions/CodeActionResolveHandler.cs +++ b/src/Features/LanguageServer/Protocol/Handler/CodeActions/CodeActionResolveHandler.cs @@ -3,9 +3,7 @@ // See the LICENSE file in the project root for more information. using System; -using System.Collections.Generic; using System.Composition; -using System.Linq; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.CodeActions; @@ -13,18 +11,11 @@ using Microsoft.CodeAnalysis.CodeRefactorings; using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.LanguageServer.Handler.CodeActions; -using Microsoft.CodeAnalysis.LanguageServer.Handler.InlayHint; using Microsoft.CodeAnalysis.Options; -using Microsoft.CodeAnalysis.PooledObjects; -using Microsoft.CodeAnalysis.Shared.Extensions; -using Microsoft.CodeAnalysis.Shared.Utilities; -using Microsoft.CodeAnalysis.Text; -using Microsoft.CodeAnalysis.UnifiedSuggestions; -using Microsoft.VisualStudio.LanguageServer.Protocol; using Newtonsoft.Json.Linq; +using Roslyn.LanguageServer.Protocol; using Roslyn.Utilities; -using StreamJsonRpc; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler { diff --git a/src/Features/LanguageServer/Protocol/Handler/CodeActions/CodeActionResolveHelper.cs b/src/Features/LanguageServer/Protocol/Handler/CodeActions/CodeActionResolveHelper.cs index 48eb84c447d66..937ceb3901ab8 100644 --- a/src/Features/LanguageServer/Protocol/Handler/CodeActions/CodeActionResolveHelper.cs +++ b/src/Features/LanguageServer/Protocol/Handler/CodeActions/CodeActionResolveHelper.cs @@ -10,11 +10,11 @@ using System.Threading.Tasks; using Microsoft.CodeAnalysis.CodeActions; using Microsoft.CodeAnalysis.PooledObjects; +using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.Text; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Roslyn.Utilities; -using Microsoft.CodeAnalysis.Shared.Extensions; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler.CodeActions { diff --git a/src/Features/LanguageServer/Protocol/Handler/CodeActions/CodeActionsHandler.cs b/src/Features/LanguageServer/Protocol/Handler/CodeActions/CodeActionsHandler.cs index 19fe581696a28..59430176e05cf 100644 --- a/src/Features/LanguageServer/Protocol/Handler/CodeActions/CodeActionsHandler.cs +++ b/src/Features/LanguageServer/Protocol/Handler/CodeActions/CodeActionsHandler.cs @@ -13,9 +13,9 @@ using Microsoft.CodeAnalysis.LanguageServer.Handler.CodeActions; using Microsoft.CodeAnalysis.LanguageServer.Handler.InlayHint; using Microsoft.CodeAnalysis.Options; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Roslyn.Utilities; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler { diff --git a/src/Features/LanguageServer/Protocol/Handler/CodeActions/RoslynFixAllCodeAction.cs b/src/Features/LanguageServer/Protocol/Handler/CodeActions/RoslynFixAllCodeAction.cs index 5f07d66b2d51f..03fdfc48564c3 100644 --- a/src/Features/LanguageServer/Protocol/Handler/CodeActions/RoslynFixAllCodeAction.cs +++ b/src/Features/LanguageServer/Protocol/Handler/CodeActions/RoslynFixAllCodeAction.cs @@ -3,8 +3,8 @@ // See the LICENSE file in the project root for more information. using System.Runtime.Serialization; -using Microsoft.VisualStudio.LanguageServer.Protocol; using Newtonsoft.Json; +using Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler.CodeActions; diff --git a/src/Features/LanguageServer/Protocol/Handler/CodeLens/CodeLensHandler.cs b/src/Features/LanguageServer/Protocol/Handler/CodeLens/CodeLensHandler.cs index df2b3cabc5622..bca78a9ebe33a 100644 --- a/src/Features/LanguageServer/Protocol/Handler/CodeLens/CodeLensHandler.cs +++ b/src/Features/LanguageServer/Protocol/Handler/CodeLens/CodeLensHandler.cs @@ -16,9 +16,9 @@ using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.PooledObjects; using Microsoft.CodeAnalysis.Shared.Extensions; +using LSP = Roslyn.LanguageServer.Protocol; using Microsoft.CodeAnalysis.Text; using StreamJsonRpc; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler.CodeLens; diff --git a/src/Features/LanguageServer/Protocol/Handler/CodeLens/CodeLensRefreshQueue.cs b/src/Features/LanguageServer/Protocol/Handler/CodeLens/CodeLensRefreshQueue.cs index 620f3a2b3c127..0557fab1300f0 100644 --- a/src/Features/LanguageServer/Protocol/Handler/CodeLens/CodeLensRefreshQueue.cs +++ b/src/Features/LanguageServer/Protocol/Handler/CodeLens/CodeLensRefreshQueue.cs @@ -4,7 +4,7 @@ using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.Shared.TestHooks; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler.CodeLens { diff --git a/src/Features/LanguageServer/Protocol/Handler/CodeLens/CodeLensResolveData.cs b/src/Features/LanguageServer/Protocol/Handler/CodeLens/CodeLensResolveData.cs index 312bd6800008d..84d82992818e4 100644 --- a/src/Features/LanguageServer/Protocol/Handler/CodeLens/CodeLensResolveData.cs +++ b/src/Features/LanguageServer/Protocol/Handler/CodeLens/CodeLensResolveData.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler.CodeLens; diff --git a/src/Features/LanguageServer/Protocol/Handler/CodeLens/CodeLensResolveHandler.cs b/src/Features/LanguageServer/Protocol/Handler/CodeLens/CodeLensResolveHandler.cs index ed5d1038b0967..930bf05308462 100644 --- a/src/Features/LanguageServer/Protocol/Handler/CodeLens/CodeLensResolveHandler.cs +++ b/src/Features/LanguageServer/Protocol/Handler/CodeLens/CodeLensResolveHandler.cs @@ -10,7 +10,7 @@ using Roslyn.Utilities; using StreamJsonRpc; using Microsoft.CodeAnalysis.Shared.Extensions; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler.CodeLens; diff --git a/src/Features/LanguageServer/Protocol/Handler/Commands/AbstractExecuteWorkspaceCommandHandler.cs b/src/Features/LanguageServer/Protocol/Handler/Commands/AbstractExecuteWorkspaceCommandHandler.cs index c362a9c410414..ef15b8f6b2135 100644 --- a/src/Features/LanguageServer/Protocol/Handler/Commands/AbstractExecuteWorkspaceCommandHandler.cs +++ b/src/Features/LanguageServer/Protocol/Handler/Commands/AbstractExecuteWorkspaceCommandHandler.cs @@ -4,7 +4,7 @@ using System.Threading; using System.Threading.Tasks; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler.Commands { diff --git a/src/Features/LanguageServer/Protocol/Handler/Completion/AbstractLspCompletionResultCreationService.cs b/src/Features/LanguageServer/Protocol/Handler/Completion/AbstractLspCompletionResultCreationService.cs index dc9a02c83541d..87d82f38ff080 100644 --- a/src/Features/LanguageServer/Protocol/Handler/Completion/AbstractLspCompletionResultCreationService.cs +++ b/src/Features/LanguageServer/Protocol/Handler/Completion/AbstractLspCompletionResultCreationService.cs @@ -18,7 +18,7 @@ using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.Text; using Roslyn.Utilities; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler.Completion { diff --git a/src/Features/LanguageServer/Protocol/Handler/Completion/CompletionCapabilityHelper.cs b/src/Features/LanguageServer/Protocol/Handler/Completion/CompletionCapabilityHelper.cs index 9892f33d66cd1..bd565c39807ac 100644 --- a/src/Features/LanguageServer/Protocol/Handler/Completion/CompletionCapabilityHelper.cs +++ b/src/Features/LanguageServer/Protocol/Handler/Completion/CompletionCapabilityHelper.cs @@ -7,7 +7,7 @@ using System.Collections.Immutable; using System.Linq; using Microsoft.CodeAnalysis.Shared.Extensions; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.LanguageServer.Handler.Completion diff --git a/src/Features/LanguageServer/Protocol/Handler/Completion/CompletionHandler.cs b/src/Features/LanguageServer/Protocol/Handler/Completion/CompletionHandler.cs index 816ec6f613b80..116f400f72b4b 100644 --- a/src/Features/LanguageServer/Protocol/Handler/Completion/CompletionHandler.cs +++ b/src/Features/LanguageServer/Protocol/Handler/Completion/CompletionHandler.cs @@ -16,7 +16,7 @@ using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.Text; using Roslyn.Utilities; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler { diff --git a/src/Features/LanguageServer/Protocol/Handler/Completion/CompletionListCache.cs b/src/Features/LanguageServer/Protocol/Handler/Completion/CompletionListCache.cs index f889391bac0a3..6e27d07d63820 100644 --- a/src/Features/LanguageServer/Protocol/Handler/Completion/CompletionListCache.cs +++ b/src/Features/LanguageServer/Protocol/Handler/Completion/CompletionListCache.cs @@ -4,7 +4,7 @@ using Microsoft.CodeAnalysis.Completion; using static Microsoft.CodeAnalysis.LanguageServer.Handler.Completion.CompletionListCache; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler.Completion { diff --git a/src/Features/LanguageServer/Protocol/Handler/Completion/CompletionResolveData.cs b/src/Features/LanguageServer/Protocol/Handler/Completion/CompletionResolveData.cs index ae7d7f77a6e55..feb3d28077bc8 100644 --- a/src/Features/LanguageServer/Protocol/Handler/Completion/CompletionResolveData.cs +++ b/src/Features/LanguageServer/Protocol/Handler/Completion/CompletionResolveData.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler.Completion { diff --git a/src/Features/LanguageServer/Protocol/Handler/Completion/CompletionResolveHandler.cs b/src/Features/LanguageServer/Protocol/Handler/Completion/CompletionResolveHandler.cs index 8eaa6a5a2ee24..00cbeb6ac5de7 100644 --- a/src/Features/LanguageServer/Protocol/Handler/Completion/CompletionResolveHandler.cs +++ b/src/Features/LanguageServer/Protocol/Handler/Completion/CompletionResolveHandler.cs @@ -13,7 +13,7 @@ using Microsoft.CommonLanguageServerProtocol.Framework; using Newtonsoft.Json.Linq; using Roslyn.Utilities; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler { diff --git a/src/Features/LanguageServer/Protocol/Handler/Completion/DefaultLspCompletionResultCreationService.cs b/src/Features/LanguageServer/Protocol/Handler/Completion/DefaultLspCompletionResultCreationService.cs index 2ad5498752e6c..8a50a908958b1 100644 --- a/src/Features/LanguageServer/Protocol/Handler/Completion/DefaultLspCompletionResultCreationService.cs +++ b/src/Features/LanguageServer/Protocol/Handler/Completion/DefaultLspCompletionResultCreationService.cs @@ -11,7 +11,7 @@ using Microsoft.CodeAnalysis.LanguageService; using Microsoft.CodeAnalysis.Text; using Roslyn.Utilities; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler.Completion { diff --git a/src/Features/LanguageServer/Protocol/Handler/Completion/ILspCompletionResultCreationService.cs b/src/Features/LanguageServer/Protocol/Handler/Completion/ILspCompletionResultCreationService.cs index b197f18bcea41..755d8e8f90813 100644 --- a/src/Features/LanguageServer/Protocol/Handler/Completion/ILspCompletionResultCreationService.cs +++ b/src/Features/LanguageServer/Protocol/Handler/Completion/ILspCompletionResultCreationService.cs @@ -8,7 +8,7 @@ using Microsoft.CodeAnalysis.Host; using Microsoft.CodeAnalysis.LanguageService; using Microsoft.CodeAnalysis.Text; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler.Completion { diff --git a/src/Features/LanguageServer/Protocol/Handler/Configuration/DidChangeConfigurationNotificationHandler.cs b/src/Features/LanguageServer/Protocol/Handler/Configuration/DidChangeConfigurationNotificationHandler.cs index 45e1f7384b824..e155bf4968dc2 100644 --- a/src/Features/LanguageServer/Protocol/Handler/Configuration/DidChangeConfigurationNotificationHandler.cs +++ b/src/Features/LanguageServer/Protocol/Handler/Configuration/DidChangeConfigurationNotificationHandler.cs @@ -11,10 +11,10 @@ using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.PooledObjects; using Microsoft.CommonLanguageServerProtocol.Framework; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Newtonsoft.Json.Linq; using Roslyn.Utilities; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler.Configuration { diff --git a/src/Features/LanguageServer/Protocol/Handler/Configuration/DidChangeConfigurationNotificationHandler_OnInitialized.cs b/src/Features/LanguageServer/Protocol/Handler/Configuration/DidChangeConfigurationNotificationHandler_OnInitialized.cs index 721f9939afb8f..f1e2f16defb48 100644 --- a/src/Features/LanguageServer/Protocol/Handler/Configuration/DidChangeConfigurationNotificationHandler_OnInitialized.cs +++ b/src/Features/LanguageServer/Protocol/Handler/Configuration/DidChangeConfigurationNotificationHandler_OnInitialized.cs @@ -4,7 +4,7 @@ using System.Threading; using System.Threading.Tasks; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Newtonsoft.Json.Linq; namespace Microsoft.CodeAnalysis.LanguageServer.Handler.Configuration diff --git a/src/Features/LanguageServer/Protocol/Handler/Definitions/AbstractGoToDefinitionHandler.cs b/src/Features/LanguageServer/Protocol/Handler/Definitions/AbstractGoToDefinitionHandler.cs index 7751bd2fe113a..83948cec1e616 100644 --- a/src/Features/LanguageServer/Protocol/Handler/Definitions/AbstractGoToDefinitionHandler.cs +++ b/src/Features/LanguageServer/Protocol/Handler/Definitions/AbstractGoToDefinitionHandler.cs @@ -13,8 +13,8 @@ using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.PooledObjects; using Microsoft.CodeAnalysis.Shared.Extensions; -using Microsoft.VisualStudio.LanguageServer.Protocol; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler { diff --git a/src/Features/LanguageServer/Protocol/Handler/Definitions/GoToDefinitionHandler.cs b/src/Features/LanguageServer/Protocol/Handler/Definitions/GoToDefinitionHandler.cs index b79a4f99cea20..b25d426dd96ff 100644 --- a/src/Features/LanguageServer/Protocol/Handler/Definitions/GoToDefinitionHandler.cs +++ b/src/Features/LanguageServer/Protocol/Handler/Definitions/GoToDefinitionHandler.cs @@ -9,7 +9,7 @@ using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.MetadataAsSource; using Microsoft.CodeAnalysis.Options; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler { diff --git a/src/Features/LanguageServer/Protocol/Handler/Definitions/GoToTypeDefinitionHandler.cs b/src/Features/LanguageServer/Protocol/Handler/Definitions/GoToTypeDefinitionHandler.cs index 34c0540522c9f..969b512be3f27 100644 --- a/src/Features/LanguageServer/Protocol/Handler/Definitions/GoToTypeDefinitionHandler.cs +++ b/src/Features/LanguageServer/Protocol/Handler/Definitions/GoToTypeDefinitionHandler.cs @@ -9,7 +9,7 @@ using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.MetadataAsSource; using Microsoft.CodeAnalysis.Options; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler { diff --git a/src/Features/LanguageServer/Protocol/Handler/Diagnostics/AbstractPullDiagnosticHandler.cs b/src/Features/LanguageServer/Protocol/Handler/Diagnostics/AbstractPullDiagnosticHandler.cs index 5d851cdc17f94..193a46f440185 100644 --- a/src/Features/LanguageServer/Protocol/Handler/Diagnostics/AbstractPullDiagnosticHandler.cs +++ b/src/Features/LanguageServer/Protocol/Handler/Diagnostics/AbstractPullDiagnosticHandler.cs @@ -14,9 +14,9 @@ using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.PooledObjects; using Microsoft.CommonLanguageServerProtocol.Framework; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Roslyn.Utilities; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler.Diagnostics { diff --git a/src/Features/LanguageServer/Protocol/Handler/Diagnostics/AbstractWorkspacePullDiagnosticsHandler.cs b/src/Features/LanguageServer/Protocol/Handler/Diagnostics/AbstractWorkspacePullDiagnosticsHandler.cs index e447ae68e1da8..510c34fa8d88c 100644 --- a/src/Features/LanguageServer/Protocol/Handler/Diagnostics/AbstractWorkspacePullDiagnosticsHandler.cs +++ b/src/Features/LanguageServer/Protocol/Handler/Diagnostics/AbstractWorkspacePullDiagnosticsHandler.cs @@ -14,7 +14,7 @@ using Microsoft.CodeAnalysis.PooledObjects; using Microsoft.CodeAnalysis.SolutionCrawler; using Microsoft.CodeAnalysis.TaskList; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.LanguageServer.Handler.Diagnostics; diff --git a/src/Features/LanguageServer/Protocol/Handler/Diagnostics/DiagnosticSources/AbstractDocumentDiagnosticSource.cs b/src/Features/LanguageServer/Protocol/Handler/Diagnostics/DiagnosticSources/AbstractDocumentDiagnosticSource.cs index f0045caa9d075..0de186f4e9ac1 100644 --- a/src/Features/LanguageServer/Protocol/Handler/Diagnostics/DiagnosticSources/AbstractDocumentDiagnosticSource.cs +++ b/src/Features/LanguageServer/Protocol/Handler/Diagnostics/DiagnosticSources/AbstractDocumentDiagnosticSource.cs @@ -6,7 +6,7 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Diagnostics; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler.Diagnostics; diff --git a/src/Features/LanguageServer/Protocol/Handler/Diagnostics/DiagnosticSources/AbstractProjectDiagnosticSource.cs b/src/Features/LanguageServer/Protocol/Handler/Diagnostics/DiagnosticSources/AbstractProjectDiagnosticSource.cs index aa674a919dbae..d34ef1d906826 100644 --- a/src/Features/LanguageServer/Protocol/Handler/Diagnostics/DiagnosticSources/AbstractProjectDiagnosticSource.cs +++ b/src/Features/LanguageServer/Protocol/Handler/Diagnostics/DiagnosticSources/AbstractProjectDiagnosticSource.cs @@ -7,7 +7,7 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Diagnostics; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler.Diagnostics; diff --git a/src/Features/LanguageServer/Protocol/Handler/Diagnostics/DiagnosticSources/IDiagnosticSource.cs b/src/Features/LanguageServer/Protocol/Handler/Diagnostics/DiagnosticSources/IDiagnosticSource.cs index cf1eec4e74692..34d110e4adb4c 100644 --- a/src/Features/LanguageServer/Protocol/Handler/Diagnostics/DiagnosticSources/IDiagnosticSource.cs +++ b/src/Features/LanguageServer/Protocol/Handler/Diagnostics/DiagnosticSources/IDiagnosticSource.cs @@ -7,7 +7,7 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Diagnostics; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler.Diagnostics; diff --git a/src/Features/LanguageServer/Protocol/Handler/Diagnostics/DiagnosticsRefreshQueue.cs b/src/Features/LanguageServer/Protocol/Handler/Diagnostics/DiagnosticsRefreshQueue.cs index c06bc461d1415..44e4f3e3ac3b7 100644 --- a/src/Features/LanguageServer/Protocol/Handler/Diagnostics/DiagnosticsRefreshQueue.cs +++ b/src/Features/LanguageServer/Protocol/Handler/Diagnostics/DiagnosticsRefreshQueue.cs @@ -8,7 +8,7 @@ using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.Shared.TestHooks; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler.Diagnostics; diff --git a/src/Features/LanguageServer/Protocol/Handler/Diagnostics/DocumentPullDiagnosticHandler.cs b/src/Features/LanguageServer/Protocol/Handler/Diagnostics/DocumentPullDiagnosticHandler.cs index 1276438900724..c2ca31b56365f 100644 --- a/src/Features/LanguageServer/Protocol/Handler/Diagnostics/DocumentPullDiagnosticHandler.cs +++ b/src/Features/LanguageServer/Protocol/Handler/Diagnostics/DocumentPullDiagnosticHandler.cs @@ -9,7 +9,7 @@ using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.SolutionCrawler; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler.Diagnostics { @@ -31,7 +31,7 @@ public DocumentPullDiagnosticHandler( public override TextDocumentIdentifier? GetTextDocumentIdentifier(VSInternalDocumentDiagnosticsParams diagnosticsParams) => diagnosticsParams.TextDocument; - protected override VSInternalDiagnosticReport[] CreateReport(TextDocumentIdentifier identifier, VisualStudio.LanguageServer.Protocol.Diagnostic[]? diagnostics, string? resultId) + protected override VSInternalDiagnosticReport[] CreateReport(TextDocumentIdentifier identifier, Roslyn.LanguageServer.Protocol.Diagnostic[]? diagnostics, string? resultId) => new[] { new VSInternalDiagnosticReport diff --git a/src/Features/LanguageServer/Protocol/Handler/Diagnostics/Public/PublicDocumentPullDiagnosticHandlerFactory.cs b/src/Features/LanguageServer/Protocol/Handler/Diagnostics/Public/PublicDocumentPullDiagnosticHandlerFactory.cs index d36b1610a1465..e369e4180ed43 100644 --- a/src/Features/LanguageServer/Protocol/Handler/Diagnostics/Public/PublicDocumentPullDiagnosticHandlerFactory.cs +++ b/src/Features/LanguageServer/Protocol/Handler/Diagnostics/Public/PublicDocumentPullDiagnosticHandlerFactory.cs @@ -8,7 +8,7 @@ using Microsoft.CodeAnalysis.EditAndContinue; using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.Options; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler.Diagnostics.Public; diff --git a/src/Features/LanguageServer/Protocol/Handler/Diagnostics/Public/PublicDocumentPullDiagnosticsHandler.cs b/src/Features/LanguageServer/Protocol/Handler/Diagnostics/Public/PublicDocumentPullDiagnosticsHandler.cs index 49a5fd0c75ba8..95d38628c49a8 100644 --- a/src/Features/LanguageServer/Protocol/Handler/Diagnostics/Public/PublicDocumentPullDiagnosticsHandler.cs +++ b/src/Features/LanguageServer/Protocol/Handler/Diagnostics/Public/PublicDocumentPullDiagnosticsHandler.cs @@ -10,7 +10,7 @@ using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.EditAndContinue; using Microsoft.CodeAnalysis.Options; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.LanguageServer.Handler.Diagnostics.Public; @@ -52,7 +52,7 @@ public PublicDocumentPullDiagnosticsHandler( protected override DiagnosticTag[] ConvertTags(DiagnosticData diagnosticData, bool isLiveSource) => ConvertTags(diagnosticData, isLiveSource, potentialDuplicate: false); - protected override DocumentDiagnosticPartialReport CreateReport(TextDocumentIdentifier identifier, VisualStudio.LanguageServer.Protocol.Diagnostic[] diagnostics, string resultId) + protected override DocumentDiagnosticPartialReport CreateReport(TextDocumentIdentifier identifier, Roslyn.LanguageServer.Protocol.Diagnostic[] diagnostics, string resultId) => new(new RelatedFullDocumentDiagnosticReport { ResultId = resultId, @@ -63,7 +63,7 @@ protected override DocumentDiagnosticPartialReport CreateRemovedReport(TextDocum => new(new RelatedFullDocumentDiagnosticReport { ResultId = null, - Items = Array.Empty(), + Items = Array.Empty(), }); protected override DocumentDiagnosticPartialReport CreateUnchangedReport(TextDocumentIdentifier identifier, string resultId) diff --git a/src/Features/LanguageServer/Protocol/Handler/Diagnostics/Public/PublicDocumentPullDiagnosticsHandler_IOnInitialized.cs b/src/Features/LanguageServer/Protocol/Handler/Diagnostics/Public/PublicDocumentPullDiagnosticsHandler_IOnInitialized.cs index c6adec2917512..940723c0e652a 100644 --- a/src/Features/LanguageServer/Protocol/Handler/Diagnostics/Public/PublicDocumentPullDiagnosticsHandler_IOnInitialized.cs +++ b/src/Features/LanguageServer/Protocol/Handler/Diagnostics/Public/PublicDocumentPullDiagnosticsHandler_IOnInitialized.cs @@ -5,7 +5,7 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.SolutionCrawler; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler.Diagnostics.Public; diff --git a/src/Features/LanguageServer/Protocol/Handler/Diagnostics/Public/PublicWorkspacePullDiagnosticsHandler.cs b/src/Features/LanguageServer/Protocol/Handler/Diagnostics/Public/PublicWorkspacePullDiagnosticsHandler.cs index 205fda0d91923..937fe0484ea18 100644 --- a/src/Features/LanguageServer/Protocol/Handler/Diagnostics/Public/PublicWorkspacePullDiagnosticsHandler.cs +++ b/src/Features/LanguageServer/Protocol/Handler/Diagnostics/Public/PublicWorkspacePullDiagnosticsHandler.cs @@ -8,7 +8,7 @@ using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.Options; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.LanguageServer.Handler.Diagnostics.Public; @@ -38,7 +38,7 @@ internal sealed class PublicWorkspacePullDiagnosticsHandler( protected override DiagnosticTag[] ConvertTags(DiagnosticData diagnosticData, bool isLiveSource) => ConvertTags(diagnosticData, isLiveSource, potentialDuplicate: false); - protected override WorkspaceDiagnosticPartialReport CreateReport(TextDocumentIdentifier identifier, VisualStudio.LanguageServer.Protocol.Diagnostic[] diagnostics, string resultId) + protected override WorkspaceDiagnosticPartialReport CreateReport(TextDocumentIdentifier identifier, Roslyn.LanguageServer.Protocol.Diagnostic[] diagnostics, string resultId) => new(new WorkspaceDiagnosticReport { Items = @@ -62,7 +62,7 @@ protected override WorkspaceDiagnosticPartialReport CreateRemovedReport(TextDocu new WorkspaceFullDocumentDiagnosticReport { Uri = identifier.Uri, - Items = Array.Empty(), + Items = Array.Empty(), // The documents provided by workspace reports are never open, so we return null. Version = null, ResultId = null, diff --git a/src/Features/LanguageServer/Protocol/Handler/Diagnostics/PullDiagnosticCategories.cs b/src/Features/LanguageServer/Protocol/Handler/Diagnostics/PullDiagnosticCategories.cs index 83dc791a77c4f..5ba6497ed6e30 100644 --- a/src/Features/LanguageServer/Protocol/Handler/Diagnostics/PullDiagnosticCategories.cs +++ b/src/Features/LanguageServer/Protocol/Handler/Diagnostics/PullDiagnosticCategories.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler.Diagnostics { diff --git a/src/Features/LanguageServer/Protocol/Handler/Diagnostics/WorkspacePullDiagnosticHandler.cs b/src/Features/LanguageServer/Protocol/Handler/Diagnostics/WorkspacePullDiagnosticHandler.cs index 42a04079f29c8..598eedc08620f 100644 --- a/src/Features/LanguageServer/Protocol/Handler/Diagnostics/WorkspacePullDiagnosticHandler.cs +++ b/src/Features/LanguageServer/Protocol/Handler/Diagnostics/WorkspacePullDiagnosticHandler.cs @@ -6,7 +6,7 @@ using System.Linq; using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.Options; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.LanguageServer.Handler.Diagnostics @@ -24,7 +24,7 @@ internal sealed partial class WorkspacePullDiagnosticHandler( protected override string? GetDiagnosticCategory(VSInternalWorkspaceDiagnosticsParams diagnosticsParams) => diagnosticsParams.QueryingDiagnosticKind?.Value; - protected override VSInternalWorkspaceDiagnosticReport[] CreateReport(TextDocumentIdentifier identifier, VisualStudio.LanguageServer.Protocol.Diagnostic[]? diagnostics, string? resultId) + protected override VSInternalWorkspaceDiagnosticReport[] CreateReport(TextDocumentIdentifier identifier, Roslyn.LanguageServer.Protocol.Diagnostic[]? diagnostics, string? resultId) => new[] { new VSInternalWorkspaceDiagnosticReport { diff --git a/src/Features/LanguageServer/Protocol/Handler/DocumentChanges/DidChangeHandler.cs b/src/Features/LanguageServer/Protocol/Handler/DocumentChanges/DidChangeHandler.cs index fbd221665f2f7..e4586f2f83a01 100644 --- a/src/Features/LanguageServer/Protocol/Handler/DocumentChanges/DidChangeHandler.cs +++ b/src/Features/LanguageServer/Protocol/Handler/DocumentChanges/DidChangeHandler.cs @@ -7,7 +7,7 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Host.Mef; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.LanguageServer.Handler.DocumentChanges; diff --git a/src/Features/LanguageServer/Protocol/Handler/DocumentChanges/DidCloseHandler.cs b/src/Features/LanguageServer/Protocol/Handler/DocumentChanges/DidCloseHandler.cs index ac24eda1eb34b..ca5a669a17aec 100644 --- a/src/Features/LanguageServer/Protocol/Handler/DocumentChanges/DidCloseHandler.cs +++ b/src/Features/LanguageServer/Protocol/Handler/DocumentChanges/DidCloseHandler.cs @@ -8,8 +8,8 @@ using System.Threading.Tasks; using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CommonLanguageServerProtocol.Framework; -using Microsoft.VisualStudio.LanguageServer.Protocol; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler.DocumentChanges { diff --git a/src/Features/LanguageServer/Protocol/Handler/DocumentChanges/DidOpenHandler.cs b/src/Features/LanguageServer/Protocol/Handler/DocumentChanges/DidOpenHandler.cs index 4493969a86c3b..54a811861cab1 100644 --- a/src/Features/LanguageServer/Protocol/Handler/DocumentChanges/DidOpenHandler.cs +++ b/src/Features/LanguageServer/Protocol/Handler/DocumentChanges/DidOpenHandler.cs @@ -10,7 +10,7 @@ using Microsoft.CodeAnalysis.Text; using Microsoft.CommonLanguageServerProtocol.Framework; using Roslyn.Utilities; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler.DocumentChanges { diff --git a/src/Features/LanguageServer/Protocol/Handler/FoldingRanges/FoldingRangesHandler.cs b/src/Features/LanguageServer/Protocol/Handler/FoldingRanges/FoldingRangesHandler.cs index 50b7dc2b0c304..2364f5f60412e 100644 --- a/src/Features/LanguageServer/Protocol/Handler/FoldingRanges/FoldingRangesHandler.cs +++ b/src/Features/LanguageServer/Protocol/Handler/FoldingRanges/FoldingRangesHandler.cs @@ -13,7 +13,7 @@ using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.Structure; using Microsoft.CodeAnalysis.Text; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler { diff --git a/src/Features/LanguageServer/Protocol/Handler/Formatting/AbstractFormatDocumentHandlerBase.cs b/src/Features/LanguageServer/Protocol/Handler/Formatting/AbstractFormatDocumentHandlerBase.cs index bb052fa7e9d93..d91d1c14d3732 100644 --- a/src/Features/LanguageServer/Protocol/Handler/Formatting/AbstractFormatDocumentHandlerBase.cs +++ b/src/Features/LanguageServer/Protocol/Handler/Formatting/AbstractFormatDocumentHandlerBase.cs @@ -12,7 +12,7 @@ using Microsoft.CodeAnalysis.Shared.Utilities; using Microsoft.CodeAnalysis.Text; using Roslyn.Utilities; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler { diff --git a/src/Features/LanguageServer/Protocol/Handler/Formatting/FormatDocumentHandler.cs b/src/Features/LanguageServer/Protocol/Handler/Formatting/FormatDocumentHandler.cs index f95e6f68c3c2e..e17382ddc9e50 100644 --- a/src/Features/LanguageServer/Protocol/Handler/Formatting/FormatDocumentHandler.cs +++ b/src/Features/LanguageServer/Protocol/Handler/Formatting/FormatDocumentHandler.cs @@ -8,7 +8,7 @@ using System.Threading.Tasks; using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.Options; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler { diff --git a/src/Features/LanguageServer/Protocol/Handler/Formatting/FormatDocumentOnTypeHandler.cs b/src/Features/LanguageServer/Protocol/Handler/Formatting/FormatDocumentOnTypeHandler.cs index adeabd78172f9..799ebc0ccfef4 100644 --- a/src/Features/LanguageServer/Protocol/Handler/Formatting/FormatDocumentOnTypeHandler.cs +++ b/src/Features/LanguageServer/Protocol/Handler/Formatting/FormatDocumentOnTypeHandler.cs @@ -16,7 +16,7 @@ using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.PooledObjects; using Microsoft.CodeAnalysis.Text; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.LanguageServer.Handler diff --git a/src/Features/LanguageServer/Protocol/Handler/Formatting/FormatDocumentRangeHandler.cs b/src/Features/LanguageServer/Protocol/Handler/Formatting/FormatDocumentRangeHandler.cs index 09a2991bfb2b5..dce2297839510 100644 --- a/src/Features/LanguageServer/Protocol/Handler/Formatting/FormatDocumentRangeHandler.cs +++ b/src/Features/LanguageServer/Protocol/Handler/Formatting/FormatDocumentRangeHandler.cs @@ -8,7 +8,7 @@ using System.Threading.Tasks; using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.Options; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler { diff --git a/src/Features/LanguageServer/Protocol/Handler/Highlights/DocumentHighlightHandler.cs b/src/Features/LanguageServer/Protocol/Handler/Highlights/DocumentHighlightHandler.cs index be4f535b57a80..74dab558fc6f8 100644 --- a/src/Features/LanguageServer/Protocol/Handler/Highlights/DocumentHighlightHandler.cs +++ b/src/Features/LanguageServer/Protocol/Handler/Highlights/DocumentHighlightHandler.cs @@ -15,7 +15,7 @@ using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.Text; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.LanguageServer.Handler diff --git a/src/Features/LanguageServer/Protocol/Handler/Hover/HoverHandler.cs b/src/Features/LanguageServer/Protocol/Handler/Hover/HoverHandler.cs index 72e0ff3d8044a..5d8a617908b4c 100644 --- a/src/Features/LanguageServer/Protocol/Handler/Hover/HoverHandler.cs +++ b/src/Features/LanguageServer/Protocol/Handler/Hover/HoverHandler.cs @@ -12,7 +12,7 @@ using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.QuickInfo; using Microsoft.CodeAnalysis.Shared.Extensions; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler { diff --git a/src/Features/LanguageServer/Protocol/Handler/Hover/ILspHoverResultCreationService.cs b/src/Features/LanguageServer/Protocol/Handler/Hover/ILspHoverResultCreationService.cs index 2b797f91c252f..6da46fc0b63fa 100644 --- a/src/Features/LanguageServer/Protocol/Handler/Hover/ILspHoverResultCreationService.cs +++ b/src/Features/LanguageServer/Protocol/Handler/Hover/ILspHoverResultCreationService.cs @@ -11,7 +11,7 @@ using Microsoft.CodeAnalysis.Host; using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.QuickInfo; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler { diff --git a/src/Features/LanguageServer/Protocol/Handler/IDocumentChangeTracker.cs b/src/Features/LanguageServer/Protocol/Handler/IDocumentChangeTracker.cs index f4a7974435f03..275c707cdb142 100644 --- a/src/Features/LanguageServer/Protocol/Handler/IDocumentChangeTracker.cs +++ b/src/Features/LanguageServer/Protocol/Handler/IDocumentChangeTracker.cs @@ -8,7 +8,7 @@ using Microsoft.CodeAnalysis.Features.Workspaces; using Microsoft.CodeAnalysis.LanguageServer.Handler.DocumentChanges; using Microsoft.CodeAnalysis.Text; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler; diff --git a/src/Features/LanguageServer/Protocol/Handler/IInitializeManager.cs b/src/Features/LanguageServer/Protocol/Handler/IInitializeManager.cs index 5bc8a26d32aea..847bbbf8af04c 100644 --- a/src/Features/LanguageServer/Protocol/Handler/IInitializeManager.cs +++ b/src/Features/LanguageServer/Protocol/Handler/IInitializeManager.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler { diff --git a/src/Features/LanguageServer/Protocol/Handler/ILspServiceRequestHandler.cs b/src/Features/LanguageServer/Protocol/Handler/ILspServiceRequestHandler.cs index c4f1788951549..25b5bf0eec1f2 100644 --- a/src/Features/LanguageServer/Protocol/Handler/ILspServiceRequestHandler.cs +++ b/src/Features/LanguageServer/Protocol/Handler/ILspServiceRequestHandler.cs @@ -3,7 +3,7 @@ // See the LICENSE file in the project root for more information. using Microsoft.CommonLanguageServerProtocol.Framework; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler; diff --git a/src/Features/LanguageServer/Protocol/Handler/InitializeManager.cs b/src/Features/LanguageServer/Protocol/Handler/InitializeManager.cs index d7004e13c4886..3dafa54fd5635 100644 --- a/src/Features/LanguageServer/Protocol/Handler/InitializeManager.cs +++ b/src/Features/LanguageServer/Protocol/Handler/InitializeManager.cs @@ -3,8 +3,8 @@ // See the LICENSE file in the project root for more information. using System; +using Roslyn.LanguageServer.Protocol; using Roslyn.Utilities; -using Microsoft.VisualStudio.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler; diff --git a/src/Features/LanguageServer/Protocol/Handler/InlayHint/InlayHintCache.cs b/src/Features/LanguageServer/Protocol/Handler/InlayHint/InlayHintCache.cs index aa98addfc4f9b..44c6877e471a6 100644 --- a/src/Features/LanguageServer/Protocol/Handler/InlayHint/InlayHintCache.cs +++ b/src/Features/LanguageServer/Protocol/Handler/InlayHint/InlayHintCache.cs @@ -4,7 +4,7 @@ using System.Collections.Immutable; using Microsoft.CodeAnalysis.InlineHints; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using static Microsoft.CodeAnalysis.LanguageServer.Handler.InlayHint.InlayHintCache; namespace Microsoft.CodeAnalysis.LanguageServer.Handler.InlayHint; diff --git a/src/Features/LanguageServer/Protocol/Handler/InlayHint/InlayHintHandler.cs b/src/Features/LanguageServer/Protocol/Handler/InlayHint/InlayHintHandler.cs index 501d3bc1baa8d..de557ed9f5240 100644 --- a/src/Features/LanguageServer/Protocol/Handler/InlayHint/InlayHintHandler.cs +++ b/src/Features/LanguageServer/Protocol/Handler/InlayHint/InlayHintHandler.cs @@ -15,8 +15,8 @@ using Microsoft.CodeAnalysis.PooledObjects; using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.Text; -using Microsoft.VisualStudio.LanguageServer.Protocol; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler.InlayHint { diff --git a/src/Features/LanguageServer/Protocol/Handler/InlayHint/InlayHintRefreshQueue.cs b/src/Features/LanguageServer/Protocol/Handler/InlayHint/InlayHintRefreshQueue.cs index 8e1c0703cf7d4..eef77631f06db 100644 --- a/src/Features/LanguageServer/Protocol/Handler/InlayHint/InlayHintRefreshQueue.cs +++ b/src/Features/LanguageServer/Protocol/Handler/InlayHint/InlayHintRefreshQueue.cs @@ -5,7 +5,7 @@ using Microsoft.CodeAnalysis.InlineHints; using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.Shared.TestHooks; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler.InlayHint { diff --git a/src/Features/LanguageServer/Protocol/Handler/InlayHint/InlayHintResolveData.cs b/src/Features/LanguageServer/Protocol/Handler/InlayHint/InlayHintResolveData.cs index ea549b4facc50..302f8b78e76a8 100644 --- a/src/Features/LanguageServer/Protocol/Handler/InlayHint/InlayHintResolveData.cs +++ b/src/Features/LanguageServer/Protocol/Handler/InlayHint/InlayHintResolveData.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler.InlayHint; diff --git a/src/Features/LanguageServer/Protocol/Handler/InlayHint/InlayHintResolveHandler.cs b/src/Features/LanguageServer/Protocol/Handler/InlayHint/InlayHintResolveHandler.cs index cad8944a8c64f..607af391f2339 100644 --- a/src/Features/LanguageServer/Protocol/Handler/InlayHint/InlayHintResolveHandler.cs +++ b/src/Features/LanguageServer/Protocol/Handler/InlayHint/InlayHintResolveHandler.cs @@ -10,11 +10,11 @@ using System.Threading.Tasks; using Microsoft.CodeAnalysis.InlineHints; using Microsoft.CodeAnalysis.LanguageServer.Handler.CodeLens; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Newtonsoft.Json.Linq; using Roslyn.Utilities; using StreamJsonRpc; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler.InlayHint { diff --git a/src/Features/LanguageServer/Protocol/Handler/InlineCompletions/InlineCompletionsHandler.cs b/src/Features/LanguageServer/Protocol/Handler/InlineCompletions/InlineCompletionsHandler.cs index 5e355cdecd880..334264c6e6270 100644 --- a/src/Features/LanguageServer/Protocol/Handler/InlineCompletions/InlineCompletionsHandler.cs +++ b/src/Features/LanguageServer/Protocol/Handler/InlineCompletions/InlineCompletionsHandler.cs @@ -19,7 +19,7 @@ using Microsoft.CodeAnalysis.Simplification; using Microsoft.CodeAnalysis.Snippets; using Microsoft.CodeAnalysis.Text; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Roslyn.Utilities; using static Microsoft.CodeAnalysis.LanguageServer.Handler.InlineCompletions.XmlSnippetParser; diff --git a/src/Features/LanguageServer/Protocol/Handler/MapCode/MapCodeHandler.cs b/src/Features/LanguageServer/Protocol/Handler/MapCode/MapCodeHandler.cs index 58ef9df33b1cc..acf2fc021d105 100644 --- a/src/Features/LanguageServer/Protocol/Handler/MapCode/MapCodeHandler.cs +++ b/src/Features/LanguageServer/Protocol/Handler/MapCode/MapCodeHandler.cs @@ -13,9 +13,9 @@ using Microsoft.CodeAnalysis.PooledObjects; using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.Text; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Roslyn.Utilities; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler; diff --git a/src/Features/LanguageServer/Protocol/Handler/MapCode/MapCodeParams.cs b/src/Features/LanguageServer/Protocol/Handler/MapCode/MapCodeParams.cs index 46072ff8913ba..013baf735acf5 100644 --- a/src/Features/LanguageServer/Protocol/Handler/MapCode/MapCodeParams.cs +++ b/src/Features/LanguageServer/Protocol/Handler/MapCode/MapCodeParams.cs @@ -3,8 +3,9 @@ // See the LICENSE file in the project root for more information. using System.Runtime.Serialization; +using Roslyn.LanguageServer.Protocol; -namespace Microsoft.VisualStudio.LanguageServer.Protocol; +namespace Roslyn.LanguageServer.Protocol; /// /// LSP Params for textDocument/mapCode calls. diff --git a/src/Features/LanguageServer/Protocol/Handler/OnAutoInsert/OnAutoInsertHandler.cs b/src/Features/LanguageServer/Protocol/Handler/OnAutoInsert/OnAutoInsertHandler.cs index 4abc6158ac136..a488aefea3f12 100644 --- a/src/Features/LanguageServer/Protocol/Handler/OnAutoInsert/OnAutoInsertHandler.cs +++ b/src/Features/LanguageServer/Protocol/Handler/OnAutoInsert/OnAutoInsertHandler.cs @@ -20,7 +20,7 @@ using Microsoft.CodeAnalysis.Text; using Roslyn.Utilities; using static Microsoft.CodeAnalysis.Completion.Utilities; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler { diff --git a/src/Features/LanguageServer/Protocol/Handler/ProjectContext/GetTextDocumentWithContextHandler.cs b/src/Features/LanguageServer/Protocol/Handler/ProjectContext/GetTextDocumentWithContextHandler.cs index 1c1e201e3698d..1fd14087e596d 100644 --- a/src/Features/LanguageServer/Protocol/Handler/ProjectContext/GetTextDocumentWithContextHandler.cs +++ b/src/Features/LanguageServer/Protocol/Handler/ProjectContext/GetTextDocumentWithContextHandler.cs @@ -10,7 +10,7 @@ using System.Threading.Tasks; using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.Shared.Extensions; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.LanguageServer.Handler diff --git a/src/Features/LanguageServer/Protocol/Handler/PullHandlers/PreviousPullResult.cs b/src/Features/LanguageServer/Protocol/Handler/PullHandlers/PreviousPullResult.cs index 85e419c56b1f6..d164a5b185708 100644 --- a/src/Features/LanguageServer/Protocol/Handler/PullHandlers/PreviousPullResult.cs +++ b/src/Features/LanguageServer/Protocol/Handler/PullHandlers/PreviousPullResult.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler { diff --git a/src/Features/LanguageServer/Protocol/Handler/References/FindAllReferencesHandler.cs b/src/Features/LanguageServer/Protocol/Handler/References/FindAllReferencesHandler.cs index 6736cab54c59e..ef7205e352c11 100644 --- a/src/Features/LanguageServer/Protocol/Handler/References/FindAllReferencesHandler.cs +++ b/src/Features/LanguageServer/Protocol/Handler/References/FindAllReferencesHandler.cs @@ -14,9 +14,9 @@ using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.Shared.TestHooks; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Roslyn.Utilities; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler { diff --git a/src/Features/LanguageServer/Protocol/Handler/References/FindImplementationsHandler.cs b/src/Features/LanguageServer/Protocol/Handler/References/FindImplementationsHandler.cs index 2905d8f9653ed..4217f4b9d99e4 100644 --- a/src/Features/LanguageServer/Protocol/Handler/References/FindImplementationsHandler.cs +++ b/src/Features/LanguageServer/Protocol/Handler/References/FindImplementationsHandler.cs @@ -11,7 +11,7 @@ using Microsoft.CodeAnalysis.PooledObjects; using Microsoft.CodeAnalysis.Shared.Extensions; using Roslyn.Utilities; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler { diff --git a/src/Features/LanguageServer/Protocol/Handler/References/FindUsagesLSPContext.cs b/src/Features/LanguageServer/Protocol/Handler/References/FindUsagesLSPContext.cs index 110a6e446d196..c5c8fa6e63fa6 100644 --- a/src/Features/LanguageServer/Protocol/Handler/References/FindUsagesLSPContext.cs +++ b/src/Features/LanguageServer/Protocol/Handler/References/FindUsagesLSPContext.cs @@ -22,11 +22,11 @@ using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.Shared.TestHooks; using Microsoft.CodeAnalysis.Text; -using Microsoft.VisualStudio.Core.Imaging; -using Microsoft.VisualStudio.LanguageServer.Protocol; -using Microsoft.VisualStudio.Text.Adornments; +using Roslyn.Core.Imaging; +using Roslyn.LanguageServer.Protocol; +using Roslyn.Text.Adornments; using Roslyn.Utilities; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler { diff --git a/src/Features/LanguageServer/Protocol/Handler/References/ILspReferencesResultCreationService.cs b/src/Features/LanguageServer/Protocol/Handler/References/ILspReferencesResultCreationService.cs index 6fadd171ec877..c5595c28e852c 100644 --- a/src/Features/LanguageServer/Protocol/Handler/References/ILspReferencesResultCreationService.cs +++ b/src/Features/LanguageServer/Protocol/Handler/References/ILspReferencesResultCreationService.cs @@ -7,9 +7,9 @@ using System.Composition; using Microsoft.CodeAnalysis.Host; using Microsoft.CodeAnalysis.Host.Mef; -using Microsoft.VisualStudio.LanguageServer.Protocol; -using Microsoft.VisualStudio.Text.Adornments; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; +using Roslyn.Text.Adornments; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler { diff --git a/src/Features/LanguageServer/Protocol/Handler/Rename/PrepareRenameHandler.cs b/src/Features/LanguageServer/Protocol/Handler/Rename/PrepareRenameHandler.cs index 7a91b654fa385..9e63126ea323e 100644 --- a/src/Features/LanguageServer/Protocol/Handler/Rename/PrepareRenameHandler.cs +++ b/src/Features/LanguageServer/Protocol/Handler/Rename/PrepareRenameHandler.cs @@ -9,7 +9,7 @@ using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.Rename; using Roslyn.Utilities; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler; diff --git a/src/Features/LanguageServer/Protocol/Handler/Rename/RenameHandler.cs b/src/Features/LanguageServer/Protocol/Handler/Rename/RenameHandler.cs index 82cef1c639851..80a0e0c693d35 100644 --- a/src/Features/LanguageServer/Protocol/Handler/Rename/RenameHandler.cs +++ b/src/Features/LanguageServer/Protocol/Handler/Rename/RenameHandler.cs @@ -11,9 +11,9 @@ using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.Rename; using Microsoft.CodeAnalysis.Shared.Extensions; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Roslyn.Utilities; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler { diff --git a/src/Features/LanguageServer/Protocol/Handler/RequestContext.cs b/src/Features/LanguageServer/Protocol/Handler/RequestContext.cs index f85b0291b3bb8..82afc2c53d20d 100644 --- a/src/Features/LanguageServer/Protocol/Handler/RequestContext.cs +++ b/src/Features/LanguageServer/Protocol/Handler/RequestContext.cs @@ -11,7 +11,7 @@ using Microsoft.CodeAnalysis.Features.Workspaces; using Microsoft.CodeAnalysis.Text; using Microsoft.CommonLanguageServerProtocol.Framework; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.LanguageServer.Handler; diff --git a/src/Features/LanguageServer/Protocol/Handler/RequestContextFactory.cs b/src/Features/LanguageServer/Protocol/Handler/RequestContextFactory.cs index dd902cc006bb0..4038a80b9f512 100644 --- a/src/Features/LanguageServer/Protocol/Handler/RequestContextFactory.cs +++ b/src/Features/LanguageServer/Protocol/Handler/RequestContextFactory.cs @@ -6,7 +6,7 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.CommonLanguageServerProtocol.Framework; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler; diff --git a/src/Features/LanguageServer/Protocol/Handler/SemanticTokens/SemanticTokensHelpers.cs b/src/Features/LanguageServer/Protocol/Handler/SemanticTokens/SemanticTokensHelpers.cs index ff15456b7928e..e32216ac37d2a 100644 --- a/src/Features/LanguageServer/Protocol/Handler/SemanticTokens/SemanticTokensHelpers.cs +++ b/src/Features/LanguageServer/Protocol/Handler/SemanticTokens/SemanticTokensHelpers.cs @@ -15,9 +15,9 @@ using Microsoft.CodeAnalysis.PooledObjects; using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.Text; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Roslyn.Utilities; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler.SemanticTokens { diff --git a/src/Features/LanguageServer/Protocol/Handler/SemanticTokens/SemanticTokensRangeHandler.cs b/src/Features/LanguageServer/Protocol/Handler/SemanticTokens/SemanticTokensRangeHandler.cs index c5b4ffdda0cde..899203510b20d 100644 --- a/src/Features/LanguageServer/Protocol/Handler/SemanticTokens/SemanticTokensRangeHandler.cs +++ b/src/Features/LanguageServer/Protocol/Handler/SemanticTokens/SemanticTokensRangeHandler.cs @@ -6,9 +6,9 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Options; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Roslyn.Utilities; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler.SemanticTokens { diff --git a/src/Features/LanguageServer/Protocol/Handler/SemanticTokens/SemanticTokensRefreshQueue.cs b/src/Features/LanguageServer/Protocol/Handler/SemanticTokens/SemanticTokensRefreshQueue.cs index f7da5f648e32f..6c70136f6ab64 100644 --- a/src/Features/LanguageServer/Protocol/Handler/SemanticTokens/SemanticTokensRefreshQueue.cs +++ b/src/Features/LanguageServer/Protocol/Handler/SemanticTokens/SemanticTokensRefreshQueue.cs @@ -12,7 +12,7 @@ using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.Shared.TestHooks; using Microsoft.CodeAnalysis.Shared.Utilities; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.LanguageServer.Handler.SemanticTokens; diff --git a/src/Features/LanguageServer/Protocol/Handler/SemanticTokens/SemanticTokensSchema.cs b/src/Features/LanguageServer/Protocol/Handler/SemanticTokens/SemanticTokensSchema.cs index 716485cbbb64b..94cdb33c0955e 100644 --- a/src/Features/LanguageServer/Protocol/Handler/SemanticTokens/SemanticTokensSchema.cs +++ b/src/Features/LanguageServer/Protocol/Handler/SemanticTokens/SemanticTokensSchema.cs @@ -6,7 +6,7 @@ using System.Collections.Immutable; using System.Linq; using Microsoft.CodeAnalysis.Classification; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.LanguageServer.Handler.SemanticTokens diff --git a/src/Features/LanguageServer/Protocol/Handler/SemanticTokens/TokenModifiers.cs b/src/Features/LanguageServer/Protocol/Handler/SemanticTokens/TokenModifiers.cs index 8591b19b6f0d3..c93cf9c6c35ce 100644 --- a/src/Features/LanguageServer/Protocol/Handler/SemanticTokens/TokenModifiers.cs +++ b/src/Features/LanguageServer/Protocol/Handler/SemanticTokens/TokenModifiers.cs @@ -7,7 +7,7 @@ namespace Microsoft.CodeAnalysis.LanguageServer.Handler.SemanticTokens { /// - /// The LSP modifiers from + /// The LSP modifiers from /// Roslyn currently supports. Enum is used to signify the modifier(s) that apply to a given token. /// [Flags] diff --git a/src/Features/LanguageServer/Protocol/Handler/ServerLifetime/InitializeHandler.cs b/src/Features/LanguageServer/Protocol/Handler/ServerLifetime/InitializeHandler.cs index 788a3a20f1f8f..94d4759c38bc1 100644 --- a/src/Features/LanguageServer/Protocol/Handler/ServerLifetime/InitializeHandler.cs +++ b/src/Features/LanguageServer/Protocol/Handler/ServerLifetime/InitializeHandler.cs @@ -6,7 +6,7 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Internal.Log; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Newtonsoft.Json; namespace Microsoft.CodeAnalysis.LanguageServer.Handler; diff --git a/src/Features/LanguageServer/Protocol/Handler/ServerLifetime/InitializedHandler.cs b/src/Features/LanguageServer/Protocol/Handler/ServerLifetime/InitializedHandler.cs index dd7a3fea0c425..61025fd484088 100644 --- a/src/Features/LanguageServer/Protocol/Handler/ServerLifetime/InitializedHandler.cs +++ b/src/Features/LanguageServer/Protocol/Handler/ServerLifetime/InitializedHandler.cs @@ -4,7 +4,7 @@ using System.Threading; using System.Threading.Tasks; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler; diff --git a/src/Features/LanguageServer/Protocol/Handler/ServerLifetime/LspServiceLifeCycleManager.cs b/src/Features/LanguageServer/Protocol/Handler/ServerLifetime/LspServiceLifeCycleManager.cs index d288fde036c4a..ace973dc8d915 100644 --- a/src/Features/LanguageServer/Protocol/Handler/ServerLifetime/LspServiceLifeCycleManager.cs +++ b/src/Features/LanguageServer/Protocol/Handler/ServerLifetime/LspServiceLifeCycleManager.cs @@ -6,7 +6,7 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.CommonLanguageServerProtocol.Framework; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using StreamJsonRpc; namespace Microsoft.CodeAnalysis.LanguageServer.Handler.ServerLifetime; diff --git a/src/Features/LanguageServer/Protocol/Handler/SignatureHelp/SignatureHelpHandler.cs b/src/Features/LanguageServer/Protocol/Handler/SignatureHelp/SignatureHelpHandler.cs index b49379730822c..058779150580c 100644 --- a/src/Features/LanguageServer/Protocol/Handler/SignatureHelp/SignatureHelpHandler.cs +++ b/src/Features/LanguageServer/Protocol/Handler/SignatureHelp/SignatureHelpHandler.cs @@ -13,8 +13,8 @@ using Microsoft.CodeAnalysis.PooledObjects; using Microsoft.CodeAnalysis.SignatureHelp; using Microsoft.CodeAnalysis.Options; -using Microsoft.VisualStudio.Text.Adornments; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.Text.Adornments; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler { diff --git a/src/Features/LanguageServer/Protocol/Handler/SpellCheck/AbstractSpellCheckingHandler.cs b/src/Features/LanguageServer/Protocol/Handler/SpellCheck/AbstractSpellCheckingHandler.cs index 8dab6ef3d19b7..d3b4eaea093af 100644 --- a/src/Features/LanguageServer/Protocol/Handler/SpellCheck/AbstractSpellCheckingHandler.cs +++ b/src/Features/LanguageServer/Protocol/Handler/SpellCheck/AbstractSpellCheckingHandler.cs @@ -12,7 +12,7 @@ using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.SpellCheck; using Microsoft.CommonLanguageServerProtocol.Framework; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.LanguageServer.Handler.SpellCheck diff --git a/src/Features/LanguageServer/Protocol/Handler/SpellCheck/DocumentSpellCheckHandler.cs b/src/Features/LanguageServer/Protocol/Handler/SpellCheck/DocumentSpellCheckHandler.cs index c81eb31a6fddb..33931ed8fdc6d 100644 --- a/src/Features/LanguageServer/Protocol/Handler/SpellCheck/DocumentSpellCheckHandler.cs +++ b/src/Features/LanguageServer/Protocol/Handler/SpellCheck/DocumentSpellCheckHandler.cs @@ -5,7 +5,7 @@ using System; using System.Collections.Immutable; using System.Threading; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler.SpellCheck { diff --git a/src/Features/LanguageServer/Protocol/Handler/SpellCheck/WorkspaceSpellCheckHandler.cs b/src/Features/LanguageServer/Protocol/Handler/SpellCheck/WorkspaceSpellCheckHandler.cs index 3766656d8f230..b8ce56eb1cd0b 100644 --- a/src/Features/LanguageServer/Protocol/Handler/SpellCheck/WorkspaceSpellCheckHandler.cs +++ b/src/Features/LanguageServer/Protocol/Handler/SpellCheck/WorkspaceSpellCheckHandler.cs @@ -7,7 +7,7 @@ using System.Threading; using Microsoft.CodeAnalysis.ExternalAccess.Razor.Api; using Microsoft.CodeAnalysis.PooledObjects; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.LanguageServer.Handler.SpellCheck diff --git a/src/Features/LanguageServer/Protocol/Handler/Symbols/DocumentSymbolsHandler.cs b/src/Features/LanguageServer/Protocol/Handler/Symbols/DocumentSymbolsHandler.cs index b23fa5975d386..1e5a06a5fee98 100644 --- a/src/Features/LanguageServer/Protocol/Handler/Symbols/DocumentSymbolsHandler.cs +++ b/src/Features/LanguageServer/Protocol/Handler/Symbols/DocumentSymbolsHandler.cs @@ -13,9 +13,9 @@ using Microsoft.CodeAnalysis.PooledObjects; using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.Text; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Roslyn.Utilities; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler { diff --git a/src/Features/LanguageServer/Protocol/Handler/Symbols/ILspSymbolInformationCreationService.cs b/src/Features/LanguageServer/Protocol/Handler/Symbols/ILspSymbolInformationCreationService.cs index 2bf00d1031cbd..ebc72add98679 100644 --- a/src/Features/LanguageServer/Protocol/Handler/Symbols/ILspSymbolInformationCreationService.cs +++ b/src/Features/LanguageServer/Protocol/Handler/Symbols/ILspSymbolInformationCreationService.cs @@ -6,8 +6,8 @@ using System.Composition; using Microsoft.CodeAnalysis.Host; using Microsoft.CodeAnalysis.Host.Mef; -using Microsoft.VisualStudio.LanguageServer.Protocol; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler { diff --git a/src/Features/LanguageServer/Protocol/Handler/Symbols/RoslynDocumentSymbol.cs b/src/Features/LanguageServer/Protocol/Handler/Symbols/RoslynDocumentSymbol.cs index 32caf9fc4ac34..a508b0251c4b8 100644 --- a/src/Features/LanguageServer/Protocol/Handler/Symbols/RoslynDocumentSymbol.cs +++ b/src/Features/LanguageServer/Protocol/Handler/Symbols/RoslynDocumentSymbol.cs @@ -3,7 +3,7 @@ // See the LICENSE file in the project root for more information. using System.Runtime.Serialization; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Newtonsoft.Json; namespace Microsoft.CodeAnalysis.LanguageServer.Handler diff --git a/src/Features/LanguageServer/Protocol/Handler/Symbols/RoslynDocumentSymbolParams.cs b/src/Features/LanguageServer/Protocol/Handler/Symbols/RoslynDocumentSymbolParams.cs index 1e72b3b7bdae5..ac79269e2d44b 100644 --- a/src/Features/LanguageServer/Protocol/Handler/Symbols/RoslynDocumentSymbolParams.cs +++ b/src/Features/LanguageServer/Protocol/Handler/Symbols/RoslynDocumentSymbolParams.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Newtonsoft.Json; namespace Microsoft.CodeAnalysis.LanguageServer.Handler diff --git a/src/Features/LanguageServer/Protocol/Handler/Symbols/WorkspaceSymbolsHandler.cs b/src/Features/LanguageServer/Protocol/Handler/Symbols/WorkspaceSymbolsHandler.cs index 108cb201a8283..b3b1092b37802 100644 --- a/src/Features/LanguageServer/Protocol/Handler/Symbols/WorkspaceSymbolsHandler.cs +++ b/src/Features/LanguageServer/Protocol/Handler/Symbols/WorkspaceSymbolsHandler.cs @@ -10,7 +10,7 @@ using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.NavigateTo; using Microsoft.CodeAnalysis.Shared.TestHooks; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.LanguageServer.Handler diff --git a/src/Features/LanguageServer/Protocol/Handler/Testing/RunTestsParams.cs b/src/Features/LanguageServer/Protocol/Handler/Testing/RunTestsParams.cs index 75d45f75f56b0..f02f51dc1b58b 100644 --- a/src/Features/LanguageServer/Protocol/Handler/Testing/RunTestsParams.cs +++ b/src/Features/LanguageServer/Protocol/Handler/Testing/RunTestsParams.cs @@ -4,20 +4,20 @@ using System; using System.Runtime.Serialization; -using Microsoft.VisualStudio.LanguageServer.Protocol; using Newtonsoft.Json; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler.Testing; [DataContract] internal record RunTestsParams( - [property: DataMember(Name = "textDocument")] TextDocumentIdentifier TextDocument, - [property: DataMember(Name = "range")] VisualStudio.LanguageServer.Protocol.Range Range, + [property: DataMember(Name = "textDocument")] LSP.TextDocumentIdentifier TextDocument, + [property: DataMember(Name = "range")] LSP.Range Range, [property: DataMember(Name = "attachDebugger")] bool AttachDebugger, [property: DataMember(Name = "runSettingsPath")] string? RunSettingsPath -) : IPartialResultParams +) : LSP.IPartialResultParams { - [DataMember(Name = Methods.PartialResultTokenName)] + [DataMember(Name = LSP.Methods.PartialResultTokenName)] [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] public IProgress? PartialResultToken { get; set; } } diff --git a/src/Features/LanguageServer/Protocol/Handler/WorkspaceCommand/ExecuteWorkspaceCommandHandler.cs b/src/Features/LanguageServer/Protocol/Handler/WorkspaceCommand/ExecuteWorkspaceCommandHandler.cs index 6b72be29076fc..761da70bf4244 100644 --- a/src/Features/LanguageServer/Protocol/Handler/WorkspaceCommand/ExecuteWorkspaceCommandHandler.cs +++ b/src/Features/LanguageServer/Protocol/Handler/WorkspaceCommand/ExecuteWorkspaceCommandHandler.cs @@ -9,7 +9,7 @@ using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.LanguageServer.Handler.Commands; using Microsoft.CommonLanguageServerProtocol.Framework; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler; diff --git a/src/Features/LanguageServer/Protocol/ICapabilitiesProvider.cs b/src/Features/LanguageServer/Protocol/ICapabilitiesProvider.cs index 317f540badede..2d2f8b29769b2 100644 --- a/src/Features/LanguageServer/Protocol/ICapabilitiesProvider.cs +++ b/src/Features/LanguageServer/Protocol/ICapabilitiesProvider.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer { diff --git a/src/Features/LanguageServer/Protocol/IOnInitialize.cs b/src/Features/LanguageServer/Protocol/IOnInitialize.cs index 8b168e2345c61..b55062502eccc 100644 --- a/src/Features/LanguageServer/Protocol/IOnInitialize.cs +++ b/src/Features/LanguageServer/Protocol/IOnInitialize.cs @@ -5,7 +5,7 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.LanguageServer.Handler; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer; diff --git a/src/Features/LanguageServer/Protocol/LanguageServerProtocolResources.Designer.cs b/src/Features/LanguageServer/Protocol/LanguageServerProtocolResources.Designer.cs new file mode 100644 index 0000000000000..3497173ee3129 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/LanguageServerProtocolResources.Designer.cs @@ -0,0 +1,126 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Microsoft.CodeAnalysis.LanguageServer { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class LanguageServerProtocolResources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal LanguageServerProtocolResources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.CodeAnalysis.LanguageServer.LanguageServerProtocolResources", typeof(LanguageServerProtocolResources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to Unable to deserialize Uri. Unexpected value encountered: {0}. + /// + internal static string DocumentUriSerializationError { + get { + return ResourceManager.GetString("DocumentUriSerializationError", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Unable to deserialize MarkupContent. Unexpected value encountered: {0}. + /// + internal static string MarkupContentSerializationError { + get { + return ResourceManager.GetString("MarkupContentSerializationError", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to A SumType cannot have another SumType as type parameter.. + /// + internal static string NestedSumType { + get { + return ResourceManager.GetString("NestedSumType", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to None of the SumType type parameters could be deserialized. + /// + internal static string NoSumTypeMatch { + get { + return ResourceManager.GetString("NoSumTypeMatch", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Type {0} is missing a contructor that takes a single string as parameter.. + /// + internal static string StringEnumMissingConstructor { + get { + return ResourceManager.GetString("StringEnumMissingConstructor", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Unable to deserialize string-based enum. Unexpected data encountered: {0}. + /// + internal static string StringEnumSerializationError { + get { + return ResourceManager.GetString("StringEnumSerializationError", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Unable to deserialize TextDocumentSyncOptions. Unexpected value encountered: {0}. + /// + internal static string TextDocumentSyncSerializationError { + get { + return ResourceManager.GetString("TextDocumentSyncSerializationError", resourceCulture); + } + } + } +} diff --git a/src/Features/LanguageServer/Protocol/LanguageServerProtocolResources.resx b/src/Features/LanguageServer/Protocol/LanguageServerProtocolResources.resx new file mode 100644 index 0000000000000..7dc4d9c00c182 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/LanguageServerProtocolResources.resx @@ -0,0 +1,122 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Unable to deserialize Uri. Unexpected value encountered: {0} + + + Unable to deserialize MarkupContent. Unexpected value encountered: {0} + + + A SumType cannot have another SumType as type parameter. + + + None of the SumType type parameters could be deserialized + + + Type {0} is missing a contructor that takes a single string as parameter. + + + Unable to deserialize string-based enum. Unexpected data encountered: {0} + + + Unable to deserialize TextDocumentSyncOptions. Unexpected value encountered: {0} + + \ No newline at end of file diff --git a/src/Features/LanguageServer/Protocol/LanguageServerResources.cs b/src/Features/LanguageServer/Protocol/LanguageServerResources.cs deleted file mode 100644 index e15c6f1fb49c4..0000000000000 --- a/src/Features/LanguageServer/Protocol/LanguageServerResources.cs +++ /dev/null @@ -1,13 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace Microsoft.CodeAnalysis.LanguageServer -{ - /// - /// Stub type - replace with type generated from resx file when resources are needed in this assembly. - /// - internal static class LanguageServerProtocolResources - { - } -} diff --git a/src/Features/LanguageServer/Protocol/Microsoft.CodeAnalysis.LanguageServer.Protocol.csproj b/src/Features/LanguageServer/Protocol/Microsoft.CodeAnalysis.LanguageServer.Protocol.csproj index 6bfd8f20ad908..4ee2ee47ef920 100644 --- a/src/Features/LanguageServer/Protocol/Microsoft.CodeAnalysis.LanguageServer.Protocol.csproj +++ b/src/Features/LanguageServer/Protocol/Microsoft.CodeAnalysis.LanguageServer.Protocol.csproj @@ -20,9 +20,6 @@ - - - @@ -75,6 +72,12 @@ + + + + + + @@ -83,17 +86,18 @@ - + + LanguageServerProtocolResources.resx True True - LanguageServerResources.resx - + + Designer + LanguageServerProtocolResources.Designer.cs ResXFileCodeGenerator - LanguageServerResources.Designer.cs diff --git a/src/Features/LanguageServer/Protocol/Protocol/.editorconfig b/src/Features/LanguageServer/Protocol/Protocol/.editorconfig new file mode 100644 index 0000000000000..f5785864979ea --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/.editorconfig @@ -0,0 +1,22 @@ +[*.cs] + +# CS0436: Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. +dotnet_diagnostic.CS0436.severity = none + +# CS8618: Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. +dotnet_diagnostic.CS8618.severity = none + +# CS8765: Nullability of type of parameter 'other' doesn't match overridden member (possibly because of nullability attributes). +dotnet_diagnostic.CS8765.severity = none + +# CS8767: Nullability of reference types in type of parameter 'other' of 'bool CodeDescription.Equals(CodeDescription other)' doesn't match implicitly implemented member 'bool IEquatable.Equals(CodeDescription? other)' (possibly because of nullability attributes). +dotnet_diagnostic.CS8767.severity = none + +# CS8603: Possible null reference return. +dotnet_diagnostic.CS8603.severity = none + +# CS8604: Possible null reference argument for parameter 'uriString' in 'Uri.Uri(string uriString)'. +dotnet_diagnostic.CS8604.severity = none + +# RS0030: The symbol 'Uri.Uri(string)' is banned in this project +dotnet_diagnostic.RS0030.severity = none diff --git a/src/Features/LanguageServer/Protocol/Protocol/ApplyWorkspaceEditParams.cs b/src/Features/LanguageServer/Protocol/Protocol/ApplyWorkspaceEditParams.cs new file mode 100644 index 0000000000000..7e4930168f914 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/ApplyWorkspaceEditParams.cs @@ -0,0 +1,39 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing the parameters sent from a server to a client for the workspace/applyEdit request. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class ApplyWorkspaceEditParams + { + /// + /// Gets or sets the label associated with this edit. + /// + [DataMember(Name = "label")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? Label + { + get; + set; + } + + /// + /// Gets or sets the edit to be applied to the workspace. + /// + [DataMember(Name = "edit")] + public WorkspaceEdit Edit + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/ApplyWorkspaceEditResponse.cs b/src/Features/LanguageServer/Protocol/Protocol/ApplyWorkspaceEditResponse.cs new file mode 100644 index 0000000000000..080ce8850873f --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/ApplyWorkspaceEditResponse.cs @@ -0,0 +1,39 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing the response sent for a workspace/applyEdit request. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class ApplyWorkspaceEditResponse + { + /// + /// Gets or sets a value indicating whether edits were applied or not. + /// + [DataMember(Name = "applied")] + public bool Applied + { + get; + set; + } + + /// + /// Gets or sets a string with textual description for why the edit was not applied. + /// + [DataMember(Name = "failureReason")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? FailureReason + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/ClientCapabilities.cs b/src/Features/LanguageServer/Protocol/Protocol/ClientCapabilities.cs new file mode 100644 index 0000000000000..aa135aefed881 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/ClientCapabilities.cs @@ -0,0 +1,51 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class which represents client capabilities. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class ClientCapabilities + { + /// + /// Gets or sets the workspace capabilities. + /// + [DataMember(Name = "workspace")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public WorkspaceClientCapabilities? Workspace + { + get; + set; + } + + /// + /// Gets or sets the text document capabilities. + /// + [DataMember(Name = "textDocument")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public TextDocumentClientCapabilities? TextDocument + { + get; + set; + } + + /// + /// Gets or sets the experimental capabilities. + /// + [DataMember(Name = "experimental")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public object? Experimental + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/CodeAction.cs b/src/Features/LanguageServer/Protocol/Protocol/CodeAction.cs new file mode 100644 index 0000000000000..86df1605432f0 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/CodeAction.cs @@ -0,0 +1,85 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// A class representing a change that can be performed in code. A CodeAction must either set + /// or . If both are supplied, + /// the edit will be applied first, then the command will be executed. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class CodeAction + { + /// + /// Gets or sets the human readable title for this code action. + /// + [DataMember(Name = "title")] + public string Title + { + get; + set; + } + + /// + /// Gets or sets the kind of code action this instance represents. + /// + [DataMember(Name = "kind")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public CodeActionKind? Kind + { + get; + set; + } + + /// + /// Gets or sets the diagnostics that this code action resolves. + /// + [DataMember(Name = "diagnostics")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public Diagnostic[]? Diagnostics + { + get; + set; + } + + /// + /// Gets or sets the workspace edit that this code action performs. + /// + [DataMember(Name = "edit")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public WorkspaceEdit? Edit + { + get; + set; + } + + /// + /// Gets or sets the command that this code action executes. + /// + [DataMember(Name = "command")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public Command? Command + { + get; + set; + } + + /// + /// Gets or sets the data that will be resend to the server if the code action is selected to be resolved. + /// + [DataMember(Name = "data")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public object? Data + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/CodeActionContext.cs b/src/Features/LanguageServer/Protocol/Protocol/CodeActionContext.cs new file mode 100644 index 0000000000000..2ccf570a49f2d --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/CodeActionContext.cs @@ -0,0 +1,50 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing diagnostic information about the context of a code action + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class CodeActionContext + { + /// + /// Gets or sets an array of diagnostics relevant to a code action. + /// + [DataMember(Name = "diagnostics")] + public Diagnostic[] Diagnostics + { + get; + set; + } + + /// + /// Gets or sets an array of code action kinds to filter for. + /// + [DataMember(Name = "only")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public CodeActionKind[]? Only + { + get; + set; + } + + /// + /// Gets or sets the indicating how the code action was triggered.. + /// + [DataMember(Name = "triggerKind")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public CodeActionTriggerKind? TriggerKind + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/CodeActionKind.cs b/src/Features/LanguageServer/Protocol/Protocol/CodeActionKind.cs new file mode 100644 index 0000000000000..264756a446c2c --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/CodeActionKind.cs @@ -0,0 +1,74 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.ComponentModel; + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Value representing the kind of a code action. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + [JsonConverter(typeof(StringEnumConverter))] + [TypeConverter(typeof(StringEnumConverter.TypeConverter))] + internal readonly record struct CodeActionKind(string Value) : IStringEnum + { + /// + /// Empty kind. + /// + public static readonly CodeActionKind Empty = new(string.Empty); + + /// + /// Code action is a refactor. + /// + public static readonly CodeActionKind QuickFix = new("quickfix"); + + /// + /// Base kind for refactoring actions. + /// + public static readonly CodeActionKind Refactor = new("refactor"); + + /// + /// Base kind for refactoring extraction actions, like extracting methods, functions, + /// variables, etc. + /// + public static readonly CodeActionKind RefactorExtract = new("refactor.extract"); + + /// + /// Base kind for refactoring inline actions, like inlining functions, variables, + /// constants, etc. + /// + public static readonly CodeActionKind RefactorInline = new("refactor.inline"); + + /// + /// Base kind for refactoring rewrite actions, like adding or removing a parameter, + /// making a method static, etc. + /// + public static readonly CodeActionKind RefactorRewrite = new("refactor.rewrite"); + + /// + /// Base kind for source actions, which apply to the entire file. + /// + public static readonly CodeActionKind Source = new("source"); + + /// + /// Base kind for an organize imports source action. + /// + public static readonly CodeActionKind SourceOrganizeImports = new("source.organizeImports"); + + /// + /// Base kind for a fix all source action, which automatically fixes errors that have a clear + /// fix that do not require user input. + /// + /// + /// They should not suppress errors or perform unsafe fixes such as generating new + /// types or classes. + /// + public static readonly CodeActionKind SourceFixAll = new("source.fixAll"); + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/CodeActionKindSetting.cs b/src/Features/LanguageServer/Protocol/Protocol/CodeActionKindSetting.cs new file mode 100644 index 0000000000000..1ec354679a037 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/CodeActionKindSetting.cs @@ -0,0 +1,27 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// Class containing the set of code action kinds that are supported. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class CodeActionKindSetting + { + /// + /// Gets or sets the code actions kinds the client supports. + /// + [DataMember(Name = "valueSet")] + public CodeActionKind[] ValueSet + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/CodeActionLiteralSetting.cs b/src/Features/LanguageServer/Protocol/Protocol/CodeActionLiteralSetting.cs new file mode 100644 index 0000000000000..92e1cc4a4f9b7 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/CodeActionLiteralSetting.cs @@ -0,0 +1,27 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// Class representing support for code action literals. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class CodeActionLiteralSetting + { + /// + /// Gets or sets a value indicating what code action kinds are supported. + /// + [DataMember(Name = "codeActionKind")] + public CodeActionKindSetting CodeActionKind + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/CodeActionOptions.cs b/src/Features/LanguageServer/Protocol/Protocol/CodeActionOptions.cs new file mode 100644 index 0000000000000..698727c5466cc --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/CodeActionOptions.cs @@ -0,0 +1,56 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing the registration options for code actions support. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class CodeActionOptions : IWorkDoneProgressOptions + { + /// + /// Gets or sets the kinds of code action that this server may return. + /// + /// + /// The list of kinds may be generic, such as `CodeActionKind.Refactor`, or the server + /// may list out every specific kind they provide. + /// + [DataMember(Name = "codeActionKinds")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public CodeActionKind[]? CodeActionKinds + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether work done progress is supported. + /// + [DataMember(Name = "workDoneProgress")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool WorkDoneProgress + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether the server provides support to resolve + /// additional information for a code action. + /// + [DataMember(Name = "resolveProvider")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool ResolveProvider + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/CodeActionParams.cs b/src/Features/LanguageServer/Protocol/Protocol/CodeActionParams.cs new file mode 100644 index 0000000000000..67f546f31ba48 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/CodeActionParams.cs @@ -0,0 +1,47 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// Class representing the parameters sent from the client to the server for the textDocument/codeAction request. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class CodeActionParams : ITextDocumentParams + { + /// + /// Gets or sets the document identifier indicating where the command was invoked. + /// + [DataMember(Name = "textDocument")] + public TextDocumentIdentifier TextDocument + { + get; + set; + } + + /// + /// Gets or sets the range in the document for which the command was invoked. + /// + [DataMember(Name = "range")] + public Range Range + { + get; + set; + } + + /// + /// Gets or sets the additional diagnostic information about the code action context. + /// + [DataMember(Name = "context")] + public CodeActionContext Context + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/CodeActionResolveSupportSetting.cs b/src/Features/LanguageServer/Protocol/Protocol/CodeActionResolveSupportSetting.cs new file mode 100644 index 0000000000000..6649a9adf92c9 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/CodeActionResolveSupportSetting.cs @@ -0,0 +1,28 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing settings for codeAction/resolve support. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class CodeActionResolveSupportSetting + { + /// + /// Gets or sets a value indicating the properties that a client can resolve lazily. + /// + [DataMember(Name = "properties")] + public string[] Properties + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/CodeActionSetting.cs b/src/Features/LanguageServer/Protocol/Protocol/CodeActionSetting.cs new file mode 100644 index 0000000000000..4af0f9f18dd66 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/CodeActionSetting.cs @@ -0,0 +1,55 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing settings for code action support. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class CodeActionSetting : DynamicRegistrationSetting + { + /// + /// Gets or sets a value indicating the client supports code action literals. + /// + [DataMember(Name = "codeActionLiteralSupport")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public CodeActionLiteralSetting? CodeActionLiteralSupport + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether the client supports resolving + /// additional code action properties via a separate `codeAction/resolve` + /// request. + /// + [DataMember(Name = "resolveSupport")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public CodeActionResolveSupportSetting? ResolveSupport + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether code action supports the `data` + /// property which is preserved between a `textDocument/codeAction` and a + /// `codeAction/resolve` request. + /// + [DataMember(Name = "dataSupport")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool DataSupport + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/CodeActionTriggerKind.cs b/src/Features/LanguageServer/Protocol/Protocol/CodeActionTriggerKind.cs new file mode 100644 index 0000000000000..14413d38f3ead --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/CodeActionTriggerKind.cs @@ -0,0 +1,28 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// Enum which represents the various reason why code actions were requested. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal enum CodeActionTriggerKind + { + /// + /// Code actions were explicitly requested by the user or by an extension. + /// + Invoked = 1, + + /// + /// Code actions were requested automatically. + /// This typically happens when current selection in a file changes, but can also be triggered when file content changes. + /// + Automatic = 2, + } +} \ No newline at end of file diff --git a/src/Features/LanguageServer/Protocol/Protocol/CodeDescription.cs b/src/Features/LanguageServer/Protocol/Protocol/CodeDescription.cs new file mode 100644 index 0000000000000..b91705db37fb0 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/CodeDescription.cs @@ -0,0 +1,76 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System; + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing a description for an error code. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class CodeDescription : IEquatable + { + /// + /// Gets or sets URI to open with more information about the diagnostic error. + /// + [DataMember(Name = "href")] + [JsonConverter(typeof(DocumentUriConverter))] + public Uri Href + { + get; + set; + } + + public static bool operator ==(CodeDescription? value1, CodeDescription? value2) + { + if (ReferenceEquals(value1, value2)) + { + return true; + } + + if (ReferenceEquals(null, value2)) + { + return false; + } + + return value1?.Equals(value2) ?? false; + } + + public static bool operator !=(CodeDescription? value1, CodeDescription? value2) + { + return !(value1 == value2); + } + + /// + public bool Equals(CodeDescription other) + { + return other is not null + && this.Href == other.Href; + } + + /// + public override bool Equals(object obj) + { + if (obj is CodeDescription other) + { + return this.Equals(other); + } + else + { + return false; + } + } + + /// + public override int GetHashCode() + { + return this.Href == null ? 53 : this.Href.GetHashCode(); + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/CodeLens.cs b/src/Features/LanguageServer/Protocol/Protocol/CodeLens.cs new file mode 100644 index 0000000000000..c88d783e26953 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/CodeLens.cs @@ -0,0 +1,50 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// A class representing a code lens command that should be shown alongside source code. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class CodeLens + { + /// + /// Gets or sets the range that the code lens applies to. + /// + [DataMember(Name = "range")] + public Range Range + { + get; + set; + } + + /// + /// Gets or sets the command associated with this code lens. + /// + [DataMember(Name = "command")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public Command? Command + { + get; + set; + } + + /// + /// Gets or sets the data that should be preserved between a textDocument/codeLens request and a codeLens/resolve request. + /// + [DataMember(Name = "data")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public object? Data + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/CodeLensOptions.cs b/src/Features/LanguageServer/Protocol/Protocol/CodeLensOptions.cs new file mode 100644 index 0000000000000..23cd60deaf41b --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/CodeLensOptions.cs @@ -0,0 +1,40 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing the options for code lens support. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class CodeLensOptions : IWorkDoneProgressOptions + { + /// + /// Gets or sets a value indicating whether or not the code lens support has a resolve provider. + /// + [DataMember(Name = "resolveProvider")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool ResolveProvider + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether work done progress is supported. + /// + [DataMember(Name = "workDoneProgress")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool WorkDoneProgress + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/CodeLensParams.cs b/src/Features/LanguageServer/Protocol/Protocol/CodeLensParams.cs new file mode 100644 index 0000000000000..d58fea7b19dec --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/CodeLensParams.cs @@ -0,0 +1,27 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// Class representing the parameters sent from the client to the server for a textDocument/codeLens request. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class CodeLensParams : ITextDocumentParams + { + /// + /// Gets or sets the document identifier to fetch code lens results for. + /// + [DataMember(Name = "textDocument")] + public TextDocumentIdentifier TextDocument + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/CodeLensWorkspaceSetting.cs b/src/Features/LanguageServer/Protocol/Protocol/CodeLensWorkspaceSetting.cs new file mode 100644 index 0000000000000..76543e6b1a334 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/CodeLensWorkspaceSetting.cs @@ -0,0 +1,25 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using Newtonsoft.Json; +using System.Runtime.Serialization; + +namespace Roslyn.LanguageServer.Protocol +{ + /// + /// Class representing the workspace code lens client capabilities. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class CodeLensWorkspaceSetting + { + /// + /// Gets or sets a value indicating whether the client supports a refresh request sent from the server to the client. + /// + [DataMember(Name = "refreshSupport")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool RefreshSupport { get; set; } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Color.cs b/src/Features/LanguageServer/Protocol/Protocol/Color.cs new file mode 100644 index 0000000000000..bda5111332f02 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Color.cs @@ -0,0 +1,53 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// Class which represents a color. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class Color + { + /// + /// Gets or sets the Red value. + /// + /// + /// Value should be clamped to [0,1]. + /// + [DataMember(Name = "red")] + public decimal Red { get; set; } + + /// + /// Gets or sets the Green value. + /// + /// + /// Value should be clamped to [0,1]. + /// + [DataMember(Name = "green")] + public decimal Green { get; set; } + + /// + /// Gets or sets the Blue value. + /// + /// + /// Value should be clamped to [0,1]. + /// + [DataMember(Name = "blue")] + public decimal Blue { get; set; } + + /// + /// Gets or sets the Alpha value. + /// + /// + /// Value should be clamped to [0,1]. + /// + [DataMember(Name = "alpha")] + public decimal Alpha { get; set; } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/ColorInformation.cs b/src/Features/LanguageServer/Protocol/Protocol/ColorInformation.cs new file mode 100644 index 0000000000000..e2cf2f0433fad --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/ColorInformation.cs @@ -0,0 +1,29 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// Class which represents color information. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class ColorInformation + { + /// + /// Gets or sets the text range representing the color. + /// + [DataMember(Name = "range")] + public Range Range { get; set; } + + /// + /// Gets or sets the color. + /// + [DataMember(Name = "color")] + public Color Color { get; set; } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Command.cs b/src/Features/LanguageServer/Protocol/Protocol/Command.cs new file mode 100644 index 0000000000000..d3effcdb1b3ae --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Command.cs @@ -0,0 +1,51 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing a reference to a command + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class Command + { + /// + /// Gets or sets the title of the command. + /// + [DataMember(Name = "title")] + [JsonProperty(Required = Required.Always)] + public string Title + { + get; + set; + } + + /// + /// Gets or sets the identifier associated with the command. + /// + [DataMember(Name = "command")] + [JsonProperty(Required = Required.Always)] + public string CommandIdentifier + { + get; + set; + } + + /// + /// Gets or sets the arguments that the command should be invoked with. + /// + [DataMember(Name = "arguments")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public object[]? Arguments + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/CompletionContext.cs b/src/Features/LanguageServer/Protocol/Protocol/CompletionContext.cs new file mode 100644 index 0000000000000..609242748d6b3 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/CompletionContext.cs @@ -0,0 +1,39 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing additional information about the content in which a completion request is triggered. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class CompletionContext + { + /// + /// Gets or sets the indicating how the completion was triggered. + /// + [DataMember(Name = "triggerKind")] + public CompletionTriggerKind TriggerKind + { + get; + set; + } + + /// + /// Gets or sets the character that triggered code completion. + /// + [DataMember(Name = "triggerCharacter")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? TriggerCharacter + { + get; + set; + } + } +} \ No newline at end of file diff --git a/src/Features/LanguageServer/Protocol/Protocol/CompletionItem.cs b/src/Features/LanguageServer/Protocol/Protocol/CompletionItem.cs new file mode 100644 index 0000000000000..acd63d0657304 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/CompletionItem.cs @@ -0,0 +1,209 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.ComponentModel; + using System.Diagnostics.CodeAnalysis; + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class which represents an IntelliSense completion item. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class CompletionItem + { + /// + /// Gets or sets the label value, i.e. display text to users. + /// + [DataMember(Name = "label", IsRequired = true)] + public string Label + { + get; + set; + } + + /// + /// Gets or sets additional details for the label. + /// + [DataMember(Name = "labelDetails")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public CompletionItemLabelDetails? LabelDetails + { + get; + set; + } + + /// + /// Gets or sets the completion kind. + /// + [DataMember(Name = "kind")] + [SuppressMessage("Microsoft.StyleCop.CSharp.LayoutRules", "SA1513:ClosingCurlyBracketMustBeFollowedByBlankLine", Justification = "There are no issues with this code")] + [SuppressMessage("Microsoft.StyleCop.CSharp.LayoutRules", "SA1500:BracesForMultiLineStatementsShouldNotShareLine", Justification = "There are no issues with this code")] + [DefaultValue(CompletionItemKind.None)] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public CompletionItemKind Kind + { + get; + set; + } = CompletionItemKind.None; + + /// + /// Gets or sets the completion detail. + /// + [DataMember(Name = "detail")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? Detail + { + get; + set; + } + + /// + /// Gets or sets the documentation comment. + /// + [DataMember(Name = "documentation")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public SumType? Documentation + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether this should be the selected item when showing. + /// + [DataMember(Name = "preselect")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool Preselect + { + get; + set; + } + + /// + /// Gets or sets the custom sort text. + /// + [DataMember(Name = "sortText")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? SortText + { + get; + set; + } + + /// + /// Gets or sets the custom filter text. + /// + [DataMember(Name = "filterText")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? FilterText + { + get; + set; + } + + /// + /// Gets or sets the insert text. + /// + [DataMember(Name = "insertText")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? InsertText + { + get; + set; + } + + /// + /// Gets or sets the insert text format. + /// + [DataMember(Name = "insertTextFormat")] + [SuppressMessage("Microsoft.StyleCop.CSharp.LayoutRules", "SA1513:ClosingCurlyBracketMustBeFollowedByBlankLine", Justification = "There are no issues with this code")] + [SuppressMessage("Microsoft.StyleCop.CSharp.LayoutRules", "SA1500:BracesForMultiLineStatementsShouldNotShareLine", Justification = "There are no issues with this code")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + [DefaultValue(InsertTextFormat.Plaintext)] + public InsertTextFormat InsertTextFormat + { + get; + set; + } = InsertTextFormat.Plaintext; + + /// + /// Gets or sets the text edit. + /// + [DataMember(Name = "textEdit")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public SumType? TextEdit + { + get; + set; + } + + /// + /// Gets or sets the text edit text. + /// + [DataMember(Name = "textEditText")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? TextEditText + { + get; + set; + } + + /// + /// Gets or sets any additional text edits. + /// + /// + /// Additional text edits must not interfere with the main text edit. + /// + [DataMember(Name = "additionalTextEdits")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public TextEdit[]? AdditionalTextEdits + { + get; + set; + } + + /// + /// Gets or sets the set of characters that will commit completion when this is selected + /// If present, this will override . + /// If absent, will be used instead. + /// + [DataMember(Name = "commitCharacters")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string[]? CommitCharacters + { + get; + set; + } + + /// + /// Gets or sets any optional command that will be executed after completion item insertion. + /// + /// + /// This feature is not supported in VS. + /// + [DataMember(Name = "command")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public Command? Command + { + get; + set; + } + + /// + /// Gets or sets any additional data that links the unresolve completion item and the resolved completion item. + /// + [DataMember(Name = "data")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public object? Data + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/CompletionItemKind.cs b/src/Features/LanguageServer/Protocol/Protocol/CompletionItemKind.cs new file mode 100644 index 0000000000000..24a46531e3b3c --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/CompletionItemKind.cs @@ -0,0 +1,208 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + /// + /// Enum values for completion item kinds. + /// + /// See the Language Server Protocol specification for additional information. + /// + internal enum CompletionItemKind + { + /// + /// Value to use when no kind was provided. + /// + None = 0, + + // LSP Spec v3.16: + + /// + /// Text. + /// + Text = 1, + + /// + /// Method. + /// + Method = 2, + + /// + /// Function. + /// + Function = 3, + + /// + /// Constructor. + /// + Constructor = 4, + + /// + /// Field. + /// + Field = 5, + + /// + /// Variable. + /// + Variable = 6, + + /// + /// Class. + /// + Class = 7, + + /// + /// Interface. + /// + Interface = 8, + + /// + /// Module. + /// + Module = 9, + + /// + /// Property. + /// + Property = 10, + + /// + /// Unit. + /// + Unit = 11, + + /// + /// Value. + /// + Value = 12, + + /// + /// Enum. + /// + Enum = 13, + + /// + /// Keyword. + /// + Keyword = 14, + + /// + /// Snippet. + /// + Snippet = 15, + + /// + /// Color. + /// + Color = 16, + + /// + /// File. + /// + File = 17, + + /// + /// Reference. + /// + Reference = 18, + + /// + /// Folder. + /// + Folder = 19, + + /// + /// EnumMember. + /// + EnumMember = 20, + + /// + /// Constant. + /// + Constant = 21, + + /// + /// Struct. + /// + Struct = 22, + + /// + /// Event. + /// + Event = 23, + + /// + /// Operator. + /// + Operator = 24, + + /// + /// TypeParameter. + /// + TypeParameter = 25, + + // Kinds custom to VS, starting with index 118115 to avoid collisions with other clients's custom kinds. + + /// + /// Macro. + /// + Macro = 118115 + 0, + + /// + /// Namespace. + /// + Namespace = 118115 + 1, + + /// + /// Template. + /// + Template = 118115 + 2, + + /// + /// TypeDefinition. + /// + TypeDefinition = 118115 + 3, + + /// + /// Union. + /// + Union = 118115 + 4, + + /// + /// Delegate. + /// + Delegate = 118115 + 5, + + /// + /// TagHelper. + /// + TagHelper = 118115 + 6, + + /// + /// ExtensionMethod. + /// + ExtensionMethod = 118115 + 7, + + /// + /// Element. + /// + Element = 118115 + 8, + + /// + /// LocalResource. + /// + LocalResource = 118115 + 9, + + /// + /// SystemResource. + /// + SystemResource = 118115 + 10, + + /// + /// CloseElement. + /// + CloseElement = 118115 + 11, + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/CompletionItemKindSetting.cs b/src/Features/LanguageServer/Protocol/Protocol/CompletionItemKindSetting.cs new file mode 100644 index 0000000000000..2322270f54e5d --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/CompletionItemKindSetting.cs @@ -0,0 +1,29 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class which represents the initialization setting for completion item kind + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class CompletionItemKindSetting + { + /// + /// Gets or sets the values that the client supports. + /// + [DataMember(Name = "valueSet")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public CompletionItemKind[]? ValueSet + { + get; + set; + } + } +} \ No newline at end of file diff --git a/src/Features/LanguageServer/Protocol/Protocol/CompletionItemLabelDetails.cs b/src/Features/LanguageServer/Protocol/Protocol/CompletionItemLabelDetails.cs new file mode 100644 index 0000000000000..43b290c77361b --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/CompletionItemLabelDetails.cs @@ -0,0 +1,40 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using Newtonsoft.Json; + using System.Runtime.Serialization; + + /// + /// Additional details for a completion item label. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class CompletionItemLabelDetails + { + /// + /// Gets or sets an optional string which is rendered less prominently directly after label, without any spacing. + /// + [DataMember(Name = "detail")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? Detail + { + get; + set; + } + + /// + /// Gets or sets an optional string which is rendered less prominently after detail. + /// + [DataMember(Name = "description")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? Description + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/CompletionItemOptions.cs b/src/Features/LanguageServer/Protocol/Protocol/CompletionItemOptions.cs new file mode 100644 index 0000000000000..9686561c69c7b --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/CompletionItemOptions.cs @@ -0,0 +1,29 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class which represents completion item capabilities. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class CompletionItemOptions + { + /// + /// Gets or sets a value indicating The server has support for completion item label details + /// + [DataMember(Name = "labelDetailsSupport")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool LabelDetailsSupport + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/CompletionItemSetting.cs b/src/Features/LanguageServer/Protocol/Protocol/CompletionItemSetting.cs new file mode 100644 index 0000000000000..58c655a5256c5 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/CompletionItemSetting.cs @@ -0,0 +1,128 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class which represents initialization setting for completion item. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class CompletionItemSetting + { + /// + /// Gets or sets a value indicating whether completion items can contain snippets. + /// + [DataMember(Name = "snippetSupport")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool SnippetSupport + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether the client supports commit characters. + /// + [DataMember(Name = "commitCharactersSupport")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool CommitCharactersSupport + { + get; + set; + } + + /// + /// Gets or sets the content formats supported for documentation. + /// + [DataMember(Name = "documentationFormat")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public MarkupKind[]? DocumentationFormat + { + get; + set; + } + + /// + /// Gets or sets the a value indicating whether the client supports the deprecated property on a completion item. + /// + [DataMember(Name = "deprecatedSupport")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool DeprecatedSupport + { + get; + set; + } + + /// + /// Gets or sets the a value indicating whether the client supports the preselect property on a completion item. + /// + [DataMember(Name = "preselectSupport")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool PreselectSupport + { + get; + set; + } + + /// + /// Gets or sets the a value indicating whether the client supports the tag property on a completion item. + /// + [DataMember(Name = "tagSupport")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public CompletionItemTagSupportSetting? TagSupport + { + get; + set; + } + + /// + /// Gets or sets the a value indicating whether the client supports insert replace edit. + /// + [DataMember(Name = "insertReplaceSupport")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool InsertReplaceSupport + { + get; + set; + } + + /// + /// Gets or sets the a value indicating which properties a client can resolve lazily on a completion item. + /// + [DataMember(Name = "resolveSupport")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public ResolveSupportSetting? ResolveSupport + { + get; + set; + } + + /// + /// Gets or sets the a value indicating whether the client supports the `insertTextMode` property on a completion item to override the whitespace handling mode as defined by the client. + /// + [DataMember(Name = "insertTextModeSupport")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public InsertTextModeSupportSetting? InsertTextModeSupport + { + get; + set; + } + + /// + /// Gets or sets the a value indicating whether the client supports completion item label details. + /// + [DataMember(Name = "labelDetailsSupport")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool LabelDetailsSupport + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/CompletionItemTag.cs b/src/Features/LanguageServer/Protocol/Protocol/CompletionItemTag.cs new file mode 100644 index 0000000000000..349e188ce5087 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/CompletionItemTag.cs @@ -0,0 +1,19 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + /// + /// Completion item tags are extra annotations that tweak the rendering of a completion item. + /// + /// See the Language Server Protocol specification for additional information. + /// + internal enum CompletionItemTag + { + /// + /// Render a completion as obsolete, usually using a strike-out. + /// + Deprecated = 1, + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/CompletionItemTagSupportSetting.cs b/src/Features/LanguageServer/Protocol/Protocol/CompletionItemTagSupportSetting.cs new file mode 100644 index 0000000000000..94b64986cff53 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/CompletionItemTagSupportSetting.cs @@ -0,0 +1,27 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// Class which represents initialization setting for the tag property on a completion item. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class CompletionItemTagSupportSetting + { + /// + /// Gets or sets a value indicating the tags supported by the client. + /// + [DataMember(Name = "valueSet", IsRequired = true)] + public CompletionItemTag[] ValueSet + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/CompletionList.cs b/src/Features/LanguageServer/Protocol/Protocol/CompletionList.cs new file mode 100644 index 0000000000000..6189603e856f0 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/CompletionList.cs @@ -0,0 +1,51 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + using Newtonsoft.Json; + + /// + /// Class which represents a completion list. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class CompletionList + { + /// + /// Gets or sets a value indicating whether Items is the complete list of items or not. If incomplete is true, then + /// filtering should ask the server again for completion item. + /// + [DataMember(Name = "isIncomplete")] + public bool IsIncomplete + { + get; + set; + } + + /// + /// Gets or sets the list of completion items. + /// + [DataMember(Name = "items")] + public CompletionItem[] Items + { + get; + set; + } + + /// + /// Gets or sets the completion list item defaults. + /// + [DataMember(Name = "itemDefaults")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public CompletionListItemDefaults? ItemDefaults + { + get; + set; + } + } +} \ No newline at end of file diff --git a/src/Features/LanguageServer/Protocol/Protocol/CompletionListItemDefaults.cs b/src/Features/LanguageServer/Protocol/Protocol/CompletionListItemDefaults.cs new file mode 100644 index 0000000000000..9c30582f3790a --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/CompletionListItemDefaults.cs @@ -0,0 +1,71 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class which represents default properties associated with the entire completion list. + /// + [DataContract] + internal class CompletionListItemDefaults + { + /// + /// Gets or sets the default commit character set. + /// + [DataMember(Name = "commitCharacters")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string[]? CommitCharacters + { + get; + set; + } + + /// + /// Gets or sets the default edit range. + /// + [DataMember(Name = "editRange")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public SumType? EditRange + { + get; + set; + } + + /// + /// Gets or sets the default . + /// + [DataMember(Name = "insertTextFormat")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public InsertTextFormat? InsertTextFormat + { + get; + set; + } + + /// + /// Gets or sets the default . + /// + [DataMember(Name = "insertTextMode")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public InsertTextMode? InsertTextMode + { + get; + set; + } + + /// + /// Gets or sets the default completion item data. + /// + [DataMember(Name = "data")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public object? Data + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/CompletionListSetting.cs b/src/Features/LanguageServer/Protocol/Protocol/CompletionListSetting.cs new file mode 100644 index 0000000000000..6ae332b4c314b --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/CompletionListSetting.cs @@ -0,0 +1,29 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + using Newtonsoft.Json; + + /// + /// Class which represents capabilites for the completion list type. + /// + [DataContract] + internal class CompletionListSetting + { + /// + /// Gets or sets a value containing the supported property names of the object. + /// If omitted, no properties are supported. + /// + [DataMember(Name = "itemDefaults")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string[]? ItemDefaults + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/CompletionOptions.cs b/src/Features/LanguageServer/Protocol/Protocol/CompletionOptions.cs new file mode 100644 index 0000000000000..2671ce6ef6959 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/CompletionOptions.cs @@ -0,0 +1,73 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class which represents completion capabilities. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class CompletionOptions : IWorkDoneProgressOptions + { + /// + /// Gets or sets the trigger characters. + /// + [DataMember(Name = "triggerCharacters")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string[]? TriggerCharacters + { + get; + set; + } + + /// + /// Gets or sets a value indicating all the possible commit characters associated with the language server. + /// + [DataMember(Name = "allCommitCharacters")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string[]? AllCommitCharacters + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether server provides completion item resolve capabilities. + /// + [DataMember(Name = "resolveProvider")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool ResolveProvider + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether work done progress is supported. + /// + [DataMember(Name = "workDoneProgress")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool WorkDoneProgress + { + get; + set; + } + + /// + /// Gets or sets completion item setting. + /// + [DataMember(Name = "completionItem")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public CompletionItemOptions? CompletionItemOptions + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/CompletionParams.cs b/src/Features/LanguageServer/Protocol/Protocol/CompletionParams.cs new file mode 100644 index 0000000000000..0756a75604049 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/CompletionParams.cs @@ -0,0 +1,41 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System; + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing the parameters for the textDocument/completion request. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class CompletionParams : TextDocumentPositionParams, IPartialResultParams?> + { + /// + /// Gets or sets the completion context. + /// + [DataMember(Name = "context")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public CompletionContext? Context + { + get; + set; + } + + /// + /// Gets or sets the value of the PartialResultToken instance. + /// + [DataMember(Name = Methods.PartialResultTokenName)] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public IProgress?>? PartialResultToken + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/CompletionSetting.cs b/src/Features/LanguageServer/Protocol/Protocol/CompletionSetting.cs new file mode 100644 index 0000000000000..d05a2bcac679e --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/CompletionSetting.cs @@ -0,0 +1,73 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class which represents initialization setting for completion. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class CompletionSetting : DynamicRegistrationSetting + { + /// + /// Gets or sets completion item setting. + /// + [DataMember(Name = "completionItem")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public CompletionItemSetting? CompletionItem + { + get; + set; + } + + /// + /// Gets or sets specific settings. + /// + [DataMember(Name = "completionItemKind")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public CompletionItemKindSetting? CompletionItemKind + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether the client supports sending additional context. + /// + [DataMember(Name = "contextSupport")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool ContextSupport + { + get; + set; + } + + /// + /// Gets or sets a value indicating client's default when the completion item doesn't provide an `insertTextMode` property. + /// + [DataMember(Name = "insertTextMode")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public InsertTextMode? InsertTextMode + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether the client supports capabilities on the completion list. + /// + [DataMember(Name = "completionList")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public CompletionListSetting? CompletionListSetting + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/CompletionTriggerKind.cs b/src/Features/LanguageServer/Protocol/Protocol/CompletionTriggerKind.cs new file mode 100644 index 0000000000000..c6e0289f2196f --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/CompletionTriggerKind.cs @@ -0,0 +1,32 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// Enum which represents the various ways in which completion can be triggered. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal enum CompletionTriggerKind + { + /// + /// Completion was triggered by typing an identifier. + /// + Invoked = 1, + + /// + /// Completion was triggered by typing a trigger character. + /// + TriggerCharacter = 2, + + /// + /// Completion was re-triggered as the current completion list is incomplete. + /// + TriggerForIncompleteCompletions = 3, + } +} \ No newline at end of file diff --git a/src/Features/LanguageServer/Protocol/Protocol/ConfigurationItem.cs b/src/Features/LanguageServer/Protocol/Protocol/ConfigurationItem.cs new file mode 100644 index 0000000000000..28bf61c08039e --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/ConfigurationItem.cs @@ -0,0 +1,42 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System; + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class which represents an configuration item. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class ConfigurationItem + { + /// + /// Gets or sets the scope to get the configuration section for. + /// + [DataMember(Name = "scopeUri")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + [JsonConverter(typeof(DocumentUriConverter))] + public Uri? ScopeUri + { + get; + set; + } + + /// + /// Gets or sets the requested configuration section. + /// + [DataMember(Name = "section")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? Section + { + get; + set; + } + } +} \ No newline at end of file diff --git a/src/Features/LanguageServer/Protocol/Protocol/ConfigurationParams.cs b/src/Features/LanguageServer/Protocol/Protocol/ConfigurationParams.cs new file mode 100644 index 0000000000000..c4547e2f08587 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/ConfigurationParams.cs @@ -0,0 +1,27 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// Class representing the parameters for the workspace/configuration request. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class ConfigurationParams + { + /// + /// Gets or sets the ConfigurationItems being requested. + /// + [DataMember(Name = "items")] + public ConfigurationItem[] Items + { + get; + set; + } + } +} \ No newline at end of file diff --git a/src/Features/LanguageServer/Protocol/Protocol/Converters/DocumentUriConverter.cs b/src/Features/LanguageServer/Protocol/Protocol/Converters/DocumentUriConverter.cs new file mode 100644 index 0000000000000..1da728f7de61d --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Converters/DocumentUriConverter.cs @@ -0,0 +1,60 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System; + using System.Globalization; + using Microsoft.CodeAnalysis.LanguageServer; + using Microsoft.CommonLanguageServerProtocol.Framework; + using Newtonsoft.Json; + using Newtonsoft.Json.Linq; + + /// + /// TODO: document. + /// + internal class DocumentUriConverter : JsonConverter + { + /// + public override bool CanConvert(Type objectType) + { + return true; + } + + /// + public override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer) + { + reader = reader ?? throw new ArgumentNullException(nameof(reader)); + if (reader.TokenType == JsonToken.String) + { + var token = JToken.ReadFrom(reader); + var uri = new Uri(token.ToObject()); + + return uri; + } + else if (reader.TokenType == JsonToken.Null) + { + return null; + } + + throw new JsonSerializationException(string.Format(CultureInfo.InvariantCulture, LanguageServerProtocolResources.DocumentUriSerializationError, reader.Value)); + } + + /// + public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer) + { + writer = writer ?? throw new ArgumentNullException(nameof(writer)); + + if (value is Uri uri) + { + var token = JToken.FromObject(uri.AbsoluteUri); + token.WriteTo(writer); + } + else + { + throw new ArgumentException($"{nameof(value)} must be of type {nameof(Uri)}"); + } + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Converters/JsonConverterCollectionUtilities.cs b/src/Features/LanguageServer/Protocol/Protocol/Converters/JsonConverterCollectionUtilities.cs new file mode 100644 index 0000000000000..207ed168f25e6 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Converters/JsonConverterCollectionUtilities.cs @@ -0,0 +1,19 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using Newtonsoft.Json; + + /// + /// Class containing extension method to thread-safely manage operations. + /// + internal static class JsonConverterCollectionUtilities + { + /// + /// Lock used for modifications to Converters collection. + /// + public static readonly object ConvertersLock = new object(); + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Converters/KindAttribute.cs b/src/Features/LanguageServer/Protocol/Protocol/Converters/KindAttribute.cs new file mode 100644 index 0000000000000..75dd87154b622 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Converters/KindAttribute.cs @@ -0,0 +1,40 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System; + + /// + /// Attribute that defines the expected value of the JSON property when a type is + /// used in an . + /// + [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = false, Inherited = false)] + internal class KindAttribute : Attribute + { + /// + /// Initializes a new instance of the class. + /// + /// The expected value of the JSON property. + /// The name of the property that is used to identify the contained type of the . + /// Specifying this attribute doesn't automatically include the JSON property upon serialization. + /// + /// In the current implementation the JSON property is always considered required. + public KindAttribute(string kind, string kindPropertyName = "kind") + { + this.Kind = kind ?? throw new ArgumentNullException(nameof(kind)); + this.KindPropertyName = kindPropertyName ?? throw new ArgumentNullException(nameof(kindPropertyName)); + } + + /// + /// Gets the expected value of the JSON property. + /// + public string Kind { get; private set; } + + /// + /// Gets the name of the property that is used to identify the contained type of the . + /// + public string KindPropertyName { get; private set; } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Converters/ParameterInformationConverter.cs b/src/Features/LanguageServer/Protocol/Protocol/Converters/ParameterInformationConverter.cs new file mode 100644 index 0000000000000..ca7ba65725eb1 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Converters/ParameterInformationConverter.cs @@ -0,0 +1,65 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System; + using Newtonsoft.Json; + using Newtonsoft.Json.Linq; + + /// + /// JsonConverter to correctly deserialize int arrays in the Label param of ParameterInformation. + /// + internal class ParameterInformationConverter : JsonConverter + { + /// + public override bool CanWrite => false; + + /// + public override bool CanConvert(Type objectType) + { + return true; + } + + /// + public override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer) + { + var token = JToken.Load(reader); + + var label = ((JObject)token).Property("label", StringComparison.Ordinal); + var documentation = ((JObject)token).Property("documentation", StringComparison.Ordinal); + + var parameter = new ParameterInformation(); + + if (label != null) + { + var value = label.Value; + if (value is JArray arr) + { + var tuple = new Tuple(arr[0].Value(), arr[1].Value()); + parameter.Label = tuple; + } + else + { + // If label is not an array we can serialize it normally + parameter.Label = value.ToObject>>(); + } + } + + if (documentation != null) + { + var value = documentation.Value; + parameter.Documentation = value.ToObject?>(); + } + + return parameter; + } + + /// + public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer) + { + throw new NotImplementedException(); + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Converters/StringEnumConverter.cs b/src/Features/LanguageServer/Protocol/Protocol/Converters/StringEnumConverter.cs new file mode 100644 index 0000000000000..2e93f97371f87 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Converters/StringEnumConverter.cs @@ -0,0 +1,103 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol; + +using System; +using System.ComponentModel; +using System.Globalization; +using System.Linq.Expressions; +using Microsoft.CodeAnalysis.LanguageServer; +using Microsoft.CommonLanguageServerProtocol.Framework; +using Newtonsoft.Json; + +/// +/// JsonConverter for serializing and deserializing string-based enums. +/// +/// The actual type implementing . +internal class StringEnumConverter + : JsonConverter + where TStringEnumType : IStringEnum +{ + private static readonly Func CreateEnum; + + static StringEnumConverter() + { + // TODO. When C# starts supporting static methods in interfaces, add a static Create method to IStringEnum and remove CreateEnum. + var constructor = typeof(TStringEnumType).GetConstructor(new Type[] { typeof(string) }); + if (constructor is null) + { + throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, LanguageServerProtocolResources.StringEnumMissingConstructor, typeof(TStringEnumType).FullName)); + } + + var param = Expression.Parameter(typeof(string), "value"); + var body = Expression.New(constructor, param); + CreateEnum = Expression.Lambda>(body, param).Compile(); + } + + /// + public override bool CanConvert(Type objectType) => objectType == typeof(TStringEnumType); + + /// + public override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer) + { + reader = reader ?? throw new ArgumentNullException(nameof(reader)); + + if (reader.TokenType == JsonToken.String) + { + return CreateEnum((string)reader.Value!); + } + else if (reader.TokenType == JsonToken.Null) + { + return default(TStringEnumType); + } + + throw new JsonSerializationException(string.Format(CultureInfo.InvariantCulture, LanguageServerProtocolResources.StringEnumSerializationError, reader.Value)); + } + + /// + public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer) + { + writer = writer ?? throw new ArgumentNullException(nameof(writer)); + + if (value is TStringEnumType kind) + { + writer.WriteValue(kind.Value); + } + else + { + throw new ArgumentException($"{nameof(value)} must be of type {typeof(TStringEnumType).FullName}"); + } + } + + /// + /// Type converter from to . + /// This is required to support . + /// + internal class TypeConverter + : System.ComponentModel.TypeConverter + { + /// + public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) + { + if (sourceType == typeof(string)) + { + return true; + } + + return base.CanConvertFrom(context, sourceType); + } + + /// + public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) + { + if (value is string stringValue) + { + return CreateEnum(stringValue); + } + + return base.ConvertFrom(context, culture, value); + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Converters/SumConverter.cs b/src/Features/LanguageServer/Protocol/Protocol/Converters/SumConverter.cs new file mode 100644 index 0000000000000..1ef563f3ff4d6 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Converters/SumConverter.cs @@ -0,0 +1,270 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System; + using System.Collections.Concurrent; + using System.Collections.Generic; + using System.Linq; + using System.Reflection; + using Microsoft.CodeAnalysis.LanguageServer; + using Microsoft.CommonLanguageServerProtocol.Framework; + using Newtonsoft.Json; + using Newtonsoft.Json.Linq; + + /// + /// Converter to translate to and from SumTypes. + /// + internal class SumConverter : JsonConverter + { + private static readonly ConcurrentDictionary SumTypeCache = new ConcurrentDictionary(); + + /// + public override bool CanConvert(Type objectType) + { + return typeof(ISumType).IsAssignableFrom(objectType); + } + + /// + public override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer) + { + reader = reader ?? throw new ArgumentNullException(nameof(reader)); + serializer = serializer ?? throw new ArgumentNullException(nameof(serializer)); + + // Even if CanConvert only returns true for ISumType, ReadJson is invoked for Nullable> as well + if (reader.TokenType == JsonToken.Null) + { + if (objectType.IsGenericType && objectType.GetGenericTypeDefinition() == typeof(Nullable<>)) + { + return null; + } + else + { + // We shouldn't really ever have a non-Nullable SumType being received as null but, if we do, return an "empty" SumType + return Activator.CreateInstance(objectType); + } + } + + // objectType will be one of the various SumType variants. In order for this converter to work with all SumTypes it has to use reflection. + // This method works by attempting to deserialize the json into each of the type parameters to a SumType and stops at the first success. + var sumTypeInfoCache = SumTypeCache.GetOrAdd(objectType, (t) => new SumTypeInfoCache(t)); + + JToken? token = null; + var applicableUnionTypeInfos = sumTypeInfoCache.GetApplicableInfos(reader.TokenType); + + for (var i = 0; i < applicableUnionTypeInfos.Count; i++) + { + var unionTypeInfo = applicableUnionTypeInfos[i]; + + if (!IsTokenCompatibleWithType(reader, unionTypeInfo)) + { + continue; + } + + try + { + object? sumValue; + if (token == null && i + 1 == applicableUnionTypeInfos.Count) + { + // We're at the very last entry, we don't need to maintain the JsonReader, can read directly from the JsonReader to avoid the inbetween JObject type. + sumValue = serializer.Deserialize(reader, unionTypeInfo.Type); + } + else + { + if (token == null) + { + token = JToken.ReadFrom(reader); + } + + if (unionTypeInfo.KindAttribute is not null && + (token is not JObject jObject || jObject[unionTypeInfo.KindAttribute.KindPropertyName]?.ToString() != unionTypeInfo.KindAttribute.Kind)) + { + continue; + } + + sumValue = token.ToObject(unionTypeInfo.Type, serializer); + } + + object?[] args = { sumValue }; + var sum = unionTypeInfo.Constructor.Invoke(args); + return sum; + } + catch + { + continue; + } + } + + throw new JsonSerializationException(LanguageServerProtocolResources.NoSumTypeMatch); + } + + /// + public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer) + { + writer = writer ?? throw new ArgumentNullException(nameof(writer)); + + if (value is null) + { + writer.WriteNull(); + } + else + { + writer = writer ?? throw new ArgumentNullException(nameof(writer)); + + var sumValue = ((ISumType)value!).Value; + + if (sumValue != null) + { + var token = JToken.FromObject(sumValue); + token.WriteTo(writer); + } + } + } + + private static bool IsTokenCompatibleWithType(JsonReader reader, SumTypeInfoCache.UnionTypeInfo unionTypeInfo) + { + var isCompatible = true; + switch (reader.TokenType) + { + case JsonToken.Float: + isCompatible = unionTypeInfo.Type == typeof(double) || + unionTypeInfo.Type == typeof(float); + break; + case JsonToken.Boolean: + isCompatible = unionTypeInfo.Type == typeof(bool); + break; + case JsonToken.Integer: + isCompatible = unionTypeInfo.Type == typeof(int) || + unionTypeInfo.Type == typeof(uint) || + unionTypeInfo.Type == typeof(long) || + unionTypeInfo.Type == typeof(ulong) || + unionTypeInfo.Type == typeof(short) || + unionTypeInfo.Type == typeof(ushort) || + unionTypeInfo.Type == typeof(byte) || + unionTypeInfo.Type == typeof(sbyte) || + unionTypeInfo.Type == typeof(double) || + unionTypeInfo.Type == typeof(float); + break; + case JsonToken.String: + isCompatible = unionTypeInfo.Type == typeof(string) || + typeof(IStringEnum).IsAssignableFrom(unionTypeInfo.Type); + break; + } + + return isCompatible; + } + + private class SumTypeInfoCache + { + // netstandard1.0 doesn't support Array.Empty +#pragma warning disable CA1825 // Avoid zero-length array allocations. + private static readonly IReadOnlyList EmptyUnionInfos = new UnionTypeInfo[0]; +#pragma warning restore CA1825 // Avoid zero-length array allocations. + + private readonly IReadOnlyList allUnionTypeInfos; + + private readonly IReadOnlyList primitiveUnionTypeInfos; + + private readonly IReadOnlyList arrayUnionTypeInfos; + + private readonly IReadOnlyList objectUnionTypeInfos; + + public SumTypeInfoCache(Type sumTypeType) + { + var allUnionTypeInfosSet = new List(); + List? primitiveUnionTypeInfosSet = null; + List? arrayUnionTypeInfosSet = null; + List? objectUnionTypeInfosSet = null; + + // If the SumType is a nullable extract the underlying type and re-assign + sumTypeType = NormalizeToNonNullable(sumTypeType); + + var typeInfo = sumTypeType.GetTypeInfo(); + var parameterTypes = typeInfo.GenericTypeArguments; + foreach (var parameterType in parameterTypes) + { + var parameterTypeInfo = NormalizeToNonNullable(parameterType).GetTypeInfo(); + var declaredConstructor = typeInfo.GetConstructor(new Type[] { parameterType }) ?? + throw new ArgumentException(nameof(sumTypeType), "All constructor parameter types must be represented in the generic type arguments of the SumType"); + + var kindAttribute = parameterType.GetCustomAttribute(); + var unionTypeInfo = new UnionTypeInfo(parameterType, declaredConstructor, kindAttribute); + allUnionTypeInfosSet.Add(unionTypeInfo); + + if (parameterTypeInfo.IsPrimitive || + parameterTypeInfo == typeof(string) || + typeof(IStringEnum).IsAssignableFrom(parameterTypeInfo)) + { + primitiveUnionTypeInfosSet ??= new List(); + primitiveUnionTypeInfosSet.Add(unionTypeInfo); + } + else if (parameterTypeInfo.IsArray) + { + arrayUnionTypeInfosSet ??= new List(); + arrayUnionTypeInfosSet.Add(unionTypeInfo); + } + else + { + objectUnionTypeInfosSet ??= new List(); + objectUnionTypeInfosSet.Add(unionTypeInfo); + } + } + + this.allUnionTypeInfos = allUnionTypeInfosSet; + this.primitiveUnionTypeInfos = primitiveUnionTypeInfosSet ?? EmptyUnionInfos; + this.arrayUnionTypeInfos = arrayUnionTypeInfosSet ?? EmptyUnionInfos; + if ((objectUnionTypeInfosSet?.Count ?? 0) > 1) + { + // If some types are tagged with a KindAttribute, make sure they are first in the list in order to avoid the wrong type being deserialized + this.objectUnionTypeInfos = objectUnionTypeInfosSet.Where(t => t.KindAttribute is not null).Concat( + objectUnionTypeInfosSet.Where(t => t.KindAttribute is null)).ToList(); + } + else + { + this.objectUnionTypeInfos = objectUnionTypeInfosSet ?? EmptyUnionInfos; + } + } + + public IReadOnlyList GetApplicableInfos(JsonToken startingTokenType) + { + return startingTokenType switch + { + JsonToken.StartArray + => this.arrayUnionTypeInfos, + JsonToken.Integer or + JsonToken.Float or + JsonToken.Bytes or + JsonToken.String or + JsonToken.Boolean + => this.primitiveUnionTypeInfos, + JsonToken.StartObject + => this.objectUnionTypeInfos, + _ => this.allUnionTypeInfos, + }; + } + + private static Type NormalizeToNonNullable(Type sumTypeType) + { + return Nullable.GetUnderlyingType(sumTypeType) ?? sumTypeType; + } + + internal class UnionTypeInfo + { + public UnionTypeInfo(Type type, ConstructorInfo constructor, KindAttribute? kindAttribute) + { + this.Type = type ?? throw new ArgumentNullException(nameof(type)); + this.Constructor = constructor ?? throw new ArgumentNullException(nameof(constructor)); + this.KindAttribute = kindAttribute; + } + + public Type Type { get; } + + public ConstructorInfo Constructor { get; } + + public KindAttribute? KindAttribute { get; } + } + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Converters/TextDocumentSyncConverter.cs b/src/Features/LanguageServer/Protocol/Protocol/Converters/TextDocumentSyncConverter.cs new file mode 100644 index 0000000000000..a8dd8c1f6e588 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Converters/TextDocumentSyncConverter.cs @@ -0,0 +1,100 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System; + using System.Globalization; + using Microsoft.CodeAnalysis.LanguageServer; + using Microsoft.CommonLanguageServerProtocol.Framework; + using Newtonsoft.Json; + using Newtonsoft.Json.Linq; + + /// + /// Converter which offers custom serialization for enum to a object. + /// + /// + /// This is to support backwards compatibility for the protocol. + /// + internal class TextDocumentSyncConverter : JsonConverter + { + /// + public override bool CanConvert(Type objectType) + { + return true; + } + + /// + /// Deserializes a json value to a object. + /// + /// Reader from which to read json value. + /// Type of the json value. + /// Existing value. + /// Default serializer. + /// A which matches the json value. + public override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer) + { + reader = reader ?? throw new ArgumentNullException(nameof(reader)); + if (reader.TokenType == JsonToken.Float || reader.TokenType == JsonToken.Integer) + { + // This conversion is modeled after what VS Code does, see https://github.com/Microsoft/vscode-languageserver-node/blob/master/client/src/client.ts#L1234 + var textDocSync = new TextDocumentSyncOptions + { + OpenClose = true, + Change = (TextDocumentSyncKind)int.Parse(reader.Value!.ToString(), NumberStyles.Integer, CultureInfo.CurrentCulture), + Save = new SaveOptions + { + IncludeText = false, + }, + }; + + return textDocSync; + } + else if (reader.TokenType == JsonToken.String) + { + return JsonConvert.DeserializeObject(reader.Value!.ToString()); + } + else if (reader.TokenType == JsonToken.StartObject) + { + var token = JToken.ReadFrom(reader); + return token.ToObject(); + } + else if (reader.TokenType == JsonToken.Null) + { + // This conversion is modeled after what VS Code does, see https://github.com/Microsoft/vscode-languageserver-node/blob/master/client/src/client.ts#L1234 + var textDocSync = new TextDocumentSyncOptions + { + OpenClose = true, + Change = TextDocumentSyncKind.None, + Save = new SaveOptions + { + IncludeText = false, + }, + }; + + return textDocSync; + } + + throw new JsonSerializationException(string.Format(CultureInfo.InvariantCulture, LanguageServerProtocolResources.TextDocumentSyncSerializationError, reader.Value)); + } + + /// + public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer) + { + writer = writer ?? throw new ArgumentNullException(nameof(writer)); + + if (value is null) + { + writer.WriteNull(); + } + else + { + writer = writer ?? throw new ArgumentNullException(nameof(writer)); + + var token = JToken.FromObject(value); + token.WriteTo(writer); + } + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/CreateFile.cs b/src/Features/LanguageServer/Protocol/Protocol/CreateFile.cs new file mode 100644 index 0000000000000..8cc16ae3379ff --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/CreateFile.cs @@ -0,0 +1,49 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System; + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing a create file operation. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + [Kind("create")] + internal class CreateFile + { + /// + /// Gets the kind value. + /// + [DataMember(Name = "kind")] + [System.Diagnostics.CodeAnalysis.SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "Member can't be static since it's part of the protocol")] + public string Kind => "create"; + + /// + /// Gets or sets the resource to create. + /// + [DataMember(Name = "uri", IsRequired = true)] + [JsonConverter(typeof(DocumentUriConverter))] + public Uri Uri + { + get; + set; + } + + /// + /// Gets or sets the additional options. + /// + [DataMember(Name = "options")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public CreateFileOptions? Options + { + get; + set; + } + } +} \ No newline at end of file diff --git a/src/Features/LanguageServer/Protocol/Protocol/CreateFileOptions.cs b/src/Features/LanguageServer/Protocol/Protocol/CreateFileOptions.cs new file mode 100644 index 0000000000000..68fcf7c8e30c5 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/CreateFileOptions.cs @@ -0,0 +1,40 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing the options for a create file operation. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class CreateFileOptions + { + /// + /// Gets or sets a value indicating whether the creation should overwrite the file if it already exists. (Overwrite wins over ignoreIfExists). + /// + [DataMember(Name = "overwrite")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool Overwrite + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether the action should be ignored if the file already exists. + /// + [DataMember(Name = "ignoreIfExists")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool IgnoreIfExists + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/CustomDictionary.xml b/src/Features/LanguageServer/Protocol/Protocol/CustomDictionary.xml new file mode 100644 index 0000000000000..1ab85c61f13c6 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/CustomDictionary.xml @@ -0,0 +1,7 @@ + + + + params + + + \ No newline at end of file diff --git a/src/Features/LanguageServer/Protocol/Protocol/DefaultBehaviorPrepareRename.cs b/src/Features/LanguageServer/Protocol/Protocol/DefaultBehaviorPrepareRename.cs new file mode 100644 index 0000000000000..abcd66aa84d61 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/DefaultBehaviorPrepareRename.cs @@ -0,0 +1,30 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class which represents a possible result value of the 'textDocument/prepareRename' request. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class DefaultBehaviorPrepareRename + { + /// + /// Gets or sets a value indicating whether the rename position is valid and the client should use its + /// default behavior to compute the rename range. + /// + [DataMember(Name = "defaultBehavior")] + [JsonProperty(Required = Required.Always)] + public bool DefaultBehavior + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/DefinitionOptions.cs b/src/Features/LanguageServer/Protocol/Protocol/DefinitionOptions.cs new file mode 100644 index 0000000000000..10493fb0aa1cc --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/DefinitionOptions.cs @@ -0,0 +1,29 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class which represents workspace symbols capabilities. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class DefinitionOptions : IWorkDoneProgressOptions + { + /// + /// Gets or sets a value indicating whether work done progress is supported. + /// + [DataMember(Name = "workDoneProgress")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool WorkDoneProgress + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/DeleteFile.cs b/src/Features/LanguageServer/Protocol/Protocol/DeleteFile.cs new file mode 100644 index 0000000000000..dcc6eed78e854 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/DeleteFile.cs @@ -0,0 +1,49 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System; + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing a delete file operation. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + [Kind("delete")] + internal class DeleteFile + { + /// + /// Gets the kind value. + /// + [DataMember(Name = "kind")] + [System.Diagnostics.CodeAnalysis.SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "Member can't be static since it's part of the protocol")] + public string Kind => "delete"; + + /// + /// Gets or sets the file to delete. + /// + [DataMember(Name = "uri", IsRequired = true)] + [JsonConverter(typeof(DocumentUriConverter))] + public Uri Uri + { + get; + set; + } + + /// + /// Gets or sets the additional options. + /// + [DataMember(Name = "options")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public DeleteFileOptions? Options + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/DeleteFileOptions.cs b/src/Features/LanguageServer/Protocol/Protocol/DeleteFileOptions.cs new file mode 100644 index 0000000000000..5e1c8edd9e884 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/DeleteFileOptions.cs @@ -0,0 +1,41 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System; + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing the options for a create file operation. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class DeleteFileOptions + { + /// + /// Gets or sets a value indicating whether the delete operation should be applied recursively if a folder is denoted. (Overwrite wins over ignoreIfNotExists). + /// + [DataMember(Name = "recursive")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool Recursive + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether the action should be ignored if the file doesn't exists. + /// + [DataMember(Name = "ignoreIfNotExists")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool IgnoreIfNotExists + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Diagnostic.cs b/src/Features/LanguageServer/Protocol/Protocol/Diagnostic.cs new file mode 100644 index 0000000000000..d664f263d5a7b --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Diagnostic.cs @@ -0,0 +1,171 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System; + using System.Linq; + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class which represents a source code diagnostic message. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class Diagnostic : IEquatable + { + /// + /// Gets or sets the source code range. + /// + [DataMember(Name = "range")] + public Range Range + { + get; + set; + } + + /// + /// Gets or sets the diagnostic severity. + /// + [DataMember(Name = "severity")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public DiagnosticSeverity? Severity + { + get; + set; + } + + /// + /// Gets or sets the diagnostic's code, which usually appear in the user interface. + /// + /// + /// The value can be an , . + /// + [DataMember(Name = "code")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public SumType? Code + { + get; + set; + } + + /// + /// Gets or sets an optional value that describes the error code. + /// + [DataMember(Name = "codeDescription")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public CodeDescription? CodeDescription + { + get; + set; + } + + /// + /// Gets or sets a human-readable string describing the source of this + /// diagnostic, e.g. 'typescript' or 'super lint'. It usually appears in the user interface. + /// + [DataMember(Name = "source")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? Source + { + get; + set; + } + + /// + /// Gets or sets the diagnostic's message. + /// + [DataMember(Name = "message")] + public string Message + { + get; + set; + } + + /// + /// Gets or sets the diagnostic's tags. + /// + [DataMember(Name = "tags")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public DiagnosticTag[]? Tags + { + get; + set; + } + + /// + /// Gets or sets the diagnostic related information + /// + [DataMember(Name = "relatedInformation")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public DiagnosticRelatedInformation[]? RelatedInformation + { + get; + set; + } + + public static bool operator ==(Diagnostic? value1, Diagnostic? value2) + { + if (ReferenceEquals(value1, value2)) + { + return true; + } + + // Is null? + if (ReferenceEquals(null, value2)) + { + return false; + } + + return value1?.Equals(value2) ?? false; + } + + public static bool operator !=(Diagnostic? value1, Diagnostic? value2) + { + return !(value1 == value2); + } + + /// + public bool Equals(Diagnostic other) + { + return other is not null + && this.Range == other.Range + && this.Severity == other.Severity + && object.Equals(this.Code, other.Code) + && this.CodeDescription == other.CodeDescription + && string.Equals(this.Source, other.Source, StringComparison.Ordinal) + && string.Equals(this.Message, other.Message, StringComparison.Ordinal) + && (this.Tags == null + ? other.Tags == null + : this.Tags.Equals(other.Tags) || this.Tags.SequenceEqual(other.Tags)); + } + + /// + public override bool Equals(object obj) + { + if (obj is Diagnostic other) + { + return this.Equals(other); + } + else + { + return false; + } + } + + /// + public override int GetHashCode() + { + return (this.Range == null ? 53 : this.Range.GetHashCode() * 13) + ^ (this.Severity.GetHashCode() * 17) + ^ (this.Code == null ? 47 : this.Code.GetHashCode() * 19) + ^ (this.Source == null ? 61 : this.Source.GetHashCode() * 79) + ^ (this.Message == null ? 83 : this.Message.GetHashCode() * 23) + ^ (this.Tags == null ? 89 : this.Tags.Sum(t => (int)t) * 73) + ^ (this.CodeDescription == null ? 23 : this.CodeDescription.GetHashCode() * 29); + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/DiagnosticOptions.cs b/src/Features/LanguageServer/Protocol/Protocol/DiagnosticOptions.cs new file mode 100644 index 0000000000000..e9b7898c56d37 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/DiagnosticOptions.cs @@ -0,0 +1,59 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol; + +using System.Runtime.Serialization; +using Newtonsoft.Json; + +/// +/// Server capabilities for pull diagnostics. +/// +/// See the Language Server Protocol specification for additional information. +/// +[DataContract] +internal class DiagnosticOptions : IWorkDoneProgressOptions +{ + /// + /// Gets or sets a value indicating whether work done progress is supported. + /// + [DataMember(Name = "workDoneProgress")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool WorkDoneProgress + { + get; + set; + } + + /// + /// Gets or sets the identifier in which the diagnostics are bucketed by the client. + /// + [DataMember(Name = "identifier")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? Identifier + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether the language has inter file dependencies. + /// + [DataMember(Name = "interFileDependencies")] + public bool InterFileDependencies + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether the server provides support for workspace diagnostics as well. + /// + [DataMember(Name = "workspaceDiagnostics")] + public bool WorkspaceDiagnostics + { + get; + set; + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/DiagnosticRegistrationOptions.cs b/src/Features/LanguageServer/Protocol/Protocol/DiagnosticRegistrationOptions.cs new file mode 100644 index 0000000000000..549fe02ed56cf --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/DiagnosticRegistrationOptions.cs @@ -0,0 +1,39 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol; + +using System.Runtime.Serialization; +using Newtonsoft.Json; + +/// +/// Diagnostic registration options. +/// +/// See the Language Server Protocol specification for additional information. +/// +[DataContract] +internal class DiagnosticRegistrationOptions : DiagnosticOptions, IStaticRegistrationOptions, ITextDocumentRegistrationOptions +{ + /// + /// Gets or sets the document filters for this registration option. + /// + [DataMember(Name = "documentSelector")] + [JsonProperty(NullValueHandling = NullValueHandling.Include)] + public DocumentFilter[]? DocumentSelector + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether work done progress is supported. + /// + [DataMember(Name = "id")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? Id + { + get; + set; + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/DiagnosticRelatedInformation.cs b/src/Features/LanguageServer/Protocol/Protocol/DiagnosticRelatedInformation.cs new file mode 100644 index 0000000000000..e62e8058f8cf7 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/DiagnosticRelatedInformation.cs @@ -0,0 +1,31 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// Class which represents a related message and source code location for a diagnostic. + /// This should be used to point to code locations that cause or are related to + /// a diagnostics, e.g when duplicating a symbol in a scope. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class DiagnosticRelatedInformation + { + /// + /// Gets or sets the location for the related information. + /// + [DataMember(Name = "location")] + public Location Location { get; set; } + + /// + /// Gets or sets the message for the related information. + /// + [DataMember(Name = "message")] + public string Message { get; set; } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/DiagnosticServerCancellationData.cs b/src/Features/LanguageServer/Protocol/Protocol/DiagnosticServerCancellationData.cs new file mode 100644 index 0000000000000..9840373f3f4c5 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/DiagnosticServerCancellationData.cs @@ -0,0 +1,26 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol; + +using System.Runtime.Serialization; + +/// +/// Class representing the cancellation data returned from a diagnostic request. +/// +/// See the Language Server Protocol specification for additional information. +/// +[DataContract] +internal class DiagnosticServerCancellationData +{ + /// + /// Gets or sets a value indicating whether the client should re-trigger the request. + /// + [DataMember(Name = "retriggerRequest")] + public bool RetriggerRequest + { + get; + set; + } +} \ No newline at end of file diff --git a/src/Features/LanguageServer/Protocol/Protocol/DiagnosticSetting.cs b/src/Features/LanguageServer/Protocol/Protocol/DiagnosticSetting.cs new file mode 100644 index 0000000000000..75c0827e25bf6 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/DiagnosticSetting.cs @@ -0,0 +1,24 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol; + +using System.Runtime.Serialization; +using Newtonsoft.Json; + +/// +/// Client settings for pull diagnostics. +/// +/// See the Language Server Protocol specification for additional information. +/// +[DataContract] +internal class DiagnosticSetting : DynamicRegistrationSetting +{ + /// + /// Gets or sets a value indicating whether the client supports related documents for document diagnostic pulls. + /// + [DataMember(Name = "relatedDocumentSupport")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool RelatedDocumentSupport { get; set; } +} \ No newline at end of file diff --git a/src/Features/LanguageServer/Protocol/Protocol/DiagnosticSeverity.cs b/src/Features/LanguageServer/Protocol/Protocol/DiagnosticSeverity.cs new file mode 100644 index 0000000000000..ede441ea9074c --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/DiagnosticSeverity.cs @@ -0,0 +1,34 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + /// + /// Diagnostic severity enum. + /// + /// See the Language Server Protocol specification for additional information. + /// + internal enum DiagnosticSeverity + { + /// + /// Error. + /// + Error = 1, + + /// + /// Warning. + /// + Warning = 2, + + /// + /// Information. + /// + Information = 3, + + /// + /// Hint. + /// + Hint = 4, + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/DiagnosticTag.cs b/src/Features/LanguageServer/Protocol/Protocol/DiagnosticTag.cs new file mode 100644 index 0000000000000..1b2662066ffea --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/DiagnosticTag.cs @@ -0,0 +1,27 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + /// + /// Diagnostic tag enum. + /// Additional metadata about the type of a diagnostic + /// + /// See the Language Server Protocol specification for additional information. + /// + internal enum DiagnosticTag + { + /// + /// Unused or unnecessary code. + /// Diagnostics with this tag are rendered faded out. + /// + Unnecessary = 1, + + /// + /// Deprecated or obsolete code. + /// Clients are allowed to rendered diagnostics with this tag strike through. + /// + Deprecated = 2, + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/DiagnosticWorkspaceSetting.cs b/src/Features/LanguageServer/Protocol/Protocol/DiagnosticWorkspaceSetting.cs new file mode 100644 index 0000000000000..1c1640598d134 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/DiagnosticWorkspaceSetting.cs @@ -0,0 +1,24 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol; + +using System.Runtime.Serialization; +using Newtonsoft.Json; + +/// +/// Class representing the workspace diagnostic client capabilities. +/// +/// See the Language Server Protocol specification for additional information. +/// +[DataContract] +internal class DiagnosticWorkspaceSetting +{ + /// + /// Gets or sets a value indicating whether the client supports a refresh request sent from the server to the client. + /// + [DataMember(Name = "refreshSupport")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool RefreshSupport { get; set; } +} \ No newline at end of file diff --git a/src/Features/LanguageServer/Protocol/Protocol/DidChangeConfigurationParams.cs b/src/Features/LanguageServer/Protocol/Protocol/DidChangeConfigurationParams.cs new file mode 100644 index 0000000000000..a9816d3926583 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/DidChangeConfigurationParams.cs @@ -0,0 +1,27 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// Class which represents the parameter sent with workspace/didChangeConfiguration requests. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class DidChangeConfigurationParams + { + /// + /// Gets or sets the settings that are applicable to the language server. + /// + [DataMember(Name = "settings")] + public object Settings + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/DidChangeTextDocumentParams.cs b/src/Features/LanguageServer/Protocol/Protocol/DidChangeTextDocumentParams.cs new file mode 100644 index 0000000000000..0a4f9c3934a02 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/DidChangeTextDocumentParams.cs @@ -0,0 +1,42 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// Class which represents the parameter that is sent with textDocument/didChange message. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class DidChangeTextDocumentParams : ITextDocumentParams + { + /// + /// Gets or sets the document that changed. + /// + [DataMember(Name = "textDocument")] + public VersionedTextDocumentIdentifier TextDocument + { + get; + set; + } + + /// + /// Gets or sets the content changes. + /// + [DataMember(Name = "contentChanges")] + public TextDocumentContentChangeEvent[] ContentChanges + { + get; + set; + } + + TextDocumentIdentifier ITextDocumentParams.TextDocument + { + get => this.TextDocument; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/DidChangeWatchedFilesParams.cs b/src/Features/LanguageServer/Protocol/Protocol/DidChangeWatchedFilesParams.cs new file mode 100644 index 0000000000000..75e21d2e8de99 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/DidChangeWatchedFilesParams.cs @@ -0,0 +1,28 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Diagnostics.CodeAnalysis; + using System.Runtime.Serialization; + + /// + /// Class which represents the parameter that is sent with workspace/didChangeWatchedFiles message. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class DidChangeWatchedFilesParams + { + /// + /// Gets or sets of the collection of file change events. + /// + [DataMember(Name = "changes")] + public FileEvent[] Changes + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/DidCloseTextDocumentParams.cs b/src/Features/LanguageServer/Protocol/Protocol/DidCloseTextDocumentParams.cs new file mode 100644 index 0000000000000..f2e1dccc784a4 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/DidCloseTextDocumentParams.cs @@ -0,0 +1,27 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// Class which represents the parameter that is sent with textDocument/didClose message. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class DidCloseTextDocumentParams : ITextDocumentParams + { + /// + /// Gets or sets the text document identifier. + /// + [DataMember(Name = "textDocument")] + public TextDocumentIdentifier TextDocument + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/DidOpenTextDocumentParams.cs b/src/Features/LanguageServer/Protocol/Protocol/DidOpenTextDocumentParams.cs new file mode 100644 index 0000000000000..2d32742a3c94f --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/DidOpenTextDocumentParams.cs @@ -0,0 +1,27 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// Class which represents the parameter that is sent with textDocument/didOpen message. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class DidOpenTextDocumentParams + { + /// + /// Gets or sets the which represents the text document that was opened. + /// + [DataMember(Name = "textDocument")] + public TextDocumentItem TextDocument + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/DidSaveTextDocumentParams.cs b/src/Features/LanguageServer/Protocol/Protocol/DidSaveTextDocumentParams.cs new file mode 100644 index 0000000000000..aab858ce354e8 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/DidSaveTextDocumentParams.cs @@ -0,0 +1,39 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class which represents the parameter that is sent with a textDocument/didSave message. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class DidSaveTextDocumentParams : ITextDocumentParams + { + /// + /// Gets or sets the which represents the text document that was saved. + /// + [DataMember(Name = "textDocument")] + public TextDocumentIdentifier TextDocument + { + get; + set; + } + + /// + /// Gets or sets the which represents the content of the text document when it was saved. + /// + [DataMember(Name = "text")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? Text + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/DocumentColorOptions.cs b/src/Features/LanguageServer/Protocol/Protocol/DocumentColorOptions.cs new file mode 100644 index 0000000000000..c3c1097998f71 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/DocumentColorOptions.cs @@ -0,0 +1,29 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class which represents workspace symbols capabilities. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class DocumentColorOptions : IWorkDoneProgressOptions + { + /// + /// Gets or sets a value indicating whether work done progress is supported. + /// + [DataMember(Name = "workDoneProgress")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool WorkDoneProgress + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/DocumentColorParams.cs b/src/Features/LanguageServer/Protocol/Protocol/DocumentColorParams.cs new file mode 100644 index 0000000000000..7f364f077b7cb --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/DocumentColorParams.cs @@ -0,0 +1,27 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// Class representing the parameters sent for a textDocument/documentColor request. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class DocumentColorParams : ITextDocumentParams + { + /// + /// Gets or sets the to provide links for. + /// + [DataMember(Name = "textDocument")] + public TextDocumentIdentifier TextDocument + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/DocumentDiagnosticParams.cs b/src/Features/LanguageServer/Protocol/Protocol/DocumentDiagnosticParams.cs new file mode 100644 index 0000000000000..55cd0c4f38eb7 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/DocumentDiagnosticParams.cs @@ -0,0 +1,65 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol; + +using System; +using System.Runtime.Serialization; +using Newtonsoft.Json; + +/// +/// Class representing the document diagnostic request parameters +/// +/// See the Language Server Protocol specification for additional information. +/// +[DataContract] +internal class DocumentDiagnosticParams : ITextDocumentParams, IPartialResultParams> +{ + /// + /// Gets or sets the value of the Progress instance. + /// + /// + /// Note that the first literal send needs to be either the or + /// followed by n literals. + /// + [DataMember(Name = Methods.PartialResultTokenName, IsRequired = false)] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public IProgress>? PartialResultToken + { + get; + set; + } + + /// + /// Gets or sets the to provide diagnostics for. + /// + [DataMember(Name = "textDocument")] + public TextDocumentIdentifier TextDocument + { + get; + set; + } + + /// + /// Gets or sets the identifier for which the client is requesting diagnostics for. + /// + [DataMember(Name = "identifier")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? Identifier + { + get; + set; + } + + /// + /// Gets or sets the result id of a previous diagnostics response if provided. + /// + [DataMember(Name = "previousResultId")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? PreviousResultId + { + get; + set; + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/DocumentDiagnosticReportKind.cs b/src/Features/LanguageServer/Protocol/Protocol/DocumentDiagnosticReportKind.cs new file mode 100644 index 0000000000000..30efcc8483aa7 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/DocumentDiagnosticReportKind.cs @@ -0,0 +1,23 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol; + +/// +/// Value representing the kind of the document diagnostic report. +/// +/// See the Language Server Protocol specification for additional information. +/// +internal static class DocumentDiagnosticReportKind +{ + /// + /// Kind representing a diagnostic report with a full set of problems. + /// + public const string Full = "full"; + + /// + /// Kind representing a diagnostic report indicating that the last returned report is still accurate. + /// + public const string Unchanged = "unchanged"; +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/DocumentDiagnosticReportPartialResult.cs b/src/Features/LanguageServer/Protocol/Protocol/DocumentDiagnosticReportPartialResult.cs new file mode 100644 index 0000000000000..936ad48f1dbde --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/DocumentDiagnosticReportPartialResult.cs @@ -0,0 +1,28 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol; + +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; + +/// +/// Class representing a partial document diagnostic report for a set of related documents. +/// +/// See the Language Server Protocol specification for additional information. +/// +[DataContract] +internal class DocumentDiagnosticReportPartialResult +{ + /// + /// Gets or sets the map of related document diagnostic reports. + /// + [DataMember(Name = "relatedDocuments")] + public Dictionary> RelatedDocuments + { + get; + set; + } +} \ No newline at end of file diff --git a/src/Features/LanguageServer/Protocol/Protocol/DocumentFilter.cs b/src/Features/LanguageServer/Protocol/Protocol/DocumentFilter.cs new file mode 100644 index 0000000000000..d06ad65ed2e9a --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/DocumentFilter.cs @@ -0,0 +1,51 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing a filter over certain types of documents + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class DocumentFilter + { + /// + /// Gets or sets a language id for the filter (e.g. 'typescript'). + /// + [DataMember(Name = "language")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? Language + { + get; + set; + } + + /// + /// Gets or sets a Uri scheme (e.g. 'file' or 'untitled'). + /// + [DataMember(Name = "scheme")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? Scheme + { + get; + set; + } + + /// + /// Gets or sets a glob pattern (e.g. '*.cs'). + /// + [DataMember(Name = "pattern")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? Pattern + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/DocumentFormattingOptions.cs b/src/Features/LanguageServer/Protocol/Protocol/DocumentFormattingOptions.cs new file mode 100644 index 0000000000000..6428db78e15a3 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/DocumentFormattingOptions.cs @@ -0,0 +1,29 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing the document formatting options for server capabilities. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class DocumentFormattingOptions : IWorkDoneProgressOptions + { + /// + /// Gets or sets a value indicating whether work done progress is supported. + /// + [DataMember(Name = "workDoneProgress")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool WorkDoneProgress + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/DocumentFormattingParams.cs b/src/Features/LanguageServer/Protocol/Protocol/DocumentFormattingParams.cs new file mode 100644 index 0000000000000..766dc19e1843e --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/DocumentFormattingParams.cs @@ -0,0 +1,37 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// Class which represents the parameter that is sent with textDocument/formatting message. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class DocumentFormattingParams : ITextDocumentParams + { + /// + /// Gets or sets the identifier for the text document to be formatted. + /// + [DataMember(Name = "textDocument")] + public TextDocumentIdentifier TextDocument + { + get; + set; + } + + /// + /// Gets or sets the formatting options. + /// + [DataMember(Name = "options")] + public FormattingOptions Options + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/DocumentHighlight.cs b/src/Features/LanguageServer/Protocol/Protocol/DocumentHighlight.cs new file mode 100644 index 0000000000000..692bc31ab9b6f --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/DocumentHighlight.cs @@ -0,0 +1,44 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.ComponentModel; + using System.Diagnostics.CodeAnalysis; + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing the response from a textDocument/documentHighlight request. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class DocumentHighlight + { + /// + /// Gets or sets the range that the highlight applies to. + /// + [DataMember(Name = "range")] + public Range Range + { + get; + set; + } + + /// + /// Gets or sets the kind of highlight. + /// + [DataMember(Name = "kind")] + [SuppressMessage("Microsoft.StyleCop.CSharp.LayoutRules", "SA1513:ClosingCurlyBracketMustBeFollowedByBlankLine", Justification = "There are no issues with this code")] + [SuppressMessage("Microsoft.StyleCop.CSharp.LayoutRules", "SA1500:BracesForMultiLineStatementsShouldNotShareLine", Justification = "There are no issues with this code")] + [DefaultValue(DocumentHighlightKind.Text)] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public DocumentHighlightKind Kind + { + get; + set; + } = DocumentHighlightKind.Text; + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/DocumentHighlightKind.cs b/src/Features/LanguageServer/Protocol/Protocol/DocumentHighlightKind.cs new file mode 100644 index 0000000000000..60375fb94cb92 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/DocumentHighlightKind.cs @@ -0,0 +1,32 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// Enum representing the different types of document highlight. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal enum DocumentHighlightKind + { + /// + /// A textual occurance. + /// + Text = 1, + + /// + /// Read access of a symbol. + /// + Read = 2, + + /// + /// Write access of a symbol. + /// + Write = 3, + } +} \ No newline at end of file diff --git a/src/Features/LanguageServer/Protocol/Protocol/DocumentHighlightOptions.cs b/src/Features/LanguageServer/Protocol/Protocol/DocumentHighlightOptions.cs new file mode 100644 index 0000000000000..a964e6d79e7fe --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/DocumentHighlightOptions.cs @@ -0,0 +1,29 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class which represents workspace symbols capabilities. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class DocumentHighlightOptions : IWorkDoneProgressOptions + { + /// + /// Gets or sets a value indicating whether work done progress is supported. + /// + [DataMember(Name = "workDoneProgress")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool WorkDoneProgress + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/DocumentHighlightParams.cs b/src/Features/LanguageServer/Protocol/Protocol/DocumentHighlightParams.cs new file mode 100644 index 0000000000000..65107dad7c797 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/DocumentHighlightParams.cs @@ -0,0 +1,31 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System; + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing the parameters sent for a textDocument/documentHighlight request. + /// + /// See the Language Server Protocol specification for additional information. + /// + internal class DocumentHighlightParams + : TextDocumentPositionParams, + IPartialResultParams + { + /// + /// Gets or sets the value of the PartialResultToken instance. + /// + [DataMember(Name = "partialResultToken")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public IProgress? PartialResultToken + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/DocumentLink.cs b/src/Features/LanguageServer/Protocol/Protocol/DocumentLink.cs new file mode 100644 index 0000000000000..91e3d65073174 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/DocumentLink.cs @@ -0,0 +1,41 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System; + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing the response of a textDocument/documentLink request. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class DocumentLink + { + /// + /// Gets or sets the range the link applies to. + /// + [DataMember(Name = "range")] + public Range Range + { + get; + set; + } + + /// + /// Gets or sets the uri that the link points to. + /// + [DataMember(Name = "target")] + [JsonConverter(typeof(DocumentUriConverter))] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public Uri? Target + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/DocumentLinkOptions.cs b/src/Features/LanguageServer/Protocol/Protocol/DocumentLinkOptions.cs new file mode 100644 index 0000000000000..f2334f4ffe47a --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/DocumentLinkOptions.cs @@ -0,0 +1,40 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing the document link options for server capabilities. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class DocumentLinkOptions : IWorkDoneProgressOptions + { + /// + /// Gets or sets a value indicating whether or not the server supports resolve providers. + /// + [DataMember(Name = "resolveProvider")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool ResolveProvider + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether work done progress is supported. + /// + [DataMember(Name = "workDoneProgress")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool WorkDoneProgress + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/DocumentLinkParams.cs b/src/Features/LanguageServer/Protocol/Protocol/DocumentLinkParams.cs new file mode 100644 index 0000000000000..58aaf921ffbc4 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/DocumentLinkParams.cs @@ -0,0 +1,27 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// Class representing the parameters sent for a textDocument/documentLink request. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class DocumentLinkParams : ITextDocumentParams + { + /// + /// Gets or sets the to provide links for. + /// + [DataMember(Name = "textDocument")] + public TextDocumentIdentifier TextDocument + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/DocumentOnTypeFormattingOptions.cs b/src/Features/LanguageServer/Protocol/Protocol/DocumentOnTypeFormattingOptions.cs new file mode 100644 index 0000000000000..c358c3dc1b7be --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/DocumentOnTypeFormattingOptions.cs @@ -0,0 +1,39 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing the options for on type formatting. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class DocumentOnTypeFormattingOptions + { + /// + /// Gets or sets the first trigger character. + /// + [DataMember(Name = "firstTriggerCharacter")] + public string FirstTriggerCharacter + { + get; + set; + } + + /// + /// Gets or sets additional trigger characters. + /// + [DataMember(Name = "moreTriggerCharacter")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string[]? MoreTriggerCharacter + { + get; + set; + } + } +} \ No newline at end of file diff --git a/src/Features/LanguageServer/Protocol/Protocol/DocumentOnTypeFormattingParams.cs b/src/Features/LanguageServer/Protocol/Protocol/DocumentOnTypeFormattingParams.cs new file mode 100644 index 0000000000000..eda0db4a326e2 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/DocumentOnTypeFormattingParams.cs @@ -0,0 +1,37 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// Class representing the parameters sent for a textDocument/onTypeFormatting request. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class DocumentOnTypeFormattingParams : TextDocumentPositionParams + { + /// + /// Gets or sets the character that was typed. + /// + [DataMember(Name = "ch")] + public string Character + { + get; + set; + } + + /// + /// Gets or sets the for the request. + /// + [DataMember(Name = "options")] + public FormattingOptions Options + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/DocumentRangeFormattingOptions.cs b/src/Features/LanguageServer/Protocol/Protocol/DocumentRangeFormattingOptions.cs new file mode 100644 index 0000000000000..29f53cf25852f --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/DocumentRangeFormattingOptions.cs @@ -0,0 +1,29 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing the document range formatting options for server capabilities. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class DocumentRangeFormattingOptions : IWorkDoneProgressOptions + { + /// + /// Gets or sets a value indicating whether work done progress is supported. + /// + [DataMember(Name = "workDoneProgress")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool WorkDoneProgress + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/DocumentRangeFormattingParams.cs b/src/Features/LanguageServer/Protocol/Protocol/DocumentRangeFormattingParams.cs new file mode 100644 index 0000000000000..103881f93ef17 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/DocumentRangeFormattingParams.cs @@ -0,0 +1,47 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// Class which represents the parameter that is sent with textDocument/rangeFormatting message. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class DocumentRangeFormattingParams : ITextDocumentParams + { + /// + /// Gets or sets the identifier for the text document to be formatted. + /// + [DataMember(Name = "textDocument")] + public TextDocumentIdentifier TextDocument + { + get; + set; + } + + /// + /// Gets or sets the selection range to be formatted. + /// + [DataMember(Name = "range")] + public Range Range + { + get; + set; + } + + /// + /// Gets or sets the formatting options. + /// + [DataMember(Name = "options")] + public FormattingOptions Options + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/DocumentSymbol.cs b/src/Features/LanguageServer/Protocol/Protocol/DocumentSymbol.cs new file mode 100644 index 0000000000000..bb1f719958c7b --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/DocumentSymbol.cs @@ -0,0 +1,96 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Represents programming constructs like variables, classes, interfaces etc. that appear in a document. Document symbols can be + /// hierarchical and they have two ranges: one that encloses its definition and one that points to its most interesting range, + /// e.g. the range of an identifier. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class DocumentSymbol + { + /// + /// Gets or sets the name of this symbol. + /// + [DataMember(IsRequired = true, Name = "name")] + public string Name + { + get; + set; + } + + /// + /// Gets or sets more detail for this symbol, e.g the signature of a function. + /// + [DataMember(Name = "detail")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? Detail + { + get; + set; + } + + /// + /// Gets or sets the of this symbol. + /// + [DataMember(Name = "kind")] + public SymbolKind Kind + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether this symbol is deprecated. + /// + [DataMember(Name = "deprecated")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool Deprecated + { + get; + set; + } + + /// + /// Gets or sets the range enclosing this symbol not including leading/trailing whitespace but everything else + /// like comments.This information is typically used to determine if the clients cursor is + /// inside the symbol to reveal in the symbol in the UI. + /// + [DataMember(IsRequired = true, Name = "range")] + public Range Range + { + get; + set; + } + + /// + /// Gets or sets the range that should be selected and revealed when this symbol is being picked, e.g the name of a function. + /// Must be contained by the `range`. + /// + [DataMember(IsRequired = true, Name = "selectionRange")] + public Range SelectionRange + { + get; + set; + } + + /// + /// Gets or sets the children of this symbol, e.g. properties of a class. + /// + [DataMember(Name = "children")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public DocumentSymbol[]? Children + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/DocumentSymbolOptions.cs b/src/Features/LanguageServer/Protocol/Protocol/DocumentSymbolOptions.cs new file mode 100644 index 0000000000000..d12b5f9552b1e --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/DocumentSymbolOptions.cs @@ -0,0 +1,29 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class which represents workspace symbols capabilities. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class DocumentSymbolOptions : IWorkDoneProgressOptions + { + /// + /// Gets or sets a value indicating whether work done progress is supported. + /// + [DataMember(Name = "workDoneProgress")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool WorkDoneProgress + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/DocumentSymbolParams.cs b/src/Features/LanguageServer/Protocol/Protocol/DocumentSymbolParams.cs new file mode 100644 index 0000000000000..3ba1eaa41230b --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/DocumentSymbolParams.cs @@ -0,0 +1,27 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// Class which represents the parameter sent with textDocument/documentSymbol requests. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class DocumentSymbolParams : ITextDocumentParams + { + /// + /// Gets or sets the text document. + /// + [DataMember(Name = "textDocument")] + public TextDocumentIdentifier TextDocument + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/DocumentSymbolSetting.cs b/src/Features/LanguageServer/Protocol/Protocol/DocumentSymbolSetting.cs new file mode 100644 index 0000000000000..f1df03c9304ef --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/DocumentSymbolSetting.cs @@ -0,0 +1,40 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing the initialization setting for document symbols. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class DocumentSymbolSetting : DynamicRegistrationSetting + { + /// + /// Gets or sets the capabilities. + /// + [DataMember(Name = "symbolKind")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public SymbolKindSetting? SymbolKind + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether the document has hierarchical symbol support. + /// + [DataMember(Name = "hierarchicalDocumentSymbolSupport")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool HierarchicalDocumentSymbolSupport + { + get; + set; + } + } +} \ No newline at end of file diff --git a/src/Features/LanguageServer/Protocol/Protocol/DynamicRegistrationSetting.cs b/src/Features/LanguageServer/Protocol/Protocol/DynamicRegistrationSetting.cs new file mode 100644 index 0000000000000..095b552f61176 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/DynamicRegistrationSetting.cs @@ -0,0 +1,43 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class which represents a setting that can be dynamically registered. + /// + [DataContract] + internal class DynamicRegistrationSetting + { + /// + /// Initializes a new instance of the class. + /// + public DynamicRegistrationSetting() + { + } + + /// + /// Initializes a new instance of the class. + /// + /// Value indicating whether the setting can be dynamically registered. + public DynamicRegistrationSetting(bool value) + { + this.DynamicRegistration = value; + } + + /// + /// Gets or sets a value indicating whether setting can be dynamically registered. + /// + [DataMember(Name = "dynamicRegistration")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool DynamicRegistration + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/ExecuteCommandOptions.cs b/src/Features/LanguageServer/Protocol/Protocol/ExecuteCommandOptions.cs new file mode 100644 index 0000000000000..ef7afc7431db0 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/ExecuteCommandOptions.cs @@ -0,0 +1,39 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing the options for execute command support. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class ExecuteCommandOptions : IWorkDoneProgressOptions + { + /// + /// Gets or sets the commands that are to be executed on the server. + /// + [DataMember(Name = "commands")] + public string[] Commands + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether work done progress is supported. + /// + [DataMember(Name = "workDoneProgress")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool WorkDoneProgress + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/ExecuteCommandParams.cs b/src/Features/LanguageServer/Protocol/Protocol/ExecuteCommandParams.cs new file mode 100644 index 0000000000000..d9c934063e7ba --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/ExecuteCommandParams.cs @@ -0,0 +1,39 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing the parameters sent from client to server for the workspace/executeCommand request. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class ExecuteCommandParams + { + /// + /// Gets or sets the command identifier associated with the command handler. + /// + [DataMember(Name = "command")] + public string Command + { + get; + set; + } + + /// + /// Gets or sets the arguments that the command should be invoked with. + /// + [DataMember(Name = "arguments")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public object[]? Arguments + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Extensions/Converters/VSExtensionConverter.cs b/src/Features/LanguageServer/Protocol/Protocol/Extensions/Converters/VSExtensionConverter.cs new file mode 100644 index 0000000000000..70f3ed31e8acb --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Extensions/Converters/VSExtensionConverter.cs @@ -0,0 +1,41 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System; + using Newtonsoft.Json; + + /// + /// Converter used to serialize and deserialize classes extending types defined in the + /// Microsoft.VisualStudio.LanguageServer.Protocol package. + /// + /// Base class that is specified in the + /// Microsoft.VisualStudio.LanguageServer.Protocol package. + /// Extension class that extends TBase. + internal class VSExtensionConverter : JsonConverter + where TExtension : TBase + { + /// + public override bool CanWrite => false; + + /// + public override bool CanConvert(Type objectType) + { + return objectType == typeof(TBase); + } + + /// + public override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer) + { + return serializer.Deserialize(reader); + } + + /// + public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer) + { + throw new NotImplementedException(); + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Extensions/Converters/VSExtensionUtilities.cs b/src/Features/LanguageServer/Protocol/Protocol/Extensions/Converters/VSExtensionUtilities.cs new file mode 100644 index 0000000000000..51ce11b3bf2bc --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Extensions/Converters/VSExtensionUtilities.cs @@ -0,0 +1,57 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using Newtonsoft.Json; + + /// + /// Utility functions to simplify working with the Visual Studio extensions to the Language Server Protocol. + /// + internal static class VSExtensionUtilities + { + /// + /// Adds to the allowing to + /// deserialize the JSON stream into objects which include Visual Studio specific extensions. + /// + /// For example, it allows to correctly deserialize the entries of a + /// 'codeAction/resolve' request into objects even if + /// is defined as an array of . + /// + /// + /// If is used in parallel to the execution of this method, + /// its access needs to be synchronized with this method call, to guarantee that the + /// collection is not modified when is in use. + /// + /// Instance of to be configured. + public static void AddVSExtensionConverters(this JsonSerializer serializer) + { + // Reading the number of converters before we start adding new ones + var existingConvertersCount = serializer.Converters.Count; + + TryAddConverter(); + TryAddConverter(); + TryAddConverter(); + TryAddConverter(); + TryAddConverter(); + + void TryAddConverter() + where TExtension : TBase + { + for (var i = 0; i < existingConvertersCount; i++) + { + var existingConverterType = serializer.Converters[i].GetType(); + if (existingConverterType.IsGenericType && + existingConverterType.GetGenericTypeDefinition() == typeof(VSExtensionConverter<,>) && + existingConverterType.GenericTypeArguments[0] == typeof(TBase)) + { + return; + } + } + + serializer.Converters.Add(new VSExtensionConverter()); + } + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Extensions/VSDiagnostic.cs b/src/Features/LanguageServer/Protocol/Protocol/Extensions/VSDiagnostic.cs new file mode 100644 index 0000000000000..4ac6e47c0a682 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Extensions/VSDiagnostic.cs @@ -0,0 +1,68 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// extends providing additional properties used by Visual Studio. + /// + [DataContract] + internal class VSDiagnostic : Diagnostic + { + /// + /// Gets or sets the project and context (e.g. Win32, MacOS, etc.) in which the diagnostic was generated. + /// + [DataMember(Name = "_vs_projects")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public VSDiagnosticProjectInformation[]? Projects { get; set; } + + /// + /// Gets or sets an expanded description of the diagnostic. + /// + [DataMember(Name = "_vs_expandedMessage")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? ExpandedMessage { get; set; } + + /// + /// Gets or sets a message shown when the user hovers over an error. If , then + /// is used (use to prevent a tool tip from being shown). + /// + [DataMember(Name = "_vs_toolTip")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? ToolTip { get; set; } + + /// + /// Gets or sets a non-human-readable identier allowing consolidation of multiple equivalent diagnostics + /// (e.g. the same syntax error from builds targeting different platforms). + /// + [DataMember(Name = "_vs_identifier")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? Identifier { get; set; } + + /// + /// Gets or sets a string describing the diagnostic types (e.g. Security, Performance, Style, etc.). + /// + [DataMember(Name = "_vs_diagnosticType")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? DiagnosticType { get; set; } + + /// + /// Gets or sets a rank associated with this diagnostic, used for the default sort. + /// will be used if no rank is specified. + /// + [DataMember(Name = "_vs_diagnosticRank")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public VSDiagnosticRank? DiagnosticRank { get; set; } + + /// + /// Gets or sets an ID used to associate this diagnostic with a corresponding line in the output window. + /// + [DataMember(Name = "_vs_outputId")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public int? OutputId { get; set; } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Extensions/VSDiagnosticProjectInformation.cs b/src/Features/LanguageServer/Protocol/Protocol/Extensions/VSDiagnosticProjectInformation.cs new file mode 100644 index 0000000000000..c2a84f512d6eb --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Extensions/VSDiagnosticProjectInformation.cs @@ -0,0 +1,38 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// represents the project and context in which the is generated. + /// + [DataContract] + internal class VSDiagnosticProjectInformation + { + /// + /// Gets or sets a human-readable identifier for the project in which the diagnostic was generated. + /// + [DataMember(Name = "_vs_projectName")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? ProjectName { get; set; } + + /// + /// Gets or sets a human-readable identifier for the build context (e.g. Win32 or MacOS) + /// in which the diagnostic was generated. + /// + [DataMember(Name = "_vs_context")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? Context { get; set; } + + /// + /// Gets or sets the unique identifier for the project in which the diagnostic was generated. + /// + [DataMember(Name = "_vs_projectIdentifier")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? ProjectIdentifier { get; set; } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Extensions/VSDiagnosticRank.cs b/src/Features/LanguageServer/Protocol/Protocol/Extensions/VSDiagnosticRank.cs new file mode 100644 index 0000000000000..5aab9983aa9ae --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Extensions/VSDiagnosticRank.cs @@ -0,0 +1,37 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + /// + /// represents the rank of a object. + /// + internal enum VSDiagnosticRank + { + /// + /// Highest priority. + /// + Highest = 100, + + /// + /// High priority. + /// + High = 200, + + /// + /// Default priority. + /// + Default = 300, + + /// + /// Low priority. + /// + Low = 400, + + /// + /// Lowest priority. + /// + Lowest = 500, + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Extensions/VSDiagnosticTags.cs b/src/Features/LanguageServer/Protocol/Protocol/Extensions/VSDiagnosticTags.cs new file mode 100644 index 0000000000000..a5a54652689ff --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Extensions/VSDiagnosticTags.cs @@ -0,0 +1,63 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + /// + /// Additional values that are specific to Visual Studio. + /// + internal static class VSDiagnosticTags + { + /// + /// A entry generated by the build. + /// + public const DiagnosticTag BuildError = (DiagnosticTag)(-1); + + /// + /// A entry generated by Intellisense. + /// + public const DiagnosticTag IntellisenseError = (DiagnosticTag)(-2); + + /// + /// A entry that could be generated from both builds + /// and Intellisense. + /// + /// entries tagged with will be hidden + /// in the error list if the error list is displaying build and intellisense + /// errors. + /// + public const DiagnosticTag PotentialDuplicate = (DiagnosticTag)(-3); + + /// + /// A entry is never displayed in the error list. + /// + public const DiagnosticTag HiddenInErrorList = (DiagnosticTag)(-4); + + /// + /// The entry is always displayed in the error list. + /// + public const DiagnosticTag VisibleInErrorList = (DiagnosticTag)(-5); + + /// + /// The entry is never displayed in the editor. + /// + public const DiagnosticTag HiddenInEditor = (DiagnosticTag)(-6); + + /// + /// No tooltip is shown for the entry in the editor. + /// + public const DiagnosticTag SuppressEditorToolTip = (DiagnosticTag)(-7); + + /// + /// The entry is represented in the Editor as an Edit + /// and Continue error. + /// + public const DiagnosticTag EditAndContinueError = (DiagnosticTag)(-8); + + /// + /// A entry is represented in the Editor as a Task List item in the TODO list. + /// + public const DiagnosticTag TaskItem = (DiagnosticTag)(-9); + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Extensions/VSGetProjectContextsParams.cs b/src/Features/LanguageServer/Protocol/Protocol/Extensions/VSGetProjectContextsParams.cs new file mode 100644 index 0000000000000..f02ebbc2bf112 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Extensions/VSGetProjectContextsParams.cs @@ -0,0 +1,26 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// represents the parameter that is sent + /// with the 'textDocument/_vs_getProjectContexts' request. + /// + [DataContract] + internal class VSGetProjectContextsParams + { + /// + /// Gets or sets the document for which project contexts are queried. + /// + [DataMember(Name = "_vs_textDocument")] + public TextDocumentItem TextDocument + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Extensions/VSImageId.cs b/src/Features/LanguageServer/Protocol/Protocol/Extensions/VSImageId.cs new file mode 100644 index 0000000000000..ed16c06838842 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Extensions/VSImageId.cs @@ -0,0 +1,62 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System; + using System.Runtime.Serialization; + + /// + /// represents the unique identifier for a Visual Studio image asset. + /// The identified is composed by a and an integer. + /// A list of valid image ids can be retrieved from the KnownMonikers class + /// from the Visual Studio SDK. + /// + [DataContract] + internal class VSImageId : IEquatable + { + /// + /// Gets or sets the component of the unique identifier. + /// + [DataMember(Name = "_vs_guid")] + public Guid Guid + { + get; + set; + } + + /// + /// Gets or sets the integer component of the unique identifier. + /// + [DataMember(Name = "_vs_id")] + public int Id + { + get; + set; + } + + /// + public override bool Equals(object obj) + { + return this.Equals(obj as VSImageId); + } + + /// + public bool Equals(VSImageId? other) + { + return other != null && + this.Guid == other.Guid && + this.Id == other.Id; + } + + /// + public override int GetHashCode() + { + var hashCode = 184147724; + hashCode = (hashCode * -1521134295) + this.Guid.GetHashCode(); + hashCode = (hashCode * -1521134295) + this.Id.GetHashCode(); + return hashCode; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Extensions/VSLocation.cs b/src/Features/LanguageServer/Protocol/Protocol/Extensions/VSLocation.cs new file mode 100644 index 0000000000000..a34ea77a25296 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Extensions/VSLocation.cs @@ -0,0 +1,32 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// extends providing additional properties used by Visual Studio. + /// + [DataContract] + internal class VSLocation : Location + { + /// + /// Gets or sets the project name to be displayed to user. + /// + [DataMember(Name = "_vs_projectName")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? ProjectName { get; set; } + + /// + /// Gets or sets the text value for the display path. + /// In case the actual path on disk would be confusing for users, this should be a friendly display name. + /// This doesn't have to correspond to a real file path, but must be parsable by the method. + /// + [DataMember(Name = "_vs_displayPath")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? DisplayPath { get; set; } + } +} \ No newline at end of file diff --git a/src/Features/LanguageServer/Protocol/Protocol/Extensions/VSMethods.cs b/src/Features/LanguageServer/Protocol/Protocol/Extensions/VSMethods.cs new file mode 100644 index 0000000000000..e2d186472f733 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Extensions/VSMethods.cs @@ -0,0 +1,28 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + /// + /// contains the string values for all Language Server Protocol Visual Studio specific methods. + /// + internal static class VSMethods + { + /// + /// Method name for 'textDocument/_vs_getProjectContexts'. + /// The 'textDocument/_vs_getProjectContexts' request is sent from the client to the server to query + /// the list of project context associated with a document. + /// This method has a parameter of type and a return value of type + /// . + /// In order to enable the client to send the 'textDocument/_vs_getProjectContexts' requests, the server must + /// set the property. + /// + public const string GetProjectContextsName = "textDocument/_vs_getProjectContexts"; + + /// + /// Strongly typed request object for 'textDocument/_vs_getProjectContexts'. + /// + public static readonly LspRequest GetProjectContexts = new LspRequest(GetProjectContextsName); + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Extensions/VSProjectContext.cs b/src/Features/LanguageServer/Protocol/Protocol/Extensions/VSProjectContext.cs new file mode 100644 index 0000000000000..de37989753381 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Extensions/VSProjectContext.cs @@ -0,0 +1,96 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System; + using System.Runtime.Serialization; + + /// + /// represents a project context. + /// + [DataContract] + internal class VSProjectContext : IEquatable + { + /// + /// Gets or sets the label for the project context. + /// + [DataMember(Name = "_vs_label", IsRequired = true)] + public string Label + { + get; + set; + } + + /// + /// Gets or sets the unique identifier of the project context. + /// + [DataMember(Name = "_vs_id", IsRequired = true)] + public string Id + { + get; + set; + } + + /// + /// Gets or sets the context kind of the project context which is used to determine its associated icon. + /// + [DataMember(Name = "_vs_kind")] + public VSProjectKind Kind + { + get; + set; + } + + public static bool operator ==(VSProjectContext? value1, VSProjectContext? value2) + { + if (ReferenceEquals(value1, value2)) + { + return true; + } + + // Is null? + if (value2 is null) + { + return false; + } + + return value1?.Equals(value2) ?? false; + } + + public static bool operator !=(VSProjectContext? value1, VSProjectContext? value2) + { + return !(value1 == value2); + } + + /// + public virtual bool Equals(VSProjectContext other) + { + return string.Equals(this.Label, other.Label, StringComparison.Ordinal) + && string.Equals(this.Id, other.Id, StringComparison.Ordinal) + && this.Kind == other.Kind; + } + + /// + public override bool Equals(object obj) + { + if (obj is VSProjectContext other) + { + return this.Equals(other); + } + else + { + return false; + } + } + + /// + public override int GetHashCode() + { + return (this.Label == null ? 53 : this.Label.GetHashCode() * 13) + ^ (this.Id == null ? 61 : this.Id.GetHashCode() * 17) + ^ ((int)this.Kind * 19); + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Extensions/VSProjectContextList.cs b/src/Features/LanguageServer/Protocol/Protocol/Extensions/VSProjectContextList.cs new file mode 100644 index 0000000000000..4c1ee69a0bbff --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Extensions/VSProjectContextList.cs @@ -0,0 +1,36 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// represents the response to the + /// 'textDocument/_vs_getProjectContexts' request. + /// + [DataContract] + internal class VSProjectContextList + { + /// + /// Gets or sets the document contexts associated with a text document. + /// + [DataMember(Name = "_vs_projectContexts")] + public VSProjectContext[] ProjectContexts + { + get; + set; + } + + /// + /// Gets or sets the index of the default entry of the array. + /// + [DataMember(Name = "_vs_defaultIndex")] + public int DefaultIndex + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Extensions/VSProjectKind.cs b/src/Features/LanguageServer/Protocol/Protocol/Extensions/VSProjectKind.cs new file mode 100644 index 0000000000000..6a541c5bce361 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Extensions/VSProjectKind.cs @@ -0,0 +1,30 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// represents the various kinds of contexts. + /// + [DataContract] + internal enum VSProjectKind + { + /// + /// C++ project. + /// + CPlusPlus = 1, + + /// + /// C# project. + /// + CSharp = 2, + + /// + /// Visual Basic project. + /// + VisualBasic = 3, + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Extensions/VSServerCapabilities.cs b/src/Features/LanguageServer/Protocol/Protocol/Extensions/VSServerCapabilities.cs new file mode 100644 index 0000000000000..6985e61b5ba06 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Extensions/VSServerCapabilities.cs @@ -0,0 +1,29 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// extends allowing to provide + /// additional capabilities supported by Visual Studio. + /// + [DataContract] + internal class VSServerCapabilities : ServerCapabilities + { + /// + /// Gets or sets a value indicating whether the server supports the + /// 'textDocument/_vs_getProjectContexts' request. + /// + [DataMember(Name = "_vs_projectContextProvider")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool ProjectContextProvider + { + get; + set; + } + } +} \ No newline at end of file diff --git a/src/Features/LanguageServer/Protocol/Protocol/Extensions/VSSymbolInformation.cs b/src/Features/LanguageServer/Protocol/Protocol/Extensions/VSSymbolInformation.cs new file mode 100644 index 0000000000000..62b8b120be35e --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Extensions/VSSymbolInformation.cs @@ -0,0 +1,37 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// extends providing additional properties used by Visual Studio. + /// + [DataContract] + internal class VSSymbolInformation : SymbolInformation + { + /// + /// Gets or sets the icon associated with the symbol. If specified, this icon is used instead of . + /// + [DataMember(Name = "_vs_icon")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public VSImageId? Icon { get; set; } + + /// + /// Gets or sets the description of the symbol. + /// + [DataMember(Name = "_vs_description")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? Description { get; set; } + + /// + /// Gets or sets the hint text for the symbol. + /// + [DataMember(Name = "_vs_hintText")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? HintText { get; set; } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Extensions/VSTextDocumentIdentifier.cs b/src/Features/LanguageServer/Protocol/Protocol/Extensions/VSTextDocumentIdentifier.cs new file mode 100644 index 0000000000000..2cffba1c8d1d8 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Extensions/VSTextDocumentIdentifier.cs @@ -0,0 +1,88 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System; + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// extends providing additional properties used by Visual Studio. + /// + [DataContract] + internal class VSTextDocumentIdentifier : TextDocumentIdentifier, IEquatable + { + /// + /// Gets or sets the project context of the text document. + /// + [DataMember(Name = "_vs_projectContext")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public VSProjectContext? ProjectContext + { + get; + set; + } + + public static bool operator ==(VSTextDocumentIdentifier? value1, VSTextDocumentIdentifier? value2) + { + if (ReferenceEquals(value1, value2)) + { + return true; + } + + // Is null? + if (ReferenceEquals(null, value2)) + { + return false; + } + + return value1?.Equals(value2) ?? false; + } + + public static bool operator !=(VSTextDocumentIdentifier? value1, VSTextDocumentIdentifier? value2) + { + return !(value1 == value2); + } + + /// + public bool Equals(VSTextDocumentIdentifier other) + { + return this.ProjectContext == other.ProjectContext + && base.Equals(other); + } + + /// + public override bool Equals(object obj) + { + if (obj is VSTextDocumentIdentifier other) + { + return this.Equals(other); + } + else + { + return false; + } + } + + /// + public override int GetHashCode() + { + return this.ProjectContext == null ? 89 : this.ProjectContext.GetHashCode() + ^ (base.GetHashCode() * 79); + } + + /// + public override string ToString() + { + var result = base.ToString(); + if (this.ProjectContext != null) + { + result += "|" + this.ProjectContext.Label + "|" + this.ProjectContext.Id; + } + + return result; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/FileChangeType.cs b/src/Features/LanguageServer/Protocol/Protocol/FileChangeType.cs new file mode 100644 index 0000000000000..e09e40a3478b2 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/FileChangeType.cs @@ -0,0 +1,29 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + /// + /// File event type enum. + /// + /// See the Language Server Protocol specification for additional information. + /// + internal enum FileChangeType + { + /// + /// File was created. + /// + Created = 1, + + /// + /// File was changed. + /// + Changed = 2, + + /// + /// File was deleted. + /// + Deleted = 3, + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/FileEvent.cs b/src/Features/LanguageServer/Protocol/Protocol/FileEvent.cs new file mode 100644 index 0000000000000..7d437e7bd1acb --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/FileEvent.cs @@ -0,0 +1,40 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System; + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class which represents a file change event. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class FileEvent + { + /// + /// Gets or sets the URI of the file. + /// + [DataMember(Name = "uri")] + [JsonConverter(typeof(DocumentUriConverter))] + public Uri Uri + { + get; + set; + } + + /// + /// Gets or sets the file change type. + /// + [DataMember(Name = "type")] + public FileChangeType FileChangeType + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/FoldingRange.cs b/src/Features/LanguageServer/Protocol/Protocol/FoldingRange.cs new file mode 100644 index 0000000000000..a45d49f3f9d5f --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/FoldingRange.cs @@ -0,0 +1,82 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing a folding range in a document. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class FoldingRange + { + /// + /// Gets or sets the start line value. + /// + [DataMember(Name = "startLine")] + public int StartLine + { + get; + set; + } + + /// + /// Gets or sets the start character value. + /// + [DataMember(Name = "startCharacter")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public int? StartCharacter + { + get; + set; + } + + /// + /// Gets or sets the end line value. + /// + [DataMember(Name = "endLine")] + public int EndLine + { + get; + set; + } + + /// + /// Gets or sets the end character value. + /// + [DataMember(Name = "endCharacter")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public int? EndCharacter + { + get; + set; + } + + /// + /// Gets or sets the folding range kind. + /// + [DataMember(Name = "kind")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public FoldingRangeKind? Kind + { + get; + set; + } + + /// + /// Gets or sets the collapsedText. + /// + [DataMember(Name = "collapsedText")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? CollapsedText + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/FoldingRangeKind.cs b/src/Features/LanguageServer/Protocol/Protocol/FoldingRangeKind.cs new file mode 100644 index 0000000000000..05e12df4907f0 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/FoldingRangeKind.cs @@ -0,0 +1,36 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.ComponentModel; + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Value representing various code action kinds. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + [JsonConverter(typeof(StringEnumConverter))] + [TypeConverter(typeof(StringEnumConverter.TypeConverter))] + internal readonly record struct FoldingRangeKind(string Value) : IStringEnum + { + /// + /// Comment folding range. + /// + public static readonly FoldingRangeKind Comment = new("comment"); + + /// + /// Imports folding range. + /// + public static readonly FoldingRangeKind Imports = new("imports"); + + /// + /// Region folding range. + /// + public static readonly FoldingRangeKind Region = new("region"); + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/FoldingRangeOptions.cs b/src/Features/LanguageServer/Protocol/Protocol/FoldingRangeOptions.cs new file mode 100644 index 0000000000000..61b531332810d --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/FoldingRangeOptions.cs @@ -0,0 +1,29 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing the folding range provider options for initialization. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class FoldingRangeOptions : IWorkDoneProgressOptions + { + /// + /// Gets or sets a value indicating whether work done progress is supported. + /// + [DataMember(Name = "workDoneProgress")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool WorkDoneProgress + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/FoldingRangeParams.cs b/src/Features/LanguageServer/Protocol/Protocol/FoldingRangeParams.cs new file mode 100644 index 0000000000000..ac57b23d4f24c --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/FoldingRangeParams.cs @@ -0,0 +1,27 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// Class representing the folding range request parameter. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class FoldingRangeParams : ITextDocumentParams + { + /// + /// Gets or sets the text document associated with the folding range request. + /// + [DataMember(Name = "textDocument")] + public TextDocumentIdentifier TextDocument + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/FoldingRangeSetting.cs b/src/Features/LanguageServer/Protocol/Protocol/FoldingRangeSetting.cs new file mode 100644 index 0000000000000..f4c10c48e1f26 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/FoldingRangeSetting.cs @@ -0,0 +1,51 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing the folding range setting for initialization. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class FoldingRangeSetting : DynamicRegistrationSetting + { + /// + /// Gets or sets the range limit for folding ranges. + /// + [DataMember(Name = "rangeLimit")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public int? RangeLimit + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether if client only supports entire line folding only. + /// + [DataMember(Name = "lineFoldingOnly")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool LineFoldingOnly + { + get; + set; + } + + /// + /// Gets or sets a value indicating the specific options for the folding range. + /// + [DataMember(Name = "foldingRange")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public FoldingRangeSettingOptions? FoldingRange + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/FoldingRangeSettingOptions.cs b/src/Features/LanguageServer/Protocol/Protocol/FoldingRangeSettingOptions.cs new file mode 100644 index 0000000000000..f1a1fe75e4584 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/FoldingRangeSettingOptions.cs @@ -0,0 +1,29 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing the specific options for the folding range. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class FoldingRangeSettingOptions : DynamicRegistrationSetting + { + /// + /// Gets or sets a value indicating whether if client supports collapsedText on folding ranges. + /// + [DataMember(Name = "collapsedText")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool CollapsedText + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/FormattingOptions.cs b/src/Features/LanguageServer/Protocol/Protocol/FormattingOptions.cs new file mode 100644 index 0000000000000..e1787620e30f5 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/FormattingOptions.cs @@ -0,0 +1,50 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Collections.Generic; + using System.Diagnostics.CodeAnalysis; + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class which represents formatting options. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class FormattingOptions + { + /// + /// Gets or sets the number of spaces to be inserted per tab. + /// + [DataMember(Name = "tabSize")] + public int TabSize + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether tabs should be spaces. + /// + [DataMember(Name = "insertSpaces")] + public bool InsertSpaces + { + get; + set; + } + + /// + /// Gets or sets the other potential formatting options. + /// + [JsonExtensionData] + public Dictionary? OtherOptions + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/FullDocumentDiagnosticReport.cs b/src/Features/LanguageServer/Protocol/Protocol/FullDocumentDiagnosticReport.cs new file mode 100644 index 0000000000000..ab55018017cb3 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/FullDocumentDiagnosticReport.cs @@ -0,0 +1,47 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol; + +using System.Runtime.Serialization; +using Newtonsoft.Json; + +/// +/// Class representing a diagnostic report with a full set of problems. +/// +/// See the Language Server Protocol specification for additional information. +/// +[DataContract] +[Kind(DocumentDiagnosticReportKind.Full)] +internal class FullDocumentDiagnosticReport +{ + /// + /// Gets the kind of this report. + /// + [DataMember(Name = "kind")] +#pragma warning disable CA1822 // Mark members as static + public string Kind => DocumentDiagnosticReportKind.Full; +#pragma warning restore CA1822 // Mark members as static + + /// + /// Gets or sets the optional result id. + /// + [DataMember(Name = "resultId")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? ResultId + { + get; + set; + } + + /// + /// Gets or sets the diagnostics in this report. + /// + [DataMember(Name = "items")] + public Diagnostic[] Items + { + get; + set; + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Hover.cs b/src/Features/LanguageServer/Protocol/Protocol/Hover.cs new file mode 100644 index 0000000000000..339ca873bcc6d --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Hover.cs @@ -0,0 +1,42 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing the data returned by a textDocument/hover request. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class Hover + { + /// + /// Gets or sets the content for the hover. Object can either be an array or a single object. + /// If the object is an array the array can contain objects of type and . + /// If the object is not an array it can be of type , , or . + /// + // This is nullable because in VS we allow null when VSInternalHover.RawContent is specified instead of Contents + [DataMember(Name = "contents")] + public SumType[], MarkupContent>? Contents + { + get; + set; + } + + /// + /// Gets or sets the range over which the hover applies. + /// + [DataMember(Name = "range")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public Range? Range + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/HoverOptions.cs b/src/Features/LanguageServer/Protocol/Protocol/HoverOptions.cs new file mode 100644 index 0000000000000..a34a473e58952 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/HoverOptions.cs @@ -0,0 +1,29 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class which represents the server hover support. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class HoverOptions : IWorkDoneProgressOptions + { + /// + /// Gets or sets a value indicating whether work done progress is supported. + /// + [DataMember(Name = "workDoneProgress")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool WorkDoneProgress + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/HoverSetting.cs b/src/Features/LanguageServer/Protocol/Protocol/HoverSetting.cs new file mode 100644 index 0000000000000..f1d195fb0a6d8 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/HoverSetting.cs @@ -0,0 +1,29 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class which represents the initialization setting for hover. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class HoverSetting : DynamicRegistrationSetting + { + /// + /// Gets or sets the values supported. + /// + [DataMember(Name = "contentFormat")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public MarkupKind[]? ContentFormat + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/IPartialResultParams.cs b/src/Features/LanguageServer/Protocol/Protocol/IPartialResultParams.cs new file mode 100644 index 0000000000000..194dc57dc96cc --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/IPartialResultParams.cs @@ -0,0 +1,26 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System; + + /// + /// Interface to describe parameters for requests that support streaming results. + /// + /// See the Language Server Protocol specification for additional information. + /// + /// The type to be reported by . + internal interface IPartialResultParams + { + /// + /// Gets or sets the value of the PartialResultToken instance. + /// + public IProgress? PartialResultToken + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/IStaticRegistrationOptions.cs b/src/Features/LanguageServer/Protocol/Protocol/IStaticRegistrationOptions.cs new file mode 100644 index 0000000000000..52fab2aad3cbd --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/IStaticRegistrationOptions.cs @@ -0,0 +1,18 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol; + +/// +/// Interface representing the static registration options for options returned in the initialize request. +/// +/// See the Language Server Protocol specification for additional information. +/// +internal interface IStaticRegistrationOptions +{ + /// + /// Gets or sets the id used to register the request. The id can be used to deregister the request again. + /// + public string? Id { get; set; } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/IStringEnum.cs b/src/Features/LanguageServer/Protocol/Protocol/IStringEnum.cs new file mode 100644 index 0000000000000..e08acb1c3008d --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/IStringEnum.cs @@ -0,0 +1,21 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol; + +/// +/// Interface that describes a string-based enumeration. +/// String-based enumerations are serialized simply as their . +/// +/// +/// When implementing this interface, a constructor that takes a single string as parameters is required by +/// . +/// +internal interface IStringEnum +{ + /// + /// Gets the value of the enumeration. + /// + string Value { get; } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/ISumType.cs b/src/Features/LanguageServer/Protocol/Protocol/ISumType.cs new file mode 100644 index 0000000000000..97dd2e33487c3 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/ISumType.cs @@ -0,0 +1,19 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + /// + /// Abstracts over the idea of a "sum type". Sum types are types that can contain one value of various types. + /// This abstraction is guaranteed to be typesafe, meaning you cannot access the underlying value without knowing + /// its specific type. + /// + internal interface ISumType + { + /// + /// Gets the value stored in the SumType. This can be matched against using the "is" operator. + /// + object? Value { get; } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/ITextDocumentParams.cs b/src/Features/LanguageServer/Protocol/Protocol/ITextDocumentParams.cs new file mode 100644 index 0000000000000..4fa13027b0903 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/ITextDocumentParams.cs @@ -0,0 +1,20 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + /// + /// Interface to identify a text document. + /// + internal interface ITextDocumentParams + { + /// + /// Gets or sets the value which identifies the document. + /// + public TextDocumentIdentifier TextDocument + { + get; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/ITextDocumentPositionParams.cs b/src/Features/LanguageServer/Protocol/Protocol/ITextDocumentPositionParams.cs new file mode 100644 index 0000000000000..22901df807aa9 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/ITextDocumentPositionParams.cs @@ -0,0 +1,32 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + /// + /// Interface to identify a text document and a position inside that document. + /// + /// See the Language Server Protocol specification for additional information. + /// + internal interface ITextDocumentPositionParams : ITextDocumentParams + { + /// + /// Gets or sets the value which identifies the document. + /// + public new TextDocumentIdentifier TextDocument + { + get; + set; + } + + /// + /// Gets or sets the value which indicates the position within the document. + /// + public Position Position + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/ITextDocumentRegistrationOptions.cs b/src/Features/LanguageServer/Protocol/Protocol/ITextDocumentRegistrationOptions.cs new file mode 100644 index 0000000000000..b919469dfb16f --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/ITextDocumentRegistrationOptions.cs @@ -0,0 +1,18 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol; + +/// +/// Interface representing the text document registration options. +/// +/// See the Language Server Protocol specification for additional information. +/// +internal interface ITextDocumentRegistrationOptions +{ + /// + /// Gets or sets the document filters for this registration option. + /// + public DocumentFilter[]? DocumentSelector { get; set; } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/IWorkDoneProgressOptions.cs b/src/Features/LanguageServer/Protocol/Protocol/IWorkDoneProgressOptions.cs new file mode 100644 index 0000000000000..d522a0fd552ef --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/IWorkDoneProgressOptions.cs @@ -0,0 +1,23 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + /// + /// Options to signal work done progress support in server capabilities. + /// + internal interface IWorkDoneProgressOptions + { + /// + /// Gets or sets a value indicating whether work done progress is supported. + /// + /// See the Language Server Protocol specification for additional information. + /// + bool WorkDoneProgress + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/ImplementationOptions.cs b/src/Features/LanguageServer/Protocol/Protocol/ImplementationOptions.cs new file mode 100644 index 0000000000000..e158e93bd7b75 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/ImplementationOptions.cs @@ -0,0 +1,29 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class which represents workspace symbols capabilities. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class ImplementationOptions : IWorkDoneProgressOptions + { + /// + /// Gets or sets a value indicating whether work done progress is supported. + /// + [DataMember(Name = "workDoneProgress")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool WorkDoneProgress + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/InitializeError.cs b/src/Features/LanguageServer/Protocol/Protocol/InitializeError.cs new file mode 100644 index 0000000000000..756906f6d62c7 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/InitializeError.cs @@ -0,0 +1,27 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// Class representing the error type sent when the initialize request fails. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class InitializeError + { + /// + /// Gets or sets a value indicating whether or not to retry. + /// + [DataMember(Name = "retry")] + public bool Retry + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/InitializeErrorCode.cs b/src/Features/LanguageServer/Protocol/Protocol/InitializeErrorCode.cs new file mode 100644 index 0000000000000..3f412b17040a5 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/InitializeErrorCode.cs @@ -0,0 +1,22 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// Enum representing the possible reasons for an initialization error. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal enum InitializeErrorCode + { + /// + /// Protocol version can't be handled by the server. + /// + UnknownProtocolVersion = 1, + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/InitializeParams.cs b/src/Features/LanguageServer/Protocol/Protocol/InitializeParams.cs new file mode 100644 index 0000000000000..a3f76104ae979 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/InitializeParams.cs @@ -0,0 +1,108 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System; + using System.ComponentModel; + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class which represents the parameter sent with an initialize method request. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class InitializeParams + { + /// + /// Gets or sets the ID of the process which launched the language server. + /// + [DataMember(Name = "processId")] + [JsonProperty(NullValueHandling = NullValueHandling.Include)] + public int? ProcessId + { + get; + set; + } + + /// + /// Gets or sets the locale the client is currently showing the user interface in. + /// This must not necessarily be the locale of the operating system. + /// + /// Uses IETF language tags as the value's syntax. + /// (See https://en.wikipedia.org/wiki/IETF_language_tag) + /// + [DataMember(Name = "locale")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? Locale + { + get; + set; + } + + /// + /// Gets or sets the workspace root path. + /// + [DataMember(Name = "rootPath")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + [Obsolete("Deprecated in favour of RootUri")] + public string? RootPath + { + get; + set; + } + + /// + /// Gets or sets the workspace root path. + /// + /// + /// This should be a string representation of an URI. + /// + [DataMember(Name = "rootUri")] + [JsonProperty(NullValueHandling = NullValueHandling.Include)] + [JsonConverter(typeof(DocumentUriConverter))] + public Uri? RootUri + { + get; + set; + } + + /// + /// Gets or sets the initialization options as specified by the client. + /// + [DataMember(Name = "initializationOptions")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public object? InitializationOptions + { + get; + set; + } + + /// + /// Gets or sets the capabilities supported by the client. + /// + [DataMember(Name = "capabilities")] + public ClientCapabilities Capabilities + { + get; + set; + } + + /// + /// Gets or sets the initial trace setting. + /// + [DataMember(Name = "trace")] + [DefaultValue(typeof(TraceSetting), "off")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public TraceSetting Trace + { + get; + set; +#pragma warning disable SA1500, SA1513 // Braces for multi-line statements should not share line, Closing brace should be followed by blank line + } = TraceSetting.Off; +#pragma warning restore SA1500, SA1513 // Braces for multi-line statements should not share line, Closing brace should be followed by blank line + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/InitializeResult.cs b/src/Features/LanguageServer/Protocol/Protocol/InitializeResult.cs new file mode 100644 index 0000000000000..8970f738ee2b2 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/InitializeResult.cs @@ -0,0 +1,27 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// Class which represents the result returned by the initialize request. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class InitializeResult + { + /// + /// Gets or sets the server capabilities. + /// + [DataMember(Name = "capabilities")] + public ServerCapabilities Capabilities + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/InitializedParams.cs b/src/Features/LanguageServer/Protocol/Protocol/InitializedParams.cs new file mode 100644 index 0000000000000..833419f347088 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/InitializedParams.cs @@ -0,0 +1,15 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + /// + /// Class containing information sent with the 'initialized' notification. + /// + /// See the Language Server Protocol specification for additional information. + /// + internal class InitializedParams + { + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/InlayHint.cs b/src/Features/LanguageServer/Protocol/Protocol/InlayHint.cs new file mode 100644 index 0000000000000..e710324261479 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/InlayHint.cs @@ -0,0 +1,104 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// A class representing inlay hints that appear next to parameters or types. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class InlayHint + { + /// + /// Gets or sets the position that the inlay hint applies to. + /// + [DataMember(Name = "position")] + public Position Position + { + get; + set; + } + + /// + /// Gets or sets the label associated with this inlay hint. + /// + [DataMember(Name = "label")] + public SumType Label + { + get; + set; + } + + /// + /// Gets or sets the InlayHintKind associated with this inlay hint. + /// + [DataMember(Name = "kind")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public InlayHintKind? Kind + { + get; + set; + } + + /// + /// Gets or sets the TextEdits associated with this inlay hint. + /// + [DataMember(Name = "textEdits")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public TextEdit[]? TextEdits + { + get; + set; + } + + /// + /// Gets or sets the tooltip of this inlay hint. + /// + [DataMember(Name = "tooltip")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public SumType? ToolTip + { + get; + set; + } + + /// + /// Gets or sets the padding before this inlay hint. + /// + [DataMember(Name = "paddingLeft")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool PaddingLeft + { + get; + set; + } + + /// + /// Gets or sets the padding after this inlay hint. + /// + [DataMember(Name = "paddingRight")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool PaddingRight + { + get; + set; + } + + /// + /// Gets or sets the data that should be preserved between a textDocument/inlayHint request and a inlayHint/resolve request. + /// + [DataMember(Name = "data")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public object? Data + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/InlayHintKind.cs b/src/Features/LanguageServer/Protocol/Protocol/InlayHintKind.cs new file mode 100644 index 0000000000000..26b3d742d0007 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/InlayHintKind.cs @@ -0,0 +1,27 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// Enum values for inlay hint kinds. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal enum InlayHintKind + { + /// + /// Type. + /// + Type = 1, + + /// + /// Parameter. + /// + Parameter = 2, + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/InlayHintLabelPart.cs b/src/Features/LanguageServer/Protocol/Protocol/InlayHintLabelPart.cs new file mode 100644 index 0000000000000..f3ae678a2f27f --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/InlayHintLabelPart.cs @@ -0,0 +1,61 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using Newtonsoft.Json; + using System.Runtime.Serialization; + + /// + /// A class representing inlay hint label parts. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class InlayHintLabelPart + { + /// + /// Gets or sets the value associated with this label part. + /// + [DataMember(Name = "value")] + public string Value + { + get; + set; + } + + /// + /// Gets or sets the tooltip of this label part. + /// + [DataMember(Name = "tooltip")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public SumType? ToolTip + { + get; + set; + } + + /// + /// Gets or sets the location of this label part. + /// + [DataMember(Name = "location")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public Location? Location + { + get; + set; + } + + /// + /// Gets or sets the command of this label part. + /// + [DataMember(Name = "command")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public Command? Command + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/InlayHintOptions.cs b/src/Features/LanguageServer/Protocol/Protocol/InlayHintOptions.cs new file mode 100644 index 0000000000000..28b384ae81ee0 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/InlayHintOptions.cs @@ -0,0 +1,40 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using Newtonsoft.Json; + using System.Runtime.Serialization; + + /// + /// Server capabilities for inlay hints. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class InlayHintOptions : IWorkDoneProgressOptions + { + /// + /// Gets or sets a value indicating whether work done progress is supported. + /// + [DataMember(Name = "workDoneProgress")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool WorkDoneProgress + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether or not the inlay hints support has a resolve provider. + /// + [DataMember(Name = "resolveProvider")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool ResolveProvider + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/InlayHintParams.cs b/src/Features/LanguageServer/Protocol/Protocol/InlayHintParams.cs new file mode 100644 index 0000000000000..84556a6ec5a3f --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/InlayHintParams.cs @@ -0,0 +1,37 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// Class representing the parameters sent from the client to the server for a textDocument/inlayHint request. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class InlayHintParams : ITextDocumentParams + { + /// + /// Gets or sets the document identifier to fetch inlay hints results for. + /// + [DataMember(Name = "textDocument")] + public TextDocumentIdentifier TextDocument + { + get; + set; + } + + /// + /// Gets or sets the range to fetch inlay hints results for. + /// + [DataMember(Name = "range")] + public Range Range + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/InlayHintRegistrationOptions.cs b/src/Features/LanguageServer/Protocol/Protocol/InlayHintRegistrationOptions.cs new file mode 100644 index 0000000000000..5825a4c023ac5 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/InlayHintRegistrationOptions.cs @@ -0,0 +1,40 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using Newtonsoft.Json; + using System.Runtime.Serialization; + + /// + /// Inlay hint registration options. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class InlayHintRegistrationOptions : InlayHintOptions, ITextDocumentRegistrationOptions, IStaticRegistrationOptions + { + /// + /// Gets or sets the document filters for this registration option. + /// + [DataMember(Name = "documentSelector")] + [JsonProperty(NullValueHandling = NullValueHandling.Include)] + public DocumentFilter[]? DocumentSelector + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether work done progress is supported. + /// + [DataMember(Name = "id")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? Id + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/InlayHintResolveSupportSetting.cs b/src/Features/LanguageServer/Protocol/Protocol/InlayHintResolveSupportSetting.cs new file mode 100644 index 0000000000000..560985840651c --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/InlayHintResolveSupportSetting.cs @@ -0,0 +1,27 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// Class representing settings for inlayHint/resolve support. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class InlayHintResolveSupportSetting + { + /// + /// Gets or sets a value indicating the properties that a client can resolve lazily. + /// + [DataMember(Name = "properties")] + public string[] Properties + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/InlayHintSetting.cs b/src/Features/LanguageServer/Protocol/Protocol/InlayHintSetting.cs new file mode 100644 index 0000000000000..edce450da136b --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/InlayHintSetting.cs @@ -0,0 +1,30 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing settings for inlay hint support. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class InlayHintSetting : DynamicRegistrationSetting + { + /// + /// Gets or sets a value indicating whether the client supports + /// resolving lazily on an inlay hint. + /// + [DataMember(Name = "resolveSupport")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public InlayHintResolveSupportSetting? ResolveSupport + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/InlayHintWorkspaceSetting.cs b/src/Features/LanguageServer/Protocol/Protocol/InlayHintWorkspaceSetting.cs new file mode 100644 index 0000000000000..5060f0e640602 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/InlayHintWorkspaceSetting.cs @@ -0,0 +1,25 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using Newtonsoft.Json; +using System.Runtime.Serialization; + +namespace Roslyn.LanguageServer.Protocol +{ + /// + /// Class representing the workspace inlay hint client capabilities. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class InlayHintWorkspaceSetting + { + /// + /// Gets or sets a value indicating whether the client supports a refresh request sent from the server to the client. + /// + [DataMember(Name = "refreshSupport")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool RefreshSupport { get; set; } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/InsertReplaceEdit.cs b/src/Features/LanguageServer/Protocol/Protocol/InsertReplaceEdit.cs new file mode 100644 index 0000000000000..9f34cd35362cd --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/InsertReplaceEdit.cs @@ -0,0 +1,47 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// A special text edit to provide an insert and a replace operation. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class InsertReplaceEdit + { + /// + /// Gets or sets the string to be inserted. + /// + [DataMember(Name = "newText", IsRequired = true)] + public string NewText + { + get; + set; + } + + /// + /// Gets or sets the range range if the insert is requested + /// + [DataMember(Name = "insert", IsRequired = true)] + public Range Insert + { + get; + set; + } + + /// + /// Gets or sets the range range if the replace is requested + /// + [DataMember(Name = "replace", IsRequired = true)] + public Range Replace + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/InsertReplaceRange.cs b/src/Features/LanguageServer/Protocol/Protocol/InsertReplaceRange.cs new file mode 100644 index 0000000000000..2ffbf04d520c6 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/InsertReplaceRange.cs @@ -0,0 +1,35 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// Class which represents default range of InsertReplaceEdit for the entire completion list + /// + [DataContract] + internal class InsertReplaceRange + { + /// + /// Gets or sets the insert range. + /// + [DataMember(Name = "insert", IsRequired = true)] + public Range Insert + { + get; + set; + } + + /// + /// Gets or sets the replace edit range. + /// + [DataMember(Name = "replace", IsRequired = true)] + public Range Replace + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/InsertTextFormat.cs b/src/Features/LanguageServer/Protocol/Protocol/InsertTextFormat.cs new file mode 100644 index 0000000000000..537c41b695637 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/InsertTextFormat.cs @@ -0,0 +1,24 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + /// + /// Enum representing insert text format for completion items. + /// + /// See the Language Server Protocol specification for additional information. + /// + internal enum InsertTextFormat + { + /// + /// Completion item insertion is plaintext. + /// + Plaintext = 1, + + /// + /// Completion item insertion is snippet. + /// + Snippet = 2, + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/InsertTextMode.cs b/src/Features/LanguageServer/Protocol/Protocol/InsertTextMode.cs new file mode 100644 index 0000000000000..68d7be59e0c45 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/InsertTextMode.cs @@ -0,0 +1,24 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + /// + /// How whitespace and indentation is handled during completion item insertion. + /// + /// See the Language Server Protocol specification for additional information. + /// + internal enum InsertTextMode + { + /// + /// The insertion or replace strings is taken as it is. + /// + AsIs = 1, + + /// + /// The editor adjusts leading whitespace of new lines so that they match the indentation up to the cursor of the line for which the item is accepted. + /// + AdjustIndentation = 2, + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/InsertTextModeSupportSetting.cs b/src/Features/LanguageServer/Protocol/Protocol/InsertTextModeSupportSetting.cs new file mode 100644 index 0000000000000..3de5c8aa688cb --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/InsertTextModeSupportSetting.cs @@ -0,0 +1,27 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// Class which represents initialization setting for the tag property on a completion item. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class InsertTextModeSupportSetting + { + /// + /// Gets or sets a value indicating the client supports the `insertTextMode` property on a completion item to override the whitespace handling mode as defined by the client. + /// + [DataMember(Name = "valueSet", IsRequired = true)] + public InsertTextMode[] ValueSet + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/Converters/ClassifiedTextElementConverter.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/Converters/ClassifiedTextElementConverter.cs new file mode 100644 index 0000000000000..c7a88f7485e0f --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/Converters/ClassifiedTextElementConverter.cs @@ -0,0 +1,84 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol; + +using System; +using System.Linq; +using Roslyn.Text.Adornments; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +/// +/// JsonConverter for serializing and deserializing . +/// +internal class ClassifiedTextElementConverter : JsonConverter +{ + /// + /// A reusable instance of the . + /// + public static readonly ClassifiedTextElementConverter Instance = new(); + + /// + public override bool CanConvert(Type objectType) => objectType == typeof(ClassifiedTextElement); + + /// + public override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer) + { + if (reader.TokenType == JsonToken.Null) + { + reader.Read(); + return null; + } + else if (reader.TokenType == JsonToken.StartObject) + { + var data = JObject.Load(reader); + var typeProperty = data[ObjectContentConverter.TypeProperty]; + if (typeProperty is not null && typeProperty.ToString() != nameof(ClassifiedTextElement)) + { + throw new JsonSerializationException($"Expected {ObjectContentConverter.TypeProperty} property value {nameof(ClassifiedTextElement)}"); + } + + var runTokens = data[nameof(ClassifiedTextElement.Runs)]?.ToArray() ?? + throw new JsonSerializationException($"Missing {nameof(ClassifiedTextElement.Runs)} property"); + var runs = new ClassifiedTextRun[runTokens.Length]; + for (var i = 0; i < runTokens.Length; i++) + { + var runTokenReader = runTokens[i].CreateReader(); + runTokenReader.Read(); + runs[i] = (ClassifiedTextRun)ClassifiedTextRunConverter.Instance.ReadJson(runTokenReader, typeof(ClassifiedTextRun), null, serializer)!; + } + + return new ClassifiedTextElement(runs); + } + else + { + throw new JsonSerializationException("Expected start object or null tokens"); + } + } + + /// + public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer) + { + if (value is not ClassifiedTextElement classifiedTextElement) + { + writer.WriteNull(); + } + else + { + writer.WriteStartObject(); + writer.WritePropertyName(nameof(ClassifiedTextElement.Runs)); + writer.WriteStartArray(); + foreach (var run in classifiedTextElement.Runs) + { + ClassifiedTextRunConverter.Instance.WriteJson(writer, run, serializer); + } + + writer.WriteEndArray(); + writer.WritePropertyName(ObjectContentConverter.TypeProperty); + writer.WriteValue(nameof(ClassifiedTextElement)); + writer.WriteEndObject(); + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/Converters/ClassifiedTextRunConverter.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/Converters/ClassifiedTextRunConverter.cs new file mode 100644 index 0000000000000..b4becb32c4bef --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/Converters/ClassifiedTextRunConverter.cs @@ -0,0 +1,92 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol; + +using System; +using Roslyn.Text.Adornments; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +/// +/// JsonConverter for serializing and deserializing . +/// +internal class ClassifiedTextRunConverter : JsonConverter +{ + /// + /// A reusable instance of the . + /// + public static readonly ClassifiedTextRunConverter Instance = new(); + + /// + public override bool CanConvert(Type objectType) + => objectType == typeof(ClassifiedTextRun); + + /// + public override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer) + { + if (reader.TokenType == JsonToken.Null) + { + reader.Read(); + return null; + } + else if (reader.TokenType == JsonToken.StartObject) + { + var data = JObject.Load(reader); + var typeProperty = data[ObjectContentConverter.TypeProperty]; + if (typeProperty is not null && typeProperty.ToString() != nameof(ClassifiedTextRun)) + { + throw new JsonSerializationException($"Expected {ObjectContentConverter.TypeProperty} property value {nameof(ClassifiedTextRun)}"); + } + + var classificationTypeName = data[nameof(ClassifiedTextRun.ClassificationTypeName)]?.Value(); + var text = data[nameof(ClassifiedTextRun.Text)]?.Value(); + var markerTagType = data[nameof(ClassifiedTextRun.MarkerTagType)]?.Value(); + var style = (ClassifiedTextRunStyle)(data[nameof(ClassifiedTextRun.Style)]?.Value() ?? 0); + return new ClassifiedTextRun(classificationTypeName!, text!, style, markerTagType); + } + else + { + throw new JsonSerializationException("Expected start object or null tokens"); + } + } + + /// + public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer) + { + if (value is not ClassifiedTextRun classifiedTextRun) + { + writer.WriteNull(); + } + else + { + writer.WriteStartObject(); + writer.WritePropertyName(nameof(ClassifiedTextRun.ClassificationTypeName)); + writer.WriteValue(classifiedTextRun.ClassificationTypeName); + writer.WritePropertyName(nameof(ClassifiedTextRun.Text)); + writer.WriteValue(classifiedTextRun.Text); + writer.WritePropertyName(nameof(ClassifiedTextRun.MarkerTagType)); + writer.WriteValue(classifiedTextRun.MarkerTagType); + writer.WritePropertyName(nameof(ClassifiedTextRun.Style)); + writer.WriteValue(classifiedTextRun.Style); + writer.WritePropertyName(nameof(ClassifiedTextRun.Tooltip)); + writer.WriteNull(); + if (classifiedTextRun.Tooltip is not null) + { + throw new JsonSerializationException(); + } + + writer.WritePropertyName(nameof(ClassifiedTextRun.NavigationAction)); + writer.WriteNull(); + if (classifiedTextRun.NavigationAction is not null) + { + throw new JsonSerializationException(); + } + + writer.WritePropertyName(ObjectContentConverter.TypeProperty); + writer.WriteValue(nameof(ClassifiedTextRun)); + writer.WriteEndObject(); + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/Converters/ContainerElementConverter.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/Converters/ContainerElementConverter.cs new file mode 100644 index 0000000000000..d1778d40c9251 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/Converters/ContainerElementConverter.cs @@ -0,0 +1,87 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol; + +using System; +using System.Linq; +using Roslyn.Text.Adornments; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +/// +/// JsonConverter for serializing and deserializing . +/// +internal class ContainerElementConverter : JsonConverter +{ + /// + /// A reusable instance of the . + /// + public static readonly ContainerElementConverter Instance = new(); + + /// + public override bool CanConvert(Type objectType) => objectType == typeof(ContainerElement); + + /// + public override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer) + { + if (reader.TokenType == JsonToken.Null) + { + reader.Read(); + return null; + } + else if (reader.TokenType == JsonToken.StartObject) + { + var data = JObject.Load(reader); + var typeProperty = data[ObjectContentConverter.TypeProperty]; + if (typeProperty is not null && typeProperty.ToString() != nameof(ContainerElement)) + { + throw new JsonSerializationException($"Expected {ObjectContentConverter.TypeProperty} property value {nameof(ContainerElement)}"); + } + + var elementTokens = data[nameof(ContainerElement.Elements)]?.ToArray() ?? + throw new JsonSerializationException($"Missing {nameof(ContainerElement.Elements)} property"); + var elements = new object?[elementTokens.Length]; + for (var i = 0; i < elementTokens.Length; i++) + { + var elementTokenReader = elementTokens[i].CreateReader(); + elementTokenReader.Read(); + elements[i] = ObjectContentConverter.Instance.ReadJson(elementTokenReader, typeof(object), null, serializer); + } + + var style = (ContainerElementStyle)(data[nameof(ContainerElement.Style)]?.Value() ?? throw new JsonSerializationException()); + return new ContainerElement(style, elements); + } + else + { + throw new JsonSerializationException("Expected start object or null tokens"); + } + } + + /// + public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer) + { + if (value is not ContainerElement containerElement) + { + writer.WriteNull(); + } + else + { + writer.WriteStartObject(); + writer.WritePropertyName(nameof(ContainerElement.Elements)); + writer.WriteStartArray(); + foreach (var run in containerElement.Elements) + { + ObjectContentConverter.Instance.WriteJson(writer, run, serializer); + } + + writer.WriteEndArray(); + writer.WritePropertyName(nameof(ContainerElement.Style)); + writer.WriteValue(containerElement.Style); + writer.WritePropertyName(ObjectContentConverter.TypeProperty); + writer.WriteValue(nameof(ContainerElement)); + writer.WriteEndObject(); + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/Converters/DropProgressConverter.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/Converters/DropProgressConverter.cs new file mode 100644 index 0000000000000..868de33bddf28 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/Converters/DropProgressConverter.cs @@ -0,0 +1,52 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System; + using System.Linq; + using Newtonsoft.Json; + + /// + /// Converter used to deserialize objects dropping any property. + /// + internal class DropProgressConverter : JsonConverter + { + /// + public override bool CanWrite => true; + + /// + /// Static method to get a containing a . + /// + /// object containing a . + public static JsonSerializer CreateSerializer() + { + var serializer = new JsonSerializer(); + serializer.Converters.Add(new DropProgressConverter()); + return serializer; + } + + /// + public override bool CanConvert(Type objectType) + { + var isIProgressOfT = objectType.IsConstructedGenericType && objectType.GetGenericTypeDefinition().Equals(typeof(IProgress<>)); + var implementsIProgressOfT = objectType.GetInterfaces().Any(i => i.IsGenericType && i.GetGenericTypeDefinition().Equals(typeof(IProgress<>))); + + return isIProgressOfT || implementsIProgressOfT; + } + + /// + public override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer) + { + // We deserialize all IProgress objects as null. + return null; + } + + /// + public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer) + { + writer.WriteNull(); + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/Converters/ImageElementConverter.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/Converters/ImageElementConverter.cs new file mode 100644 index 0000000000000..cb8d549fe6f65 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/Converters/ImageElementConverter.cs @@ -0,0 +1,74 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol; + +using System; +using Roslyn.Core.Imaging; +using Roslyn.Text.Adornments; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +/// +/// JsonConverter for serializing and deserializing . +/// +internal class ImageElementConverter : JsonConverter +{ + /// + /// A reusable instance of the . + /// + public static readonly ImageElementConverter Instance = new(); + + /// + public override bool CanConvert(Type objectType) => objectType == typeof(ImageElement); + + /// + public override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer) + { + if (reader.TokenType == JsonToken.Null) + { + reader.Read(); + return null; + } + else if (reader.TokenType == JsonToken.StartObject) + { + var data = JObject.Load(reader); + var typeProperty = data[ObjectContentConverter.TypeProperty]; + if (typeProperty is not null && typeProperty.ToString() != nameof(ImageElement)) + { + throw new JsonSerializationException($"Expected {ObjectContentConverter.TypeProperty} property value {nameof(ImageElement)}"); + } + + var imageTokenReader = data[nameof(ImageElement.ImageId)]?.CreateReader() ?? throw new JsonSerializationException(); + imageTokenReader.Read(); + var imageId = (ImageId)ImageIdConverter.Instance.ReadJson(imageTokenReader, typeof(ImageId), null, serializer)!; + var automationName = data[nameof(ImageElement.AutomationName)]?.Value(); + return automationName is null ? new ImageElement(imageId) : new ImageElement(imageId, automationName); + } + else + { + throw new JsonSerializationException("Expected start object or null tokens"); + } + } + + /// + public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer) + { + if (value is not ImageElement imageElement) + { + writer.WriteNull(); + } + else + { + writer.WriteStartObject(); + writer.WritePropertyName(nameof(ImageElement.ImageId)); + ImageIdConverter.Instance.WriteJson(writer, imageElement.ImageId, serializer); + writer.WritePropertyName(nameof(ImageElement.AutomationName)); + writer.WriteValue(imageElement.AutomationName); + writer.WritePropertyName(ObjectContentConverter.TypeProperty); + writer.WriteValue(nameof(ImageElement)); + writer.WriteEndObject(); + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/Converters/ImageIdConverter.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/Converters/ImageIdConverter.cs new file mode 100644 index 0000000000000..825d98d413ea5 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/Converters/ImageIdConverter.cs @@ -0,0 +1,72 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol; + +using System; +using Roslyn.Core.Imaging; +using Roslyn.Text.Adornments; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +/// +/// JsonConverter for serializing and deserializing . +/// +internal class ImageIdConverter : JsonConverter +{ + /// + /// A reusable instance of the . + /// + public static readonly ImageIdConverter Instance = new(); + + /// + public override bool CanConvert(Type objectType) => objectType == typeof(ImageId); + + /// + public override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer) + { + if (reader.TokenType == JsonToken.Null) + { + reader.Read(); + return null; + } + else if (reader.TokenType == JsonToken.StartObject) + { + var data = JObject.Load(reader); + var typeProperty = data[ObjectContentConverter.TypeProperty]; + if (typeProperty is not null && typeProperty.ToString() != nameof(ImageId)) + { + throw new JsonSerializationException($"Expected {ObjectContentConverter.TypeProperty} property value {nameof(ImageId)}"); + } + + var guid = data[nameof(ImageId.Guid)]?.Value() ?? throw new JsonSerializationException(); + var id = data[nameof(ImageId.Id)]?.Value() ?? throw new JsonSerializationException(); + return new ImageId(new Guid(guid), id); + } + else + { + throw new JsonSerializationException("Expected start object or null tokens"); + } + } + + /// + public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer) + { + if (value is not ImageId imageId) + { + writer.WriteNull(); + } + else + { + writer.WriteStartObject(); + writer.WritePropertyName(nameof(ImageId.Guid)); + writer.WriteValue(imageId.Guid); + writer.WritePropertyName(nameof(ImageId.Id)); + writer.WriteValue(imageId.Id); + writer.WritePropertyName(ObjectContentConverter.TypeProperty); + writer.WriteValue(nameof(ImageId)); + writer.WriteEndObject(); + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/Converters/ObjectContentConverter.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/Converters/ObjectContentConverter.cs new file mode 100644 index 0000000000000..26e0886a0ee51 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/Converters/ObjectContentConverter.cs @@ -0,0 +1,116 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System; + using Roslyn.Core.Imaging; + using Roslyn.Text.Adornments; + using Newtonsoft.Json; + using Newtonsoft.Json.Linq; + + /// + /// Object Content converter used to serialize and deserialize Text and Adornements from VS. + /// + /// This converts the following types: + /// + /// , + /// , + /// , + /// , + /// . + /// + /// Every other type is serialized as a string using the method. + /// + internal class ObjectContentConverter : JsonConverter + { + /// + /// The property name used to save the .NET Type name of the serialized object. + /// + public const string TypeProperty = "_vs_type"; + + /// + /// A reusable instance of the . + /// + public static readonly ObjectContentConverter Instance = new ObjectContentConverter(); + + /// + public override bool CanConvert(Type objectType) + { + return objectType == typeof(object); + } + + /// + public override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer) + { + if (reader.TokenType == JsonToken.Null) + { + reader.Read(); + return null; + } + else if (reader.TokenType == JsonToken.StartObject) + { + var data = JObject.Load(reader); + var type = data[TypeProperty]?.ToString() ?? throw new JsonSerializationException(); + + var tokenReader = data.CreateReader(); + tokenReader.Read(); + switch (type) + { + case nameof(ImageId): + return ImageIdConverter.Instance.ReadJson(tokenReader, typeof(ImageId), null, serializer); + case nameof(ImageElement): + return ImageElementConverter.Instance.ReadJson(tokenReader, typeof(ImageElement), null, serializer); + case nameof(ContainerElement): + return ContainerElementConverter.Instance.ReadJson(tokenReader, typeof(ContainerElementConverter), null, serializer); + case nameof(ClassifiedTextElement): + return ClassifiedTextElementConverter.Instance.ReadJson(tokenReader, typeof(ClassifiedTextElementConverter), null, serializer); + case nameof(ClassifiedTextRun): + return ClassifiedTextRunConverter.Instance.ReadJson(tokenReader, typeof(ClassifiedTextRunConverter), null, serializer); + default: + return data; + } + } + else + { + return serializer.Deserialize(reader); + } + } + + /// + public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer) + { + if (value is null) + { + writer.WriteNull(); + return; + } + + switch (value) + { + case ImageId: + ImageIdConverter.Instance.WriteJson(writer, value, serializer); + break; + case ImageElement: + ImageElementConverter.Instance.WriteJson(writer, value, serializer); + break; + case ContainerElement: + ContainerElementConverter.Instance.WriteJson(writer, value, serializer); + break; + case ClassifiedTextElement: + ClassifiedTextElementConverter.Instance.WriteJson(writer, value, serializer); + break; + case ClassifiedTextRun: + ClassifiedTextRunConverter.Instance.WriteJson(writer, value, serializer); + break; + default: + // According to the docs of ContainerElement point to https://docs.microsoft.com/en-us/dotnet/api/microsoft.visualstudio.text.adornments.iviewelementfactoryservice + // which states that Editor supports ClassifiedTextElement, ContainerElement, ImageElement and that other objects would be presented using ToString unless an extender + // exports a IViewElementFactory for that type. So I will simply serialize unknown objects as strings. + writer.WriteValue(value.ToString()); + break; + } + } + } +} \ No newline at end of file diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/Converters/RegexConverter.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/Converters/RegexConverter.cs new file mode 100644 index 0000000000000..1bd71cd566617 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/Converters/RegexConverter.cs @@ -0,0 +1,49 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System; + using System.Text.RegularExpressions; + + using Newtonsoft.Json; + + /// + /// Similar to https://devdiv.visualstudio.com/DevDiv/_git/VS-Platform?path=/src/Productivity/TextMate/Core/LanguageConfiguration/Impl/FastRegexConverter.cs + /// to allow us to only compile the regex option once. + /// + internal class RegexConverter : JsonConverter + { + public override bool CanConvert(Type objectType) + { + // nameof is faster than typeof, so below is a fast path. + return objectType.Name == nameof(Regex) && objectType == typeof(Regex); + } + + public override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer) + { + // Create a custom deserializer for regex as the default provided by newtonsoft doesn't + // specify the Compiled option. + var regexText = reader.Value as string; + if (string.IsNullOrEmpty(regexText)) + { + return null; + } + + return new Regex(regexText, RegexOptions.Compiled | RegexOptions.ECMAScript, matchTimeout: TimeSpan.FromMilliseconds(1000)); + } + + public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer) + { + if (value is Regex valueAsRegex) + { + writer.WriteValue(valueAsRegex.ToString()); + } + else + { + throw new ArgumentException($"{nameof(value)} must be of type {nameof(Regex)}"); + } + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/Converters/VSInternalExtensionUtilities.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/Converters/VSInternalExtensionUtilities.cs new file mode 100644 index 0000000000000..dea7f8218f125 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/Converters/VSInternalExtensionUtilities.cs @@ -0,0 +1,73 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using Newtonsoft.Json; + + /// + /// Utilities to aid work with the LSP Extensions. + /// + internal static class VSInternalExtensionUtilities + { + /// + /// Adds necessary to deserialize + /// JSON stream into objects which include VS-specific extensions. + /// + /// + /// If is used in parallel to execution of this method, + /// its access needs to be synchronized with this method call, to guarantee that + /// collection is not modified when in use. + /// + /// Instance of which is guaranteed to not work in parallel to this method call. + public static void AddVSInternalExtensionConverters(this JsonSerializer serializer) + { + VSExtensionUtilities.AddVSExtensionConverters(serializer); + + // Reading the number of converters before we start adding new ones + var existingConvertersCount = serializer.Converters.Count; + + AddOrReplaceConverter(); + AddOrReplaceConverter(); + AddOrReplaceConverter(); + AddOrReplaceConverter(); + AddOrReplaceConverter(); + AddOrReplaceConverter(); + AddOrReplaceConverter(); + AddOrReplaceConverter(); + AddOrReplaceConverter(); + AddOrReplaceConverter(); + AddOrReplaceConverter(); + AddOrReplaceConverter(); + AddOrReplaceConverter(); + AddOrReplaceConverter(); + AddOrReplaceConverter(); + AddOrReplaceConverter(); + AddOrReplaceConverter(); + AddOrReplaceConverter(); + AddOrReplaceConverter(); + AddOrReplaceConverter(); + AddOrReplaceConverter(); + + void AddOrReplaceConverter() + where TExtension : TBase + { + for (var i = 0; i < existingConvertersCount; i++) + { + var existingConverterType = serializer.Converters[i].GetType(); + if (existingConverterType.IsGenericType && + existingConverterType.GetGenericTypeDefinition() == typeof(VSExtensionConverter<,>) && + existingConverterType.GenericTypeArguments[0] == typeof(TBase)) + { + serializer.Converters.RemoveAt(i); + existingConvertersCount--; + break; + } + } + + serializer.Converters.Add(new VSExtensionConverter()); + } + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/Diagnostics/VSInternalDiagnosticKind.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/Diagnostics/VSInternalDiagnosticKind.cs new file mode 100644 index 0000000000000..05d65708fcfd3 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/Diagnostics/VSInternalDiagnosticKind.cs @@ -0,0 +1,25 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.ComponentModel; + using System.Runtime.Serialization; + + using Newtonsoft.Json; + + /// + /// Value representing the kind of a diagnostic. + /// + [DataContract] + [JsonConverter(typeof(StringEnumConverter))] + [TypeConverter(typeof(StringEnumConverter.TypeConverter))] + internal readonly record struct VSInternalDiagnosticKind(string Value) : IStringEnum + { + /// + /// Task list diagnostic kind. + /// + public static readonly VSInternalDiagnosticKind Task = new("task"); + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/Diagnostics/VSInternalDiagnosticOptions.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/Diagnostics/VSInternalDiagnosticOptions.cs new file mode 100644 index 0000000000000..39c5a27db93a1 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/Diagnostics/VSInternalDiagnosticOptions.cs @@ -0,0 +1,53 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Server provided options for pull diagnostic requests. + /// + [DataContract] + internal class VSInternalDiagnosticOptions : IWorkDoneProgressOptions + { + /// + /// Gets or sets a list of id's used to identify diagnostics that may be coming + /// from build systems instead of a language server. + /// + /// VS client will then use the information to do any merging logic in the Error List. + /// Maps to . + /// + [DataMember(Name = "_vs_buildOnlyDiagnosticIds")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string[]? BuildOnlyDiagnosticIds + { + get; + set; + } + + /// + /// Gets or sets a list of diagnostic kinds used to query diagnostics in each context. + /// + [DataMember(Name = "_vs_diagnosticKinds")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public VSInternalDiagnosticKind[]? DiagnosticKinds + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether work done progress is supported. + /// + [DataMember(Name = "_vs_workDoneProgress")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool WorkDoneProgress + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/Diagnostics/VSInternalDiagnosticParams.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/Diagnostics/VSInternalDiagnosticParams.cs new file mode 100644 index 0000000000000..40e808078218a --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/Diagnostics/VSInternalDiagnosticParams.cs @@ -0,0 +1,53 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + using Newtonsoft.Json; + + /// + /// Class representing a diagnostic pull request parameter used. + /// + [DataContract] + internal class VSInternalDiagnosticParams + { + /// + /// Gets or sets the document for which diagnostics are desired. + /// + [DataMember(Name = "_vs_textDocument", IsRequired = true)] + public TextDocumentIdentifier? TextDocument { get; set; } + + /// + /// Gets or sets a value indicating what kind of diagnostic this request is querying for. + /// + [DataMember(Name = "_vs_queryingDiagnosticKind")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public VSInternalDiagnosticKind? QueryingDiagnosticKind { get; set; } + + /// + /// Gets or sets the server-generated version number for the diagnostics. + /// + /// + /// + /// This is treated as a black box by the client: it is stored on the client + /// for each textDocument and sent back to the server when requesting + /// diagnostics. The server can use this result ID to avoid resending + /// diagnostics that had previously been sent. + /// + /// Note that if a client does request diagnostics that haven’t changed, the + /// language server should not reply with any diagnostics for that document. + /// If the client requests diagnostics for a file that has been renamed or + /// deleted, then the language service should respond with null for the + /// diagnostics. + /// Also, if a service is reporting multiple DiagnosticReports for the same + /// document, then all reports are expected to have the same + /// previousResultId. + /// + [DataMember(Name = "_vs_previousResultId")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? PreviousResultId { get; set; } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/Diagnostics/VSInternalDiagnosticReport.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/Diagnostics/VSInternalDiagnosticReport.cs new file mode 100644 index 0000000000000..29b96efd3f442 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/Diagnostics/VSInternalDiagnosticReport.cs @@ -0,0 +1,77 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System; + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing a diagnostic pull request report. + /// + [DataContract] + internal class VSInternalDiagnosticReport + { + /// + /// Gets or sets the server-generated version number for the diagnostics. + /// This is treated as a black box by the client: it is stored on the client + /// for each textDocument and sent back to the server when requesting + /// diagnostics.The server can use this result ID to avoid resending + /// diagnostics that had previously been sent. + /// + [DataMember(Name = "_vs_resultId")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? ResultId { get; set; } + + /// + /// Gets or sets a (potentially incomplete) list of Diagnostics for the document. + /// Subsequent DiagnosticReports for the same document will be appended. + /// + /// + /// Is null if no changes in the diagnostics. Is empty if there is no diagnostic. + /// + [DataMember(Name = "_vs_diagnostics")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public Diagnostic[]? Diagnostics { get; set; } + + /// + /// Gets or sets an identifier associated with all the diagnostics in this report. + /// + /// If the property matches the supersedes property of another report, + /// entries tagged with will + /// be hidden in the editor. + /// + [DataMember(Name = "_vs_identifier")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public int? Identifier { get; set; } + + /// + /// Gets or sets an indicator of which diagnostic report is superseded by this report. + /// + /// + /// Diagnostics in a superseded report will be hidden if they have the PotentialDuplicate VSDiagnosticTag. + /// + [DataMember(Name = "_vs_supersedes")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public int? Supersedes { get; set; } + + /// + /// Gets or sets an optional key used to associate diagnostics with lines + /// of text in the output window(diagnostics can have an additional + /// outputId and the (outputKey, outputId) uniquely identify + /// a line of text in the output window). + /// + [DataMember(Name = "_vs_outputKey")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public Guid? OutputKey { get; set; } + + /// + /// Gets or sets the document version. + /// + [DataMember(Name = "_vs_version")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public int? Version { get; set; } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/Diagnostics/VSInternalDocumentDiagnosticsParams.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/Diagnostics/VSInternalDocumentDiagnosticsParams.cs new file mode 100644 index 0000000000000..8b61f2fbf6438 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/Diagnostics/VSInternalDocumentDiagnosticsParams.cs @@ -0,0 +1,31 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System; + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing a diagnostic pull request for a specific document. + /// + [DataContract] + internal class VSInternalDocumentDiagnosticsParams : VSInternalDiagnosticParams, IPartialResultParams + { + /// + /// Gets or sets an optional token that a server can use to report work done progress. + /// + [DataMember(Name = Methods.WorkDoneTokenName)] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public IProgress? WorkDoneToken { get; set; } + + /// + /// Gets or sets an optional token that a server can use to report partial results (e.g. streaming) to the client. + /// + [DataMember(Name = Methods.PartialResultTokenName)] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public IProgress? PartialResultToken { get; set; } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/Diagnostics/VSInternalWorkspaceDiagnosticReport.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/Diagnostics/VSInternalWorkspaceDiagnosticReport.cs new file mode 100644 index 0000000000000..b4841e7c41664 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/Diagnostics/VSInternalWorkspaceDiagnosticReport.cs @@ -0,0 +1,21 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// Class representing a diagnostic pull request result for all documents. + /// + [DataContract] + internal class VSInternalWorkspaceDiagnosticReport : VSInternalDiagnosticReport + { + /// + /// Gets or sets the document for which diagnostics is returned. + /// + [DataMember(Name = "_vs_textDocument", IsRequired = true)] + public TextDocumentIdentifier? TextDocument { get; set; } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/Diagnostics/VSInternalWorkspaceDiagnosticsParams.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/Diagnostics/VSInternalWorkspaceDiagnosticsParams.cs new file mode 100644 index 0000000000000..1ddf9bd496914 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/Diagnostics/VSInternalWorkspaceDiagnosticsParams.cs @@ -0,0 +1,45 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System; + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing a diagnostic pull request for all documents. + /// + [DataContract] + internal class VSInternalWorkspaceDiagnosticsParams : IPartialResultParams + { + /// + /// Gets or sets the current state of the documents the client already has received. + /// + [DataMember(Name = "_vs_previousResults")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public VSInternalDiagnosticParams[]? PreviousResults { get; set; } + + /// + /// Gets or sets an optional token that a server can use to report work done progress. + /// + [DataMember(Name = Methods.WorkDoneTokenName)] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public IProgress? WorkDoneToken { get; set; } + + /// + /// Gets or sets an optional token that a server can use to report partial results (e.g. streaming) to the client. + /// + [DataMember(Name = Methods.PartialResultTokenName)] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public IProgress? PartialResultToken { get; set; } + + /// + /// Gets or sets a value indicating what kind of diagnostic this request is querying for. + /// + [DataMember(Name = "_vs_queryingDiagnosticKind")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public VSInternalDiagnosticKind? QueryingDiagnosticKind { get; set; } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/Efficiency/OptimizedVSCompletionList.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/Efficiency/OptimizedVSCompletionList.cs new file mode 100644 index 0000000000000..f99efeba0bbea --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/Efficiency/OptimizedVSCompletionList.cs @@ -0,0 +1,43 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// A subclass of the VS LSP protocol extension that has a fast serialization path. + /// + [DataContract] + [JsonConverter(typeof(OptimizedVSCompletionListJsonConverter))] + internal sealed class OptimizedVSCompletionList : VSInternalCompletionList + { + /// + /// Initializes a new instance of the class. + /// + /// The completion list to wrap. + public OptimizedVSCompletionList(VSInternalCompletionList completionList) + { + this.Items = completionList.Items; + this.IsIncomplete = completionList.IsIncomplete; + this.SuggestionMode = completionList.SuggestionMode; + this.ContinueCharacters = completionList.ContinueCharacters; + this.Data = completionList.Data; + this.CommitCharacters = completionList.CommitCharacters; + this.ItemDefaults = completionList.ItemDefaults; + } + + /// + /// Initializes a new instance of the class. + /// + /// The completion list to wrap. + public OptimizedVSCompletionList(CompletionList completionList) + { + this.Items = completionList.Items; + this.IsIncomplete = completionList.IsIncomplete; + this.ItemDefaults = completionList.ItemDefaults; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/Efficiency/OptimizedVSCompletionListJsonConverter.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/Efficiency/OptimizedVSCompletionListJsonConverter.cs new file mode 100644 index 0000000000000..8369864bfd38f --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/Efficiency/OptimizedVSCompletionListJsonConverter.cs @@ -0,0 +1,267 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System; + using System.Collections.Concurrent; + using System.Collections.Generic; + using Roslyn.Core.Imaging; + using Newtonsoft.Json; + + internal class OptimizedVSCompletionListJsonConverter : JsonConverter + { + public static readonly OptimizedVSCompletionListJsonConverter Instance = new OptimizedVSCompletionListJsonConverter(); + private static readonly ConcurrentDictionary IconRawJson = new ConcurrentDictionary(); + + public override bool CanRead => false; + + public override bool CanConvert(Type objectType) => typeof(OptimizedVSCompletionList) == objectType; + + public override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer) => throw new NotImplementedException(); + + public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer) + { + if (value is null) + { + writer.WriteNull(); + return; + } + + var completionList = (VSInternalCompletionList)value; + + writer.WriteStartObject(); + + if (completionList.SuggestionMode) + { + writer.WritePropertyName(VSInternalCompletionList.SuggestionModeSerializedName); + writer.WriteValue(completionList.SuggestionMode); + } + else + { + // Default is "false" so no need to serialize + } + + if (completionList.ContinueCharacters != null && completionList.ContinueCharacters.Length > 0) + { + writer.WritePropertyName(VSInternalCompletionList.ContinueCharactersSerializedName); + serializer.Serialize(writer, completionList.ContinueCharacters); + } + + if (completionList.Data != null) + { + writer.WritePropertyName(VSInternalCompletionList.DataSerializedName); + serializer.Serialize(writer, completionList.Data); + } + + if (completionList.CommitCharacters != null) + { + writer.WritePropertyName(VSInternalCompletionList.CommitCharactersSerializedName); + serializer.Serialize(writer, completionList.CommitCharacters); + } + + if (completionList.IsIncomplete) + { + writer.WritePropertyName("isIncomplete"); + writer.WriteValue(completionList.IsIncomplete); + } + else + { + // Default is "false" so no need to serialize + } + + writer.WritePropertyName("items"); + if (completionList.Items == null || completionList.Items.Length == 0) + { + writer.WriteRawValue("[]"); + } + else + { + writer.WriteStartArray(); + + var itemRawJsonCache = new Dictionary(capacity: 1); + + foreach (var completionItem in completionList.Items) + { + if (completionItem == null) + { + continue; + } + + WriteCompletionItem(writer, completionItem, serializer, itemRawJsonCache); + } + + writer.WriteEndArray(); + } + + if (completionList.ItemDefaults != null) + { + writer.WritePropertyName("itemDefaults"); + serializer.Serialize(writer, completionList.ItemDefaults); + } + + writer.WriteEndObject(); + } + + private static void WriteCompletionItem(JsonWriter writer, CompletionItem completionItem, JsonSerializer serializer, Dictionary itemRawJsonCache) + { + writer.WriteStartObject(); + + if (completionItem is VSInternalCompletionItem vsCompletionItem) + { + if (vsCompletionItem.Icon != null) + { + if (!IconRawJson.TryGetValue(vsCompletionItem.Icon.ImageId, out var jsonString)) + { + jsonString = JsonConvert.SerializeObject(vsCompletionItem.Icon, Formatting.None, ImageElementConverter.Instance); + IconRawJson.TryAdd(vsCompletionItem.Icon.ImageId, jsonString); + } + + writer.WritePropertyName(VSInternalCompletionItem.IconSerializedName); + writer.WriteRawValue(jsonString); + } + + if (vsCompletionItem.Description != null) + { + writer.WritePropertyName(VSInternalCompletionItem.DescriptionSerializedName); + ClassifiedTextElementConverter.Instance.WriteJson(writer, vsCompletionItem.Description, serializer); + } + + if (vsCompletionItem.VsCommitCharacters?.Value is string[] basicCommitCharacters + && basicCommitCharacters.Length > 0) + { + if (!itemRawJsonCache.TryGetValue(basicCommitCharacters, out var jsonString)) + { + jsonString = JsonConvert.SerializeObject(basicCommitCharacters); + itemRawJsonCache.Add(basicCommitCharacters, jsonString); + } + + writer.WritePropertyName(VSInternalCompletionItem.VsCommitCharactersSerializedName); + writer.WriteRawValue(jsonString); + } + else if (vsCompletionItem.VsCommitCharacters?.Value is VSInternalCommitCharacter[] augmentedCommitCharacters + && augmentedCommitCharacters.Length > 0) + { + if (!itemRawJsonCache.TryGetValue(augmentedCommitCharacters, out var jsonString)) + { + jsonString = JsonConvert.SerializeObject(augmentedCommitCharacters); + itemRawJsonCache.Add(augmentedCommitCharacters, jsonString); + } + + writer.WritePropertyName(VSInternalCompletionItem.VsCommitCharactersSerializedName); + writer.WriteRawValue(jsonString); + } + + if (vsCompletionItem.VsResolveTextEditOnCommit) + { + writer.WritePropertyName(VSInternalCompletionItem.VsResolveTextEditOnCommitName); + writer.WriteValue(vsCompletionItem.VsResolveTextEditOnCommit); + } + } + + var label = completionItem.Label; + if (label != null) + { + writer.WritePropertyName("label"); + writer.WriteValue(label); + } + + if (completionItem.LabelDetails != null) + { + writer.WritePropertyName("labelDetails"); + serializer.Serialize(writer, completionItem.LabelDetails); + } + + writer.WritePropertyName("kind"); + writer.WriteValue(completionItem.Kind); + + if (completionItem.Detail != null) + { + writer.WritePropertyName("detail"); + writer.WriteValue(completionItem.Detail); + } + + if (completionItem.Documentation != null) + { + writer.WritePropertyName("documentation"); + serializer.Serialize(writer, completionItem.Documentation); + } + + // Only render preselect if it's "true" + if (completionItem.Preselect) + { + writer.WritePropertyName("preselect"); + writer.WriteValue(completionItem.Preselect); + } + + if (completionItem.SortText != null && !string.Equals(completionItem.SortText, label, StringComparison.Ordinal)) + { + writer.WritePropertyName("sortText"); + writer.WriteValue(completionItem.SortText); + } + + if (completionItem.FilterText != null && !string.Equals(completionItem.FilterText, label, StringComparison.Ordinal)) + { + writer.WritePropertyName("filterText"); + writer.WriteValue(completionItem.FilterText); + } + + if (completionItem.InsertText != null && !string.Equals(completionItem.InsertText, label, StringComparison.Ordinal)) + { + writer.WritePropertyName("insertText"); + writer.WriteValue(completionItem.InsertText); + } + + if (completionItem.InsertTextFormat != default && completionItem.InsertTextFormat != InsertTextFormat.Plaintext) + { + writer.WritePropertyName("insertTextFormat"); + writer.WriteValue(completionItem.InsertTextFormat); + } + + if (completionItem.TextEdit != null) + { + writer.WritePropertyName("textEdit"); + serializer.Serialize(writer, completionItem.TextEdit); + } + + if (completionItem.TextEditText != null) + { + writer.WritePropertyName("textEditText"); + serializer.Serialize(writer, completionItem.TextEditText); + } + + if (completionItem.AdditionalTextEdits != null && completionItem.AdditionalTextEdits.Length > 0) + { + writer.WritePropertyName("additionalTextEdits"); + serializer.Serialize(writer, completionItem.AdditionalTextEdits); + } + + if (completionItem.CommitCharacters != null && completionItem.CommitCharacters.Length > 0) + { + if (!itemRawJsonCache.TryGetValue(completionItem.CommitCharacters, out var jsonString)) + { + jsonString = JsonConvert.SerializeObject(completionItem.CommitCharacters); + itemRawJsonCache.Add(completionItem.CommitCharacters, jsonString); + } + + writer.WritePropertyName("commitCharacters"); + writer.WriteRawValue(jsonString); + } + + if (completionItem.Command != null) + { + writer.WritePropertyName("command"); + serializer.Serialize(writer, completionItem.Command); + } + + if (completionItem.Data != null) + { + writer.WritePropertyName("data"); + serializer.Serialize(writer, completionItem.Data); + } + + writer.WriteEndObject(); + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/Text/ClassifiedTextElement.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/Text/ClassifiedTextElement.cs new file mode 100644 index 0000000000000..e472d496076d0 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/Text/ClassifiedTextElement.cs @@ -0,0 +1,41 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Collections.Immutable; +using Roslyn.Text.Adornments; + +namespace Roslyn.Text.Adornments +{ + internal sealed class ClassifiedTextElement + { + public const string TextClassificationTypeName = "text"; + + public IEnumerable Runs { get; } + + public ClassifiedTextElement(params ClassifiedTextRun[] runs) + { + Runs = runs?.ToImmutableList() ?? throw new ArgumentNullException("runs"); + } + + public ClassifiedTextElement(IEnumerable runs) + { + Runs = runs?.ToImmutableList() ?? throw new ArgumentNullException("runs"); + } + + public static ClassifiedTextElement CreateHyperlink(string text, string tooltip, Action navigationAction) + { + //Requires.NotNull(text, "text"); + //Requires.NotNull(navigationAction, "navigationAction"); + return new ClassifiedTextElement(new ClassifiedTextRun("text", text, navigationAction: navigationAction, tooltip: tooltip)); + } + + public static ClassifiedTextElement CreatePlainText(string text) + { + //Requires.NotNull(text, "text"); + return new ClassifiedTextElement(new ClassifiedTextRun("text", text)); + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/Text/ClassifiedTextRun.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/Text/ClassifiedTextRun.cs new file mode 100644 index 0000000000000..e79d24774d717 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/Text/ClassifiedTextRun.cs @@ -0,0 +1,23 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; + +namespace Roslyn.Text.Adornments; + +internal sealed class ClassifiedTextRun( + string classificationTypeName, + string text, + ClassifiedTextRunStyle style = ClassifiedTextRunStyle.Plain, + string? markerTagType = null, + Action? navigationAction = null, + string? tooltip = null) +{ + public string ClassificationTypeName { get; } = classificationTypeName ?? throw new ArgumentNullException(nameof(classificationTypeName)); + public string Text { get; } = text ?? throw new ArgumentNullException(nameof(text)); + public string? MarkerTagType { get; } = markerTagType; + public ClassifiedTextRunStyle Style { get; } = style; + public string? Tooltip { get; } = tooltip; + public Action? NavigationAction { get; } = navigationAction; +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/Text/ClassifiedTextRunStyle.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/Text/ClassifiedTextRunStyle.cs new file mode 100644 index 0000000000000..7e03f2b16f477 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/Text/ClassifiedTextRunStyle.cs @@ -0,0 +1,55 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; + +namespace Roslyn.Text.Adornments +{ + // + // Summary: + // The text style for a Microsoft.VisualStudio.Text.Adornments.ClassifiedTextRun. + // + // Remarks: + // By default, text is displayed using tooltip preferences, but colorized using + // text editor colors in order to make tooltips that look visually like UI, but + // match the semantic colorization of the code. + [Flags] + internal enum ClassifiedTextRunStyle + { + // + // Summary: + // Plain text. + Plain = 0x0, + // + // Summary: + // Bolded text. + Bold = 0x1, + // + // Summary: + // Italic text. + Italic = 0x2, + // + // Summary: + // Underlined text. + Underline = 0x4, + // + // Summary: + // Use the font specified by the classification. + // + // Remarks: + // If applied, the classification's code font is used instead of the default tooltip + // font. + UseClassificationFont = 0x8, + // + // Summary: + // Use the style specified by the classification. + // + // Remarks: + // If applied, the classification's bold, italic, and underline settings are used + // instead of the default tooltip style. Note that additional styles can be layered + // on top of the classification's style by adding Microsoft.VisualStudio.Text.Adornments.ClassifiedTextRunStyle.Bold, + // Microsoft.VisualStudio.Text.Adornments.ClassifiedTextRunStyle.Italic, or Microsoft.VisualStudio.Text.Adornments.ClassifiedTextRunStyle.Underline. + UseClassificationStyle = 0x10 + } +} \ No newline at end of file diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/Text/ContainerElement.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/Text/ContainerElement.cs new file mode 100644 index 0000000000000..c9f140776da0c --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/Text/ContainerElement.cs @@ -0,0 +1,31 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Collections.Immutable; + +namespace Roslyn.Text.Adornments +{ + internal sealed class ContainerElement + { + public IEnumerable Elements { get; } + + public ContainerElementStyle Style { get; } + + public ContainerElement(ContainerElementStyle style, IEnumerable elements) + { + Style = style; + Elements = elements?.ToImmutableList() ?? throw new ArgumentNullException("elements"); + } + + public ContainerElement(ContainerElementStyle style, params object[] elements) + { + Style = style; + Elements = elements?.ToImmutableList() ?? throw new ArgumentNullException("elements"); + } + } +} \ No newline at end of file diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/Text/ContainerElementStyle.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/Text/ContainerElementStyle.cs new file mode 100644 index 0000000000000..441741d13ab6a --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/Text/ContainerElementStyle.cs @@ -0,0 +1,28 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; + +namespace Roslyn.Text.Adornments +{ + // + // Summary: + // The layout style for a Microsoft.VisualStudio.Text.Adornments.ContainerElement. + [Flags] + internal enum ContainerElementStyle + { + // + // Summary: + // Contents are end-to-end, and wrapped when the control becomes too wide. + Wrapped = 0x0, + // + // Summary: + // Contents are stacked vertically. + Stacked = 0x1, + // + // Summary: + // Additional padding above and below content. + VerticalPadding = 0x2 + } +} \ No newline at end of file diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/Text/ImageElement.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/Text/ImageElement.cs new file mode 100644 index 0000000000000..bbd213a10f8bd --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/Text/ImageElement.cs @@ -0,0 +1,25 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using Roslyn.Core.Imaging; + +namespace Roslyn.Text.Adornments; + +internal sealed class ImageElement +{ + public static readonly ImageElement Empty = new(default, string.Empty); + + public ImageId ImageId { get; } + public string? AutomationName { get; } + + public ImageElement(ImageId imageId) : this(imageId, null) + { + } + + public ImageElement(ImageId imageId, string? automationName) + { + ImageId = imageId; + AutomationName = automationName; + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/Text/ImageId.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/Text/ImageId.cs new file mode 100644 index 0000000000000..9b226ebb2938a --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/Text/ImageId.cs @@ -0,0 +1,104 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Globalization; + +namespace Roslyn.Core.Imaging +{ + // + // Summary: + // Unique identifier for Visual Studio image asset. + // + // Remarks: + // On Windows systems, Microsoft.VisualStudio.Core.Imaging.ImageId can be converted + // to and from various other image representations via the ImageIdExtensions extension + // methods. + internal struct ImageId : IEquatable + { + // + // Summary: + // The Microsoft.VisualStudio.Core.Imaging.ImageId.Guid identifying the group to + // which this image belongs. + public readonly Guid Guid; + + // + // Summary: + // The System.Int32 identifying the particular image from the group that this id + // maps to. + public readonly int Id; + + // + // Summary: + // Creates a new instance of ImageId. + // + // Parameters: + // guid: + // The Microsoft.VisualStudio.Core.Imaging.ImageId.Guid identifying the group to + // which this image belongs. + // + // id: + // The System.Int32 identifying the particular image from the group that this id + // maps to. + public ImageId(Guid guid, int id) + { + Guid = guid; + Id = id; + } + + public override string ToString() + { + return ToString(CultureInfo.InvariantCulture); + } + + public string ToString(IFormatProvider provider) + { + var guid = Guid; + var arg = guid.ToString("D", provider); + var id = Id; + return string.Format(provider, "{0} : {1}", arg, id.ToString(provider)); + } + + bool IEquatable.Equals(ImageId other) + { + var id = Id; + if (id.Equals(other.Id)) + { + var guid = Guid; + return guid.Equals(other.Guid); + } + + return false; + } + + public override bool Equals(object other) + { + if (other is ImageId) + { + var other2 = (ImageId)other; + return ((IEquatable)this).Equals(other2); + } + + return false; + } + + public static bool operator ==(ImageId left, ImageId right) + { + return left.Equals(right); + } + + public static bool operator !=(ImageId left, ImageId right) + { + return !(left == right); + } + + public override int GetHashCode() + { + var guid = Guid; + var hashCode = guid.GetHashCode(); + var id = Id; + return hashCode ^ id.GetHashCode(); + } + } +} \ No newline at end of file diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/VSFoldingRangeSetting.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSFoldingRangeSetting.cs new file mode 100644 index 0000000000000..a7d46e257f83e --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSFoldingRangeSetting.cs @@ -0,0 +1,26 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class used to extend to add internal capabilities. + /// + internal class VSFoldingRangeSetting : FoldingRangeSetting + { + /// + /// Gets or sets a value indicating whether if client only supports entire line folding only. + /// + [DataMember(Name = "_vs_refreshSupport")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool RefreshSupport + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalClientCapabilities.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalClientCapabilities.cs new file mode 100644 index 0000000000000..476b1bbc3238e --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalClientCapabilities.cs @@ -0,0 +1,73 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Extension class for ClientCapabilities with fields specific to Visual Studio. + /// + [DataContract] + internal class VSInternalClientCapabilities : ClientCapabilities + { + /// + /// Gets or sets a value indicating whether client supports Visual Studio extensions. + /// + [DataMember(Name = "_vs_supportsVisualStudioExtensions")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool SupportsVisualStudioExtensions + { + get; + set; + } + + /// + /// Gets or sets a value indicating what level of snippet support is available from Visual Studio Client. + /// v1.0 refers to only default tab stop support i.e. support for $0 which manipualtes the cursor position. + /// + [DataMember(Name = "_vs_supportedSnippetVersion")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public VSInternalSnippetSupportLevel? SupportedSnippetVersion + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether client supports omitting document text in textDocument/didOpen notifications. + /// + [DataMember(Name = "_vs_supportsNotIncludingTextInTextDocumentDidOpen")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool SupportsNotIncludingTextInTextDocumentDidOpen + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether the client supports string based response kinds + /// instead of enum based response kinds. + /// + [DataMember(Name = "_vs_supportsIconExtensions")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool SupportsIconExtensions + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether the client provides support for diagnostic pull requests. + /// + [DataMember(Name = "_vs_supportsDiagnosticRequests")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool SupportsDiagnosticRequests + { + get; + set; + } + } +} \ No newline at end of file diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalClipboardContent.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalClipboardContent.cs new file mode 100644 index 0000000000000..eb25ceed3c90f --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalClipboardContent.cs @@ -0,0 +1,35 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// Class which represents content to be sent to the clipboard. + /// + [DataContract] + internal class VSInternalClipboardContent + { + /// + /// Gets or sets a string that describes clipboard format types, for example, "text/plain". + /// + [DataMember(Name = "_vs_mime", IsRequired = true)] + public string MimeType + { + get; + set; + } + + /// + /// Gets or sets the content of the clipboard. + /// + [DataMember(Name = "_vs_content", IsRequired = true)] + public string Content + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalCodeAction.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalCodeAction.cs new file mode 100644 index 0000000000000..2daba780549e6 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalCodeAction.cs @@ -0,0 +1,72 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System; + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class used to extend to add the data field for codeAction/_ms_resolve support. + /// + [DataContract] + internal class VSInternalCodeAction : CodeAction + { + /// + /// Gets or sets the group this CodeAction belongs to. + /// + [DataMember(Name = "_vs_group")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? Group + { + get; + set; + } + + /// + /// Gets or sets the priority level of the code action. + /// + [DataMember(Name = "_vs_priority")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public VSInternalPriorityLevel? Priority + { + get; + set; + } + + /// + /// Gets or sets the range of the span this action is applicable to. + /// + [DataMember(Name = "_vs_applicableRange")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public Range? ApplicableRange + { + get; + set; + } + + /// + /// Gets or sets the children of this action. + /// + [DataMember(Name = "_vs_children")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public VSInternalCodeAction[]? Children + { + get; + set; + } + + /// + /// Gets or sets the telemetry id of this action. + /// + [DataMember(Name = "_vs_telemetryId")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public Guid? TelemetryId + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalCodeActionContext.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalCodeActionContext.cs new file mode 100644 index 0000000000000..93a48ed25cbc6 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalCodeActionContext.cs @@ -0,0 +1,28 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing the parameters sent from the client to the server for the textDocument/codeAction request. + /// + [DataContract] + internal class VSInternalCodeActionContext : CodeActionContext + { + /// + /// Gets or sets the range of the current selection in the document for which the command was invoked. + /// If there is no selection this would be a Zero-length range for the caret position. + /// + [DataMember(Name = "_vs_selectionRange")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public Range? SelectionRange + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalCodeActionGroup.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalCodeActionGroup.cs new file mode 100644 index 0000000000000..109f98d7b85fb --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalCodeActionGroup.cs @@ -0,0 +1,47 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + /// + /// Enum which represents the various kinds of code actions. + /// + internal static class VSInternalCodeActionGroup + { + /// + /// Code action is a quick fix. + /// + public const string QuickFix = "quickfix"; + + /// + /// Code action is a refactor. + /// + public const string Refactor = "refactor"; + + /// + /// Code action is a refactor for extracting methods, functions, variables, etc. + /// + public const string RefactorExtract = "refactor.extract"; + + /// + /// Code action is a refactor for inlining methods, constants, etc. + /// + public const string RefactorInline = "refactor.inline"; + + /// + /// Code action is a refactor for rewrite actions, such as making methods static. + /// + public const string RefactorRewrite = "refactor.rewrite"; + + /// + /// Code action applies to the entire file. + /// + public const string Source = "source"; + + /// + /// Code actions is for organizing imports. + /// + public const string SourceOrganizeImports = "source.organizeImports"; + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalCodeActionGroupSetting.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalCodeActionGroupSetting.cs new file mode 100644 index 0000000000000..8bd608dbd27fe --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalCodeActionGroupSetting.cs @@ -0,0 +1,25 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// Class containing the set of code action default groups that are supported. + /// + [DataContract] + internal class VSInternalCodeActionGroupSetting + { + /// + /// Gets or sets the code actions default group names the client supports. + /// + [DataMember(Name = "_vs_valueSet")] + public string[] ValueSet + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalCodeActionLiteralSetting.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalCodeActionLiteralSetting.cs new file mode 100644 index 0000000000000..58da67255fd31 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalCodeActionLiteralSetting.cs @@ -0,0 +1,27 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing support for code action literals. + /// + [DataContract] + internal class VSInternalCodeActionLiteralSetting : CodeActionLiteralSetting + { + /// + /// Gets or sets a value indicating what code action default groups are supported. + /// + [DataMember(Name = "_vs_codeActionGroup")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public VSInternalCodeActionGroupSetting? CodeActionGroup + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalCommitCharacter.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalCommitCharacter.cs new file mode 100644 index 0000000000000..9e9b8ab8cebf2 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalCommitCharacter.cs @@ -0,0 +1,27 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// Extension class for CompletionItem with fields specific to Visual Studio functionalities. + /// + [DataContract] + internal class VSInternalCommitCharacter + { + /// + /// Gets or sets the commit character. + /// + [DataMember(Name = "_vs_character")] + public string Character { get; set; } + + /// + /// Gets or sets a value indicating whether the commit character should be inserted or not. + /// + [DataMember(Name = "_vs_insert")] + public bool Insert { get; set; } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalCompletionContext.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalCompletionContext.cs new file mode 100644 index 0000000000000..fc0b92a2fe216 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalCompletionContext.cs @@ -0,0 +1,32 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.ComponentModel; + using System.Diagnostics.CodeAnalysis; + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Extension class for with properties specific to Visual Studio. + /// + [DataContract] + internal class VSInternalCompletionContext : CompletionContext + { + /// + /// Gets or sets the indicating how the completion was triggered. + /// + [DataMember(Name = "_vs_invokeKind")] + [SuppressMessage("Microsoft.StyleCop.CSharp.LayoutRules", "SA1513:ClosingCurlyBracketMustBeFollowedByBlankLine", Justification = "There are no issues with this code")] + [SuppressMessage("Microsoft.StyleCop.CSharp.LayoutRules", "SA1500:BracesForMultiLineStatementsShouldNotShareLine", Justification = "There are no issues with this code")] + [DefaultValue(VSInternalCompletionInvokeKind.Explicit)] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public VSInternalCompletionInvokeKind InvokeKind + { + get; + set; + } = VSInternalCompletionInvokeKind.Explicit; + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalCompletionInvokeKind.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalCompletionInvokeKind.cs new file mode 100644 index 0000000000000..a8bd492e3ebd2 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalCompletionInvokeKind.cs @@ -0,0 +1,31 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// Provides value for which specifies + /// how completion was invoked. + /// + [DataContract] + internal enum VSInternalCompletionInvokeKind + { + /// + /// Completion was triggered by explicit user's gesture (e.g. Ctrl+Space, Ctr+J) or via API. + /// + Explicit = 0, + + /// + /// Completion was triggered by typing an identifier. + /// + Typing = 1, + + /// + /// Completion was triggered by deletion (e.g. Backspace or Delete keys). + /// + Deletion = 2, + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalCompletionItem.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalCompletionItem.cs new file mode 100644 index 0000000000000..7edcd8403e1ef --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalCompletionItem.cs @@ -0,0 +1,56 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Roslyn.Text.Adornments; + using Newtonsoft.Json; + + /// + /// Extension class for CompletionItem with fields specific to Visual Studio functionalities. + /// + [DataContract] + internal class VSInternalCompletionItem : CompletionItem + { + internal const string IconSerializedName = "_vs_icon"; + internal const string DescriptionSerializedName = "_vs_description"; + internal const string VsCommitCharactersSerializedName = "_vs_commitCharacters"; + internal const string VsResolveTextEditOnCommitName = "_vs_resolveTextEditOnCommit"; + + /// + /// Gets or sets the icon to show for the completion item. In VS, this is more extensive than the completion kind. + /// + [DataMember(Name = IconSerializedName)] + [JsonConverter(typeof(ImageElementConverter))] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public ImageElement? Icon { get; set; } + + /// + /// Gets or sets the description for a completion item. + /// + [DataMember(Name = DescriptionSerializedName)] + [JsonConverter(typeof(ClassifiedTextElementConverter))] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public ClassifiedTextElement? Description { get; set; } + + /// + /// Gets or sets the set of characters that will commit completion when this is selected. + /// Allows customization of commit behavior. + /// If present, client will use this value instead of . + /// If absent, client will default to . + /// + [DataMember(Name = VsCommitCharactersSerializedName)] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public SumType? VsCommitCharacters { get; set; } + + /// + /// Gets or sets a value indicating whether the client should call to + /// get the value of the text edit to commit. + /// + [DataMember(Name = VsResolveTextEditOnCommitName)] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool VsResolveTextEditOnCommit { get; set; } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalCompletionList.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalCompletionList.cs new file mode 100644 index 0000000000000..e6984d8584a40 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalCompletionList.cs @@ -0,0 +1,66 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// A subclass of the LSP protocol that contains extensions specific to Visual Studio. + /// + [DataContract] + internal class VSInternalCompletionList : CompletionList + { + internal const string SuggestionModeSerializedName = "_vs_suggestionMode"; + internal const string ContinueCharactersSerializedName = "_vs_continueCharacters"; + internal const string DataSerializedName = "_vs_data"; + internal const string CommitCharactersSerializedName = "_vs_commitCharacters"; + + /// + /// Gets or sets a value indicating whether the completion list should use suggestion mode. In suggestion mode items are "soft-selected" by default. + /// + [DataMember(Name = SuggestionModeSerializedName)] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public bool SuggestionMode + { + get; + set; + } + + /// + /// Gets or sets the continue characters for the completion list. + /// + [DataMember(Name = ContinueCharactersSerializedName)] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public SumType[]? ContinueCharacters + { + get; + set; + } + + /// + /// Gets or sets the default used for completion items. + /// + [DataMember(Name = DataSerializedName)] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public object? Data + { + get; + set; + } + + /// + /// Gets or sets the default or used for completion items. + /// + /// + /// If set, overrides . + /// + [DataMember(Name = CommitCharactersSerializedName)] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public SumType? CommitCharacters { get; set; } + + // NOTE: Any changes that are added to this file may need to be reflected in its "optimized" counterparts JsonConverter (OptomizedVSCompletionListJsonConverter). + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalCompletionListSetting.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalCompletionListSetting.cs new file mode 100644 index 0000000000000..4f613cd4e478a --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalCompletionListSetting.cs @@ -0,0 +1,40 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class which represents initialization setting for completion list. + /// + [DataContract] + internal class VSInternalCompletionListSetting + { + /// + /// Gets or sets a value indicating whether completion lists can have Data bags. These data bags get propagated + /// onto underlying completion items unless they have their own data bags. + /// + [DataMember(Name = "_vs_data")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public bool Data + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether completion lists can have VSCommitCharacters. These commit characters get propagated + /// onto underlying valid completion items unless they have their own commit characters. + /// + [DataMember(Name = "_vs_commitCharacters")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public bool CommitCharacters + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalCompletionSetting.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalCompletionSetting.cs new file mode 100644 index 0000000000000..41cd0d069d8cb --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalCompletionSetting.cs @@ -0,0 +1,27 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class which represents initialization setting for VS completion. + /// + [DataContract] + internal class VSInternalCompletionSetting : CompletionSetting + { + /// + /// Gets or sets completion list setting. + /// + [DataMember(Name = "_vs_completionList")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public VSInternalCompletionListSetting? CompletionList + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalContinueCharacterClass.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalContinueCharacterClass.cs new file mode 100644 index 0000000000000..dbfacba1f2cf3 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalContinueCharacterClass.cs @@ -0,0 +1,30 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing a unicode character class for completion continuation. + /// + [DataContract] + internal class VSInternalContinueCharacterClass + { + /// + /// Gets the type value. + /// + [DataMember(Name = "_vs_type")] + [JsonProperty(Required = Required.Always)] + public const string Type = "unicodeClass"; + + /// + /// Gets or sets the unicode class. + /// + [DataMember(Name = "_vs_unicodeClass")] + [JsonProperty(Required = Required.Always)] + public string UnicodeClass { get; set; } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalContinueCharacterRange.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalContinueCharacterRange.cs new file mode 100644 index 0000000000000..46bc21e6ba34f --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalContinueCharacterRange.cs @@ -0,0 +1,37 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing range of characters for completion continuation. + /// + [DataContract] + internal class VSInternalContinueCharacterRange + { + /// + /// Gets the type value. + /// + [DataMember(Name = "_vs_type")] + [JsonProperty(Required = Required.Always)] + public const string Type = "charRange"; + + /// + /// Gets or sets the first completion character of the range. + /// + [DataMember(Name = "_vs_start")] + [JsonProperty(Required = Required.Always)] + public string Start { get; set; } + + /// + /// Gets or sets the last completion character of the range. + /// + [DataMember(Name = "_vs_end")] + [JsonProperty(Required = Required.Always)] + public string End { get; set; } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalContinueCharacterSingle.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalContinueCharacterSingle.cs new file mode 100644 index 0000000000000..233e1e82129e2 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalContinueCharacterSingle.cs @@ -0,0 +1,30 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing single continue character for completion. + /// + [DataContract] + internal class VSInternalContinueCharacterSingle + { + /// + /// Gets the type value. + /// + [DataMember(Name = "_vs_type")] + [JsonProperty(Required = Required.Always)] + public const string Type = "singleChar"; + + /// + /// Gets or sets the completion character. + /// + [DataMember(Name = "_vs_char")] + [JsonProperty(Required = Required.Always)] + public string Character { get; set; } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalDocumentOnAutoInsertOptions.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalDocumentOnAutoInsertOptions.cs new file mode 100644 index 0000000000000..785e96b9decad --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalDocumentOnAutoInsertOptions.cs @@ -0,0 +1,25 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// Class representing the options for on auto insert. + /// + [DataContract] + internal class VSInternalDocumentOnAutoInsertOptions + { + /// + /// Gets or sets trigger characters for on auto insert. + /// + [DataMember(Name = "_vs_triggerCharacters")] + public string[] TriggerCharacters + { + get; + set; + } + } +} \ No newline at end of file diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalDocumentOnAutoInsertParams.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalDocumentOnAutoInsertParams.cs new file mode 100644 index 0000000000000..4fe5d9c1897a7 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalDocumentOnAutoInsertParams.cs @@ -0,0 +1,55 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// Class representing the parameters sent for a textDocument/_ms_onAutoInsert request. + /// + [DataContract] + internal class VSInternalDocumentOnAutoInsertParams : ITextDocumentPositionParams + { + /// + /// Gets or sets the representing the document to format. + /// + [DataMember(Name = "_vs_textDocument")] + public TextDocumentIdentifier TextDocument + { + get; + set; + } + + /// + /// Gets or sets the at which the request was sent. + /// + [DataMember(Name = "_vs_position")] + public Position Position + { + get; + set; + } + + /// + /// Gets or sets the character that was typed. + /// + [DataMember(Name = "_vs_ch")] + public string Character + { + get; + set; + } + + /// + /// Gets or sets the for the request. + /// + [DataMember(Name = "_vs_options")] + public FormattingOptions Options + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalDocumentOnAutoInsertResponseItem.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalDocumentOnAutoInsertResponseItem.cs new file mode 100644 index 0000000000000..d9b52602383c3 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalDocumentOnAutoInsertResponseItem.cs @@ -0,0 +1,43 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.ComponentModel; + using System.Diagnostics.CodeAnalysis; + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing the response of an AutoInsert response. + /// + [DataContract] + internal class VSInternalDocumentOnAutoInsertResponseItem + { + /// + /// Gets or sets the insert text format of the primary text edit. for supported formats. + /// + [DataMember(Name = "_vs_textEditFormat")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + [DefaultValue(InsertTextFormat.Plaintext)] + [SuppressMessage("Microsoft.StyleCop.CSharp.LayoutRules", "SA1513:ClosingCurlyBracketMustBeFollowedByBlankLine", Justification = "There are no issues with this code")] + [SuppressMessage("Microsoft.StyleCop.CSharp.LayoutRules", "SA1500:BracesForMultiLineStatementsShouldNotShareLine", Justification = "There are no issues with this code")] + public InsertTextFormat TextEditFormat + { + get; + set; + } = InsertTextFormat.Plaintext; + + /// + /// Gets or sets the text edit. + /// + [DataMember(Name = "_vs_textEdit")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public TextEdit TextEdit + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalDocumentSpellCheckableParams.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalDocumentSpellCheckableParams.cs new file mode 100644 index 0000000000000..2bee314d31fa6 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalDocumentSpellCheckableParams.cs @@ -0,0 +1,30 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System; + using System.Collections.Generic; + using System.Runtime.Serialization; + using System.Text; + using Newtonsoft.Json; + + /// + /// Parameter for tD/_vs_spellCheckableRanges. + /// + [DataContract] + internal class VSInternalDocumentSpellCheckableParams : VSInternalStreamingParams, IPartialResultParams + { + /// + /// Gets or sets an optional token that a server can use to report partial results (e.g. streaming) to the client. + /// + [DataMember(Name = Methods.PartialResultTokenName)] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public IProgress? PartialResultToken + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalExecuteCommandClientCapabilities.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalExecuteCommandClientCapabilities.cs new file mode 100644 index 0000000000000..ba2abd3e80a02 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalExecuteCommandClientCapabilities.cs @@ -0,0 +1,41 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// Class representing settings for well-known Visual Studio's code action command. + /// + [DataContract] + internal class VSInternalExecuteCommandClientCapabilities : DynamicRegistrationSetting + { + /// + /// Initializes a new instance of the class. + /// + public VSInternalExecuteCommandClientCapabilities() + { + } + + /// + /// Initializes a new instance of the class. + /// + /// Value indicating whether the setting can be dynamically registered. + public VSInternalExecuteCommandClientCapabilities(bool value) + : base(value) + { + } + + /// + /// Gets or sets a set of well-known commands name the given VS-LSP client supports. + /// + [DataMember(Name = "_vs_supportedCommands")] + public string[] SupportedCommands + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalHover.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalHover.cs new file mode 100644 index 0000000000000..ea9a5ec9094f6 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalHover.cs @@ -0,0 +1,29 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Extension to Hover which adds additional data for colorization. + /// + internal class VSInternalHover : Hover + { + /// + /// Gets or sets the value which represents the hover content as a tree + /// of objects from the Microsoft.VisualStudio.Text.Adornments namespace, + /// such as ContainerElements, ClassifiedTextElements and ClassifiedTextRuns. + /// + [DataMember(Name = "_vs_rawContent")] + [JsonConverter(typeof(ObjectContentConverter))] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public object? RawContent + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalIconMapping.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalIconMapping.cs new file mode 100644 index 0000000000000..aaf0fe7a8517a --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalIconMapping.cs @@ -0,0 +1,132 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System; + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Response class when asking server to resolve the rendering information of a string kind. + /// + [DataContract] + internal class VSInternalIconMapping : IEquatable + { + /// + /// Gets or sets the ImageElements for a certain kind. + /// + [DataMember(Name = "_vs_images")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public VSImageId[]? Images + { + get; + set; + } + + /// + /// Gets or sets the tags for a certain kind. To be used in the absence of ImageIds. + /// + [DataMember(Name = "_vs_tags")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string[]? Tags + { + get; + set; + } + + /// + public override bool Equals(object? obj) + { + return this.Equals(obj as VSInternalIconMapping); + } + + /// + public bool Equals(VSInternalIconMapping? other) + { + if (other == null) + { + return false; + } + + return CheckImagesAreEqual(this.Images, other.Images) && CheckTagsAreEqual(this.Tags, other.Tags); + } + + /// + public override int GetHashCode() + { + var hashCode = 1825600323; + + if (this.Images != null) + { + for (var i = 0; i < this.Images.Length; i++) + { + hashCode = (hashCode * -1521134295) + this.Images[i].Guid.GetHashCode(); + hashCode = (hashCode * -1521134295) + this.Images[i].Id.GetHashCode(); + } + } + + if (this.Tags != null) + { + for (var i = 0; i < this.Tags.Length; i++) + { + hashCode = (hashCode * -1521134295) + StringComparer.Ordinal.GetHashCode(this.Tags[i]); + } + } + + return hashCode; + } + + private static bool CheckImagesAreEqual(VSImageId[]? current, VSImageId[]? other) + { + if (current == null ^ other == null) + { + return false; + } + + if (current != null && + other != null && + current.Length == other.Length) + { + for (var i = 0; i < current.Length; i++) + { + if (current[i].Id != other[i].Id) + { + return false; + } + + if (current[i].Guid != other[i].Guid) + { + return false; + } + } + } + + return true; + } + + private static bool CheckTagsAreEqual(string[]? current, string[]? other) + { + if (current == null ^ other == null) + { + return false; + } + + if (current != null && + other != null && + current.Length == other.Length) + { + for (var i = 0; i < current.Length; i++) + { + if (!string.Equals(current[i], other[i], StringComparison.Ordinal)) + { + return false; + } + } + } + + return true; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalInlineCompletionContext.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalInlineCompletionContext.cs new file mode 100644 index 0000000000000..284ffa5d505ae --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalInlineCompletionContext.cs @@ -0,0 +1,33 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.ComponentModel; + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Context for inline completion request. + /// See https://github.com/microsoft/vscode/blob/075ba020e8493f40dba89891b1a08453f2c067e9/src/vscode-dts/vscode.proposed.inlineCompletions.d.ts#L27. + /// + internal class VSInternalInlineCompletionContext + { + /// + /// Gets or sets how completion was triggered. + /// + [DataMember(Name = "_vs_triggerKind")] + [JsonProperty(Required = Required.Always)] + public VSInternalInlineCompletionTriggerKind TriggerKind { get; set; } = VSInternalInlineCompletionTriggerKind.Explicit; + + /// + /// Gets or sets information about the currently selected item in the autocomplete widget, if visible. + /// + /// See https://github.com/microsoft/vscode/blob/075ba020e8493f40dba89891b1a08453f2c067e9/src/vscode-dts/vscode.proposed.inlineCompletions.d.ts#L45. + /// + [DataMember(Name = "_vs_selectedCompletionInfo")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public VSInternalSelectedCompletionInfo? SelectedCompletionInfo { get; set; } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalInlineCompletionItem.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalInlineCompletionItem.cs new file mode 100644 index 0000000000000..73fb5c5285852 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalInlineCompletionItem.cs @@ -0,0 +1,48 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.ComponentModel; + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// A single inline completion item response. + /// + /// See https://github.com/microsoft/vscode/blob/075ba020e8493f40dba89891b1a08453f2c067e9/src/vscode-dts/vscode.proposed.inlineCompletions.d.ts#L78. + /// + internal class VSInternalInlineCompletionItem + { + /// + /// Gets or sets the text to replace the range with. + /// + [DataMember(Name = "_vs_text")] + [JsonProperty(Required = Required.Always)] + public string Text { get; set; } + + /// + /// Gets or sets the range to replace. + /// + /// See https://github.com/microsoft/vscode/blob/075ba020e8493f40dba89891b1a08453f2c067e9/src/vscode-dts/vscode.proposed.inlineCompletions.d.ts#L94. + /// + [DataMember(Name = "_vs_range")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public Range? Range { get; set; } + + /// + /// Gets or sets the command that is executed after inserting this completion item. + /// + [DataMember(Name = "_vs_command")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public Command? Command { get; set; } + + /// + /// Gets or sets the format of the insert text. + /// + [DataMember(Name = "_vs_insertTextFormat")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public InsertTextFormat? TextFormat { get; set; } = InsertTextFormat.Plaintext; + } +} \ No newline at end of file diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalInlineCompletionList.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalInlineCompletionList.cs new file mode 100644 index 0000000000000..62f4b20ba0d07 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalInlineCompletionList.cs @@ -0,0 +1,24 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Response for an inline completions request. + /// + /// See https://github.com/microsoft/vscode/blob/075ba020e8493f40dba89891b1a08453f2c067e9/src/vscode-dts/vscode.proposed.inlineCompletions.d.ts#L72. + /// + internal class VSInternalInlineCompletionList + { + /// + /// Gets or sets the inline completion items. + /// + [DataMember(Name = "_vs_items")] + [JsonProperty(Required = Required.Always)] + public VSInternalInlineCompletionItem[] Items { get; set; } + } +} \ No newline at end of file diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalInlineCompletionOptions.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalInlineCompletionOptions.cs new file mode 100644 index 0000000000000..b73012d5900e8 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalInlineCompletionOptions.cs @@ -0,0 +1,26 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using System.Text.RegularExpressions; + + using Newtonsoft.Json; + + /// + /// The options for inline completion. + /// + [DataContract] + internal class VSInternalInlineCompletionOptions + { + /// + /// Gets or sets a regex used by the client to determine when to ask the server for snippets. + /// + [DataMember(Name = "_vs_pattern")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + [JsonConverter(typeof(RegexConverter))] + public Regex Pattern { get; set; } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalInlineCompletionRequest.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalInlineCompletionRequest.cs new file mode 100644 index 0000000000000..fe3840400b762 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalInlineCompletionRequest.cs @@ -0,0 +1,44 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// The request data for an inline completions request. + /// + /// See https://github.com/microsoft/vscode/blob/075ba020e8493f40dba89891b1a08453f2c067e9/src/vscode-dts/vscode.proposed.inlineCompletions.d.ts#L24. + /// + internal class VSInternalInlineCompletionRequest : ITextDocumentParams + { + /// + /// Gets or sets the text document. + /// + [DataMember(Name = "_vs_textDocument")] + [JsonProperty(Required = Required.Always)] + public TextDocumentIdentifier TextDocument { get; set; } + + /// + /// Gets or sets the position where inline completions are being requested. + /// + [DataMember(Name = "_vs_position")] + [JsonProperty(Required = Required.Always)] + public Position Position { get; set; } + + /// + /// Gets or sets the context for the inline completions request. + /// + [DataMember(Name = "_vs_context")] + [JsonProperty(Required = Required.Always)] + public VSInternalInlineCompletionContext Context { get; set; } + + /// + /// Gets or sets the for the request. + /// + [DataMember(Name = "_vs_options")] + public FormattingOptions Options { get; set; } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalInlineCompletionTriggerKind.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalInlineCompletionTriggerKind.cs new file mode 100644 index 0000000000000..476a038b93d7f --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalInlineCompletionTriggerKind.cs @@ -0,0 +1,26 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// How the inline completion request was triggered. + /// See https://github.com/microsoft/vscode/blob/075ba020e8493f40dba89891b1a08453f2c067e9/src/vscode-dts/vscode.proposed.inlineCompletions.d.ts#L58. + /// + [DataContract] + internal enum VSInternalInlineCompletionTriggerKind + { + /// + /// Inline completions were triggered automatically while editing. + /// + Automatic = 0, + + /// + /// Completion was triggered explicitly by a user gesture. + /// + Explicit = 1, + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalItemOrigin.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalItemOrigin.cs new file mode 100644 index 0000000000000..fe79f9bdd6561 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalItemOrigin.cs @@ -0,0 +1,47 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + /// + /// Enum which represents the origin of an item. + /// + internal enum VSInternalItemOrigin + { + /// + /// The entry is contained in exact code. + /// + Exact = 0, + + /// + /// The entry is contained in metadata generated from exact information. + /// + ExactMetadata = 1000, + + /// + /// The entry is contained in indexed code. + /// + Indexed = 2000, + + /// + /// The entry is contained in indexed code in the repo where the request originated. + /// + IndexedInRepo = 2100, + + /// + /// The entry is contained in indexed code in the same organization but different repo where the request originated. + /// + IndexedInOrganization = 2200, + + /// + /// The entry is contained in indexed code in a different organization and repo where request originated. + /// + IndexedInThirdParty = 2300, + + /// + /// The entry is of lesser quality than all other choices. + /// + Other = int.MaxValue, + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalKindAndModifier.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalKindAndModifier.cs new file mode 100644 index 0000000000000..6167f1ff419e3 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalKindAndModifier.cs @@ -0,0 +1,115 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System; + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class that contains the base kind and modifiers used to describe a response item. + /// + [DataContract] + internal class VSInternalKindAndModifier : IEquatable + { + /// + /// Gets or sets the ImageIds for a certain kind. + /// + [DataMember(Name = "_vs_kind")] + public string Kind + { + get; + set; + } + + /// + /// Gets or sets the modifier of the kind. + /// + [DataMember(Name = "_vs_modifier")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string[]? Modifier + { + get; + set; + } + + public static bool operator ==(VSInternalKindAndModifier? value1, VSInternalKindAndModifier? value2) + { + if (ReferenceEquals(value1, value2)) + { + return true; + } + + // Is null? + if (ReferenceEquals(null, value2)) + { + return false; + } + + return value1?.Equals(value2) ?? false; + } + + public static bool operator !=(VSInternalKindAndModifier? value1, VSInternalKindAndModifier? value2) + { + return !(value1 == value2); + } + + /// + public override bool Equals(object obj) + { + return this.Equals(obj as VSInternalKindAndModifier); + } + + /// + public bool Equals(VSInternalKindAndModifier? other) + { + return other != null && + string.Equals(this.Kind, other.Kind, StringComparison.Ordinal) && + this.CheckModifierEquality(other.Modifier); + } + + /// + public override int GetHashCode() + { + var hashCode = 1850642763; + hashCode = (hashCode * -1521134295) + (this.Kind == null ? 0 : StringComparer.Ordinal.GetHashCode(this.Kind)); + if (this.Modifier != null) + { + for (var i = 0; i < this.Modifier.Length; i++) + { + if (this.Modifier[i] != null) + { + hashCode = (hashCode * -1521134295) + StringComparer.Ordinal.GetHashCode(this.Modifier[i]); + } + } + } + + return hashCode; + } + + private bool CheckModifierEquality(string[]? modifiers) + { + if (modifiers == null ^ this.Modifier == null) + { + return false; + } + + if (modifiers != null && + this.Modifier != null && + modifiers.Length == this.Modifier.Length) + { + for (var i = 0; i < modifiers.Length; i++) + { + if (!string.Equals(modifiers[i], this.Modifier[i], StringComparison.Ordinal)) + { + return false; + } + } + } + + return true; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalKnownKindModifiers.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalKnownKindModifiers.cs new file mode 100644 index 0000000000000..336ebbd50976e --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalKnownKindModifiers.cs @@ -0,0 +1,75 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Collections.Generic; + + /// + /// Known VS response kind modifiers. + /// + internal static class VSInternalKnownKindModifiers + { + /// + /// Response kind modifier string for 'public'. + /// + public const string Public = "public"; + + /// + /// Response kind modifier string for 'private'. + /// + public const string Private = "private"; + + /// + /// Response kind modifier string for 'protected'. + /// + public const string Protected = "protected"; + + /// + /// Response kind modifier string for 'internal'. + /// + public const string Internal = "internal"; + + /// + /// Response kind modifier string for 'sealed'. + /// + public const string Sealed = "sealed"; + + /// + /// Response kind modifier string for 'shortcut'. + /// + public const string Shortcut = "shortcut"; + + /// + /// Response kind modifier string for 'snippet'. + /// + public const string Snippet = "snippet"; + + /// + /// Response kind modifier string for 'friend'. + /// + public const string Friend = "friend"; + + /// + /// Response kind modifier string for 'declaration'. + /// + public const string Declaration = "declaration"; + + /// + /// Collection of known response kind modifier strings. + /// + public static readonly IReadOnlyCollection AllModifiers = new[] + { + Public, + Private, + Protected, + Internal, + Sealed, + Shortcut, + Snippet, + Friend, + Declaration, + }; + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalKnownKinds.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalKnownKinds.cs new file mode 100644 index 0000000000000..8e629a148331b --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalKnownKinds.cs @@ -0,0 +1,267 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Collections.Generic; + + /// + /// Known VS response kinds. + /// + internal static class VSInternalKnownKinds + { + /// + /// Response kind string for 'text'. + /// + public const string Text = "text"; + + /// + /// Response kind string for 'method'. + /// + public const string Method = "method"; + + /// + /// Response kind string for 'function'. + /// + public const string Function = "function"; + + /// + /// Response kind string for 'constructor'. + /// + public const string Constructor = "constructor"; + + /// + /// Response kind string for 'field'. + /// + public const string Field = "field"; + + /// + /// Response kind string for 'variable'. + /// + public const string Variable = "variable"; + + /// + /// Response kind string for 'class'. + /// + public const string Class = "class"; + + /// + /// Response kind string for 'interface'. + /// + public const string Interface = "interface"; + + /// + /// Response kind string for 'module'. + /// + public const string Module = "module"; + + /// + /// Response kind string for 'property'. + /// + public const string Property = "property"; + + /// + /// Response kind string for 'unit'. + /// + public const string Unit = "unit"; + + /// + /// Response kind string for 'value'. + /// + public const string Value = "value"; + + /// + /// Response kind string for 'enum'. + /// + public const string Enum = "enum"; + + /// + /// Response kind string for 'keyword'. + /// + public const string Keyword = "keyword"; + + /// + /// Response kind string for 'snippet'. + /// + public const string Snippet = "snippet"; + + /// + /// Response kind string for 'color'. + /// + public const string Color = "color"; + + /// + /// Response kind string for 'file'. + /// + public const string File = "file"; + + /// + /// Response kind string for 'reference'. + /// + public const string Reference = "reference"; + + /// + /// Response kind string for 'folder'. + /// + public const string Folder = "folder"; + + /// + /// Response kind string for 'enumMember'. + /// + public const string EnumMember = "enumMember"; + + /// + /// Response kind string for 'constant'. + /// + public const string Constant = "constant"; + + /// + /// Response kind string for 'struct'. + /// + public const string Struct = "struct"; + + /// + /// Response kind string for 'event'. + /// + public const string Event = "event"; + + /// + /// Response kind string for 'operator'. + /// + public const string Operator = "operator"; + + /// + /// Response kind string for 'typeParameter'. + /// + public const string TypeParameter = "typeParameter"; + + /// + /// Response kind string for 'namespace'. + /// + public const string Namespace = "namespace"; + + /// + /// Response kind string for 'package'. + /// + public const string Package = "package"; + + /// + /// Response kind string for 'string'. + /// + public const string StringKind = "string"; + + /// + /// Response kind string for 'number'. + /// + public const string Number = "number"; + + /// + /// Response kind string for 'boolean'. + /// + public const string Boolean = "boolean"; + + /// + /// Response kind string for 'array'. + /// + public const string Array = "array"; + + /// + /// Response kind string for 'object'. + /// + public const string ObjectKind = "object"; + + /// + /// Response kind string for 'key'. + /// + public const string Key = "key"; + + /// + /// Response kind string for 'null'. + /// + public const string Null = "null"; + + /// + /// Response kind string for 'macro'. + /// + public const string Macro = "macro"; + + /// + /// Response kind string for 'template'. + /// + public const string Template = "template"; + + /// + /// Response kind string for 'typedef'. + /// + public const string Typedef = "typedef"; + + /// + /// Response kind string for 'union'. + /// + public const string Union = "union"; + + /// + /// Response kind string for 'delegate'. + /// + public const string Delegate = "delegate"; + + /// + /// Response kind string for 'tag'. + /// + public const string Tag = "tag"; + + /// + /// Response kind string for 'attribute'. + /// + public const string Attribute = "attribute"; + + /// + /// Collection of response kind strings. + /// + public static readonly IReadOnlyCollection AllKinds = new[] + { + Text, + Method, + Function, + Constructor, + Field, + Variable, + Class, + Interface, + Module, + Property, + Unit, + Value, + Enum, + Keyword, + Snippet, + Color, + File, + Reference, + Folder, + EnumMember, + Constant, + Struct, + Event, + Operator, + TypeParameter, + Namespace, + Package, + StringKind, + Number, + Boolean, + Array, + ObjectKind, + Key, + Null, + Macro, + Template, + Typedef, + Union, + Delegate, + Tag, + Attribute, + }; + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalLocation.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalLocation.cs new file mode 100644 index 0000000000000..4c62c6fb74ec5 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalLocation.cs @@ -0,0 +1,46 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System; + using System.Runtime.Serialization; + using Roslyn.Text.Adornments; + using Newtonsoft.Json; + + /// + /// Extension class for . Used to relay reference text information with colorization. + /// + [DataContract] + internal class VSInternalLocation : VSLocation + { + private object? textValue = null; + + /// + /// Gets or sets the text value for a location reference. Must be of type or or or . + /// + [DataMember(Name = "_vs_text")] + [JsonConverter(typeof(ObjectContentConverter))] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public object? Text + { + get + { + return this.textValue; + } + + set + { + if (value is ImageElement || value is ContainerElement || value is ClassifiedTextElement || value is string) + { + this.textValue = value; + } + else + { + throw new InvalidOperationException($"{value?.GetType()} is an invalid type."); + } + } + } + } +} \ No newline at end of file diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalMethods.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalMethods.cs new file mode 100644 index 0000000000000..8f5fc764f2de3 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalMethods.cs @@ -0,0 +1,122 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + /// + /// Class which contains the string values for all Language Server Protocol Visual Studio specific methods. + /// + internal static class VSInternalMethods + { + /// + /// Method name for 'textDocument/foldingRange/_vs_refresh'. + /// + public const string DocumentFoldingRangeRefreshName = "textDocument/foldingRange/_vs_refresh"; + + /// + /// Method name for 'textDocument/_vs_references'. + /// + public const string DocumentReferencesName = "textDocument/_vs_references"; + + /// + /// Method name for 'textDocument/_vs_onAutoInsert'. + /// + public const string OnAutoInsertName = "textDocument/_vs_onAutoInsert"; + + /// + /// Method name for 'textDocument/_vs_iconMappingResolve'. + /// + public const string TextDocumentIconMappingResolveName = "textDocument/_vs_iconMappingResolve"; + + /// + /// Method name for 'textdocument/_vs_diagnostic'. + /// + public const string DocumentPullDiagnosticName = "textdocument/_vs_diagnostic"; + + /// + /// Method name for 'workspace/_vs_diagnostic'. + /// + public const string WorkspacePullDiagnosticName = "workspace/_vs_diagnostic"; + + /// + /// Method name for 'textDocument/_vs_validateBreakableRange'. + /// + public const string TextDocumentValidateBreakableRangeName = "textDocument/_vs_validateBreakableRange"; + + /// + /// Method name for 'textDocument/_vs_inlineCompletion'. + /// + public const string TextDocumentInlineCompletionName = "textDocument/_vs_inlineCompletion"; + + /// + /// Method name for 'textDocument/_vs_spellCheckableRanges'. + /// + public const string TextDocumentSpellCheckableRangesName = "textDocument/_vs_spellCheckableRanges"; + + /// + /// Method name for 'textDocument/_vs_uriPresentation'. + /// + public const string TextDocumentUriPresentationName = "textDocument/_vs_uriPresentation"; + + /// + /// Method name for 'textDocument/_vs_textPresentation'. + /// + public const string TextDocumentTextPresentationName = "textDocument/_vs_textPresentation"; + + /// + /// Method name for 'workspace/_vs_spellCheckableRanges'. + /// + public const string WorkspaceSpellCheckableRangesName = "workspace/_vs_spellCheckableRanges"; + + /// + /// Strongly typed message object for 'textDocument/_vs_onAutoInsert'. + /// + public static readonly LspRequest OnAutoInsert = new LspRequest(OnAutoInsertName); + + /// + /// Strongly typed message object for 'textDocument/_vs_iconMappingResolve'. + /// + public static readonly LspRequest TextDocumentIconMappingResolve = new LspRequest(TextDocumentIconMappingResolveName); + + /// + /// Strongly typed message object for 'textDocument/_vs_diagnostic'. + /// + public static readonly LspRequest DocumentPullDiagnostic = new LspRequest(DocumentPullDiagnosticName); + + /// + /// Strongly typed message object for 'workspace/_vs_diagnostic'. + /// + public static readonly LspRequest WorkspacePullDiagnostic = new LspRequest(WorkspacePullDiagnosticName); + + /// + /// Strongly typed message object for 'textDocument/_vs_validateBreakableRange'. + /// + public static readonly LspRequest TextDocumentValidateBreakableRange = new LspRequest(TextDocumentValidateBreakableRangeName); + + /// + /// Strongly typed message object for 'textDocument/inlineCompletion'. + /// + public static readonly LspRequest TextDocumentInlineCompletion = new LspRequest(TextDocumentInlineCompletionName); + + /// + /// Strongly typed message object for 'textDocument/_vs_uriPresentation'. + /// + public static readonly LspRequest TextDocumentUriPresentation = new LspRequest(TextDocumentUriPresentationName); + + /// + /// Strongly typed message object for 'textDocument/_vs_textPresentation'. + /// + public static readonly LspRequest TextDocumentTextPresentation = new LspRequest(TextDocumentTextPresentationName); + + /// + /// Strongly typed message object for 'textDocument/_vs_spellCheckableRanges'. + /// + public static readonly LspRequest TextDocumentSpellCheckableRanges = new LspRequest(TextDocumentSpellCheckableRangesName); + + /// + /// Strongly typed message object for 'workspace/_vs_spellCheckableRanges'. + /// + public static readonly LspRequest WorkspaceSpellCheckableRanges = new LspRequest(WorkspaceSpellCheckableRangesName); + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalMultipleContextFeatures.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalMultipleContextFeatures.cs new file mode 100644 index 0000000000000..54b2578b76c25 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalMultipleContextFeatures.cs @@ -0,0 +1,27 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Lists the features that support sending off feature requests for all available project contexts instead of the default active one. + /// + [DataContract] + internal class VSInternalMultipleContextFeatures + { + /// + /// Gets or sets a value indicating whether the server provides support for sending diagnostics requests for all project contexts. + /// + [DataMember(Name = "_vs_SupportsMultipleContextDiagnostics")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool SupportsMultipleContextsDiagnostics + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalPriorityLevel.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalPriorityLevel.cs new file mode 100644 index 0000000000000..c13a7e297b072 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalPriorityLevel.cs @@ -0,0 +1,32 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + /// + /// Enum which represents the various reference kinds. + /// + internal enum VSInternalPriorityLevel + { + /// + /// Lowest priority. + /// + Lowest = 0, + + /// + /// Low priority. + /// + Low = 1, + + /// + /// Medium priority. + /// + Normal = 2, + + /// + /// High priority. + /// + High = 3, + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalProjectContext.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalProjectContext.cs new file mode 100644 index 0000000000000..4334c1b2aff26 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalProjectContext.cs @@ -0,0 +1,81 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System; + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class for a project context. + /// + [DataContract] + internal class VSInternalProjectContext : VSProjectContext, IEquatable + { + /// + /// Gets or sets the string context kind of the project context. + /// + [DataMember(Name = "_vs_vsKind")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public VSInternalKindAndModifier? VSKind + { + get; + set; + } + + public static bool operator ==(VSInternalProjectContext? value1, VSInternalProjectContext? value2) + { + if (ReferenceEquals(value1, value2)) + { + return true; + } + + if (value2 is null) + { + return false; + } + + return value1?.Equals(value2) ?? false; + } + + public static bool operator !=(VSInternalProjectContext? value1, VSInternalProjectContext? value2) + { + return !(value1 == value2); + } + + /// + public bool Equals(VSInternalProjectContext other) + { + return base.Equals(other) + && this.VSKind == other.VSKind; + } + + /// + public override bool Equals(VSProjectContext other) + { + return this.Equals((object)other); + } + + /// + public override bool Equals(object obj) + { + if (obj is VSInternalProjectContext other) + { + return this.Equals(other); + } + else + { + return false; + } + } + + /// + public override int GetHashCode() + { + return base.GetHashCode() + ^ (this.VSKind == null ? 13 : this.VSKind.GetHashCode() * 79); + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalReferenceItem.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalReferenceItem.cs new file mode 100644 index 0000000000000..cf551ec93172e --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalReferenceItem.cs @@ -0,0 +1,195 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System; + using System.Runtime.Serialization; + using Roslyn.Text.Adornments; + using Newtonsoft.Json; + + /// + /// Class which represents references information. + /// + [DataContract] + internal class VSInternalReferenceItem + { + private object? definitionTextValue = null; + private object? textValue = null; + + /// + /// Gets or sets the reference id. + /// + [DataMember(Name = "_vs_id", IsRequired = true)] + public int Id + { + get; + set; + } + + /// + /// Gets or sets the reference location. + /// + [DataMember(Name = "_vs_location")] + public Location Location + { + get; + set; + } + + /// + /// Gets or sets the definition Id. + /// + [DataMember(Name = "_vs_definitionId")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public int? DefinitionId + { + get; + set; + } + + /// + /// Gets or sets the definition text displayed as a header when references are grouped by Definition. + /// Must be of type , , and . + /// + /// + /// This element should colorize syntax, but should not contain highlighting, e.g. + /// embedded within should not define . + /// + [DataMember(Name = "_vs_definitionText")] + [JsonConverter(typeof(ObjectContentConverter))] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public object? DefinitionText + { + get + { + return this.definitionTextValue; + } + + set + { + if (value == null || // Null is accepted since for non-definition references + (value is ImageElement || value is ContainerElement || value is ClassifiedTextElement || value is string)) + { + this.definitionTextValue = value; + } + else + { + throw new InvalidOperationException($"{value.GetType()} is an invalid type."); + } + } + } + + /// + /// Gets or sets the resolution status. + /// + [DataMember(Name = "_vs_resolutionStatus")] + public VSInternalResolutionStatusKind ResolutionStatus + { + get; + set; + } + + /// + /// Gets or sets the reference kind. + /// + [DataMember(Name = "_vs_kind")] + public VSInternalReferenceKind[] Kind + { + get; + set; + } + + /// + /// Gets or sets the document name to be displayed to user when needed.This can be used in cases where URI doesn't have a user friendly file name or it is a remote URI. + /// + [DataMember(Name = "_vs_documentName")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? DocumentName { get; set; } + + /// + /// Gets or sets the project name. + /// + [DataMember(Name = "_vs_projectName")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? ProjectName { get; set; } + + /// + /// Gets or sets the containing type. + /// + [DataMember(Name = "_vs_containingType")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? ContainingType { get; set; } + + /// + /// Gets or sets the containing member. + /// + [DataMember(Name = "_vs_containingMember")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? ContainingMember { get; set; } + + /// + /// Gets or sets the text value for a location reference. + /// Must be of type or or or . + /// + /// + /// + /// This element should colorize syntax and highlight the range containing the reference. + /// Highlighting can be achieved by setting + /// on embedded within . + /// + /// + /// Encouraged values for are: + /// "MarkerFormatDefinition/HighlightedReference" for read references, + /// "MarkerFormatDefinition/HighlightedWrittenReference" for write references, + /// "MarkerFormatDefinition/HighlightedDefinition" for definitions. + /// + /// + [DataMember(Name = "_vs_text")] + [JsonConverter(typeof(ObjectContentConverter))] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public object? Text + { + get + { + return this.textValue; + } + + set + { + if (value is ImageElement || value is ContainerElement || value is ClassifiedTextElement || value is string) + { + this.textValue = value; + } + else + { + throw new InvalidOperationException($"{value?.GetType()} is an invalid type."); + } + } + } + + /// + /// Gets or sets the text value for display path.This would be a friendly display name for scenarios where the actual path on disk may be confusing for users. + /// This doesn't have to correspond to a real file path, but does need to be parsable by the various Path.GetFileName() methods. + /// + [DataMember(Name = "_vs_displayPath")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? DisplayPath { get; set; } + + /// + /// Gets or sets the origin of the item.The origin is used to filter remote results. + /// + [DataMember(Name = "_vs_origin")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public VSInternalItemOrigin? Origin { get; set; } + + /// + /// Gets or sets the icon to show for the definition header. + /// + [DataMember(Name = "_vs_definitionIcon")] + [JsonConverter(typeof(ImageElementConverter))] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public ImageElement? DefinitionIcon { get; set; } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalReferenceKind.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalReferenceKind.cs new file mode 100644 index 0000000000000..b511340956f5c --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalReferenceKind.cs @@ -0,0 +1,104 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Diagnostics.CodeAnalysis; + + /// + /// Enum which represents the various reference kinds. + /// + internal enum VSInternalReferenceKind + { + /// + /// Reference in inactive code block. + /// + Inactive, + + /// + /// Reference in comment. + /// + Comment, + + /// + /// Reference in a string. + /// + String, + + /// + /// Read operation on the reference. + /// + Read, + + /// + /// Write operation on the reference. + /// + Write, + + /// + /// Reference. + /// + Reference, + + /// + /// Name. + /// + Name, + + /// + /// Qualified. + /// + Qualified, + + /// + /// Type Argument. + /// + TypeArgument, + + /// + /// Type Constraint. + /// + TypeConstraint, + + /// + /// Base Type. + /// + BaseType, + + /// + /// Construct. + /// + Constructor, + + /// + /// Destructor. + /// + Destructor, + + /// + /// Import. + /// + Import, + + /// + /// Declaration. + /// + Declaration, + + /// + /// Address of. + /// + AddressOf, + + /// + /// Not a reference. + /// + NotReference, + + /// + /// Unknown. + /// + Unknown, + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalReferenceParams.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalReferenceParams.cs new file mode 100644 index 0000000000000..a302b2baeb3ce --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalReferenceParams.cs @@ -0,0 +1,26 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class which represents extensions of passed as parameter of find reference requests. + /// + internal class VSInternalReferenceParams : ReferenceParams + { + /// + /// Gets or sets a value indicating the scope of returned items. + /// + [DataMember(Name = "_vs_scope")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public VSInternalItemOrigin? Scope + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalRenameOptionSelection.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalRenameOptionSelection.cs new file mode 100644 index 0000000000000..4fe711ae387b5 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalRenameOptionSelection.cs @@ -0,0 +1,38 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing the user configuration (as defined in ) for a rename request. + /// + [DataContract] + internal class VSInternalRenameOptionSelection + { + /// + /// Gets or sets the name that identifies the option. + /// + [DataMember(Name = "_vs_name")] + [JsonProperty(Required = Required.Always)] + public string Name + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether the user selected the option. + /// + [DataMember(Name = "_vs_value")] + [JsonProperty(Required = Required.Always)] + public bool Value + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalRenameOptionSupport.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalRenameOptionSupport.cs new file mode 100644 index 0000000000000..4614f862c3eb2 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalRenameOptionSupport.cs @@ -0,0 +1,49 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing a renaming option for customizing the edit in the 'textDocument/rename' request. + /// + [DataContract] + internal class VSInternalRenameOptionSupport + { + /// + /// Gets or sets the name that identifies the option. + /// + [DataMember(Name = "_vs_name")] + [JsonProperty(Required = Required.Always)] + public string Name + { + get; + set; + } + + /// + /// Gets or sets the user-facing option label. + /// + [DataMember(Name = "_vs_label")] + [JsonProperty(Required = Required.Always)] + public string Label + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether the option has a default value of true. + /// + [DataMember(Name = "_vs_default")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool Default + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalRenameParams.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalRenameParams.cs new file mode 100644 index 0000000000000..969228507d1b8 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalRenameParams.cs @@ -0,0 +1,28 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing the parameters (together with extra VS-specific options) sent for the + /// 'textDocument/rename' request. + /// + [DataContract] + internal class VSInternalRenameParams : RenameParams + { + /// + /// Gets or sets the rename option values as selected by the user. + /// + [DataMember(Name = "_vs_optionSelections")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public VSInternalRenameOptionSelection[]? OptionSelections + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalRenameRange.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalRenameRange.cs new file mode 100644 index 0000000000000..092944a6dadae --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalRenameRange.cs @@ -0,0 +1,28 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class which represents a possible result value of the 'textDocument/prepareRename' request, + /// together with extra VS-specific options. + /// + [DataContract] + internal class VSInternalRenameRange : RenameRange + { + /// + /// Gets or sets the supported options for the rename request. + /// + [DataMember(Name = "_vs_supportedOptions")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public VSInternalRenameOptionSupport[]? SupportedOptions + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalResolutionStatusKind.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalResolutionStatusKind.cs new file mode 100644 index 0000000000000..871001c9ad550 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalResolutionStatusKind.cs @@ -0,0 +1,32 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + /// + /// Enum which represents the various resolutions for a reference entry. + /// + internal enum VSInternalResolutionStatusKind + { + /// + /// Entry has been processed and confirmed as a reference. + /// + ConfirmedAsReference, + + /// + /// Entry has been processed and confimed as not a reference. + /// + ConfirmedAsNotReference, + + /// + /// Entry has been processed but could not be confirmed. + /// + NotConfirmed, + + /// + /// Entry has not been processed. + /// + NotProcessed, + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalSelectedCompletionInfo.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalSelectedCompletionInfo.cs new file mode 100644 index 0000000000000..566acebde174c --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalSelectedCompletionInfo.cs @@ -0,0 +1,45 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Information about the selected completion item for . + /// + /// See https://github.com/microsoft/vscode/blob/075ba020e8493f40dba89891b1a08453f2c067e9/src/vscode-dts/vscode.proposed.inlineCompletions.d.ts#L48. + /// + internal class VSInternalSelectedCompletionInfo + { + /// + /// Gets or sets the range of the selected completion item. + /// + [DataMember(Name = "_vs_range")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public Range Range { get; set; } + + /// + /// Gets or sets the text of the selected completion item. + /// + [DataMember(Name = "_vs_text")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public string Text { get; set; } + + /// + /// Gets or sets the completion item kind of the selected completion item. + /// + [DataMember(Name = "_vs_completionKind")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public CompletionItemKind CompletionKind { get; set; } + + /// + /// Gets or sets a value indicating whether the completion item is a snippet. + /// + [DataMember(Name = "_vs_isSnippetText")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool IsSnippetText { get; set; } + } +} \ No newline at end of file diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalServerCapabilities.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalServerCapabilities.cs new file mode 100644 index 0000000000000..644a6a437fd46 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalServerCapabilities.cs @@ -0,0 +1,168 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System; + using System.Runtime.Serialization; + + using Newtonsoft.Json; + + /// + /// Extension class for ServerCapabilities with fields specific to Visual Studio. + /// + [DataContract] + internal class VSInternalServerCapabilities : VSServerCapabilities + { + /// + /// Gets or sets a value indicating whether or not GoTo's integration with + /// 'workspace/symbol' and the deprecated 16.3 'workspace/beginSymbol' messages + /// should be disabled. + /// + /// + /// This is provided to facilitate transition from in-proc to OOP for teams that + /// currently own both a Language Server for Ctrl+Q and a GoTo provider. + /// + [DataMember(Name = "_vs_disableGoToWorkspaceSymbols")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool DisableGoToWorkspaceSymbols + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether document/_ms_references is supported. + /// + [DataMember(Name = "_vs_ReferencesProvider")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool MSReferencesProvider + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether the server supports OnAutoInsert. + /// + [DataMember(Name = "_vs_onAutoInsertProvider")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public VSInternalDocumentOnAutoInsertOptions? OnAutoInsertProvider + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether the server requires document text to be included in textDocument/didOpen notifications. + /// + /// This capability is not intended to be included into the official LSP, hence _ms_ prefix. + [DataMember(Name = "_vs_doNotIncludeTextInTextDocumentDidOpen")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool DoNotIncludeTextInTextDocumentDidOpen + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether the server provides support to resolve string based response kinds. + /// + [DataMember(Name = "_vs_KindDescriptionResolveProvider")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool KindDescriptionResolveProvider + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether the server provides support for diagnostic pull requests. + /// + [DataMember(Name = "_vs_supportsDiagnosticRequests")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool SupportsDiagnosticRequests + { + get; + set; + } + + /// + /// Gets or sets server specified options for diagnostic pull requests. + /// + [DataMember(Name = "_vs_diagnosticProvider")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public VSInternalDiagnosticOptions? DiagnosticProvider + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether the server provides support for multiple context requests. + /// + [DataMember(Name = "_vs_MultipleContextSupportProvider")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public VSInternalMultipleContextFeatures? MultipleContextSupportProvider + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether the server provides support for inline completion requests. + /// + [DataMember(Name = "_vs_inlineCompletionOptions")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public VSInternalInlineCompletionOptions? InlineCompletionOptions + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether the server provides support for spell checking. + /// + [DataMember(Name = "_vs_spellCheckingProvider")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool SpellCheckingProvider + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether the server supports validating breakable ranges. + /// + [DataMember(Name = "_vs_breakableRangeProvider")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool BreakableRangeProvider + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether the server supports uri presentation. + /// + [DataMember(Name = "_vs_uriPresentationProvider")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool UriPresentationProvider + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether the server supports text presentation. + /// + [DataMember(Name = "_vs_textPresentationProvider")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool TextPresentationProvider + { + get; + set; + } + } +} \ No newline at end of file diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalSignatureInformation.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalSignatureInformation.cs new file mode 100644 index 0000000000000..74ca607565159 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalSignatureInformation.cs @@ -0,0 +1,29 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Roslyn.Text.Adornments; + using Newtonsoft.Json; + + /// + /// Extension class for signature help information which contains colorized label information. + /// + [DataContract] + internal class VSInternalSignatureInformation : SignatureInformation + { + /// + /// Gets or sets the value representing the colorized label. + /// + [DataMember(Name = "_vs_colorizedLabel")] + [JsonConverter(typeof(ClassifiedTextElementConverter))] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public ClassifiedTextElement? ColorizedLabel + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalSnippetSupportLevel.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalSnippetSupportLevel.cs new file mode 100644 index 0000000000000..7bf24583957e9 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalSnippetSupportLevel.cs @@ -0,0 +1,22 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + /// + /// The version of support that is available from the client. + /// + internal enum VSInternalSnippetSupportLevel + { + /// + /// Only default tab stops ($0) are supported. + /// + DefaultTabStop = 1, + + /// + /// Complete snippet support is available. + /// + Complete = 99, + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalSpellCheckableRangeKind.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalSpellCheckableRangeKind.cs new file mode 100644 index 0000000000000..d3c3022366495 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalSpellCheckableRangeKind.cs @@ -0,0 +1,27 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + /// + /// Enum to represent the spell checkable region kinds. + /// + internal enum VSInternalSpellCheckableRangeKind + { + /// + /// Represents a span of a string. + /// + String = 0, + + /// + /// Represents a span of a comment. + /// + Comment = 1, + + /// + /// Represents a span of an identifier declaration. + /// + Identifier = 2, + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalSpellCheckableRangeReport.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalSpellCheckableRangeReport.cs new file mode 100644 index 0000000000000..ca3264b7e8c30 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalSpellCheckableRangeReport.cs @@ -0,0 +1,67 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + using Newtonsoft.Json; + + /// + /// Report of spell checkable ranges. + /// + [DataContract] + internal class VSInternalSpellCheckableRangeReport + { + /// + /// Gets or sets the server-generated version number for the spell checkable ranges. + /// This is treated as a black box by the client: it is stored on the client + /// for each textDocument and sent back to the server when requesting + /// spell checkable ranges. The server can use this result ID to avoid resending + /// spell checkable ranges that had previously been sent. + /// + [DataMember(Name = "_vs_resultId")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? ResultId { get; set; } + + /// + /// Gets or sets an array containing encoded ranges to spell check. + /// + /// + /// The data structure is as the following: + /// 1. property can contain multiple spans to spell check. + /// 2. Each span is defined by a set of 3 ordered integers in the property. + /// 3. The span's ordered information are the following: + /// 1. A kind, corresponding to the numeric value of . + /// 2. A start position, which is the character index where the span starts in the document buffer. + /// The start position should be the relative offset from the end of the previous span, regardless of whether that span is the same range + /// or a prior range. + /// 3. The length of the span. + /// 4. Spans should be ordered by their absolute start position in the document buffer. + /// + /// + /// [ + /// /* ---- First span in the document, admitting this is the first report returned. ---- */ + /// 1, // The kind of the span. Equivalent to . + /// 123, // This is the very first span's start position. The position is relative to the beginning of the document buffer. + /// 5, // Span length + /// /* ---- Second span in the document ---- */ + /// 0, // Equivalent to . + /// 6, // Start position relative to the first span in the document. Absolute span position is therefore (123 + 5) + 6 = 134. + /// 4, // Span length + /// /* ---- Third span in the document ---- */ + /// 0, // Equivalent to . + /// 12, // Start position relative to the second span. Absolute span position is therefore (134 + 4) + 12 = 150 + /// 5 // Span length + /// ] + /// + [DataMember(Name = "_vs_ranges")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public int[]? Ranges + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalStreamingParams.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalStreamingParams.cs new file mode 100644 index 0000000000000..3b0e082213ebe --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalStreamingParams.cs @@ -0,0 +1,47 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing a streaming pull request parameter used. + /// + /// TODO: Deprecate VSInternalDiagnosticParams.cs to use this merged param instead. + /// + [DataContract] + internal class VSInternalStreamingParams : ITextDocumentParams + { + /// + /// Gets or sets the document for which the feature is being requested for. + /// + [DataMember(Name = "_vs_textDocument", IsRequired = true)] + public TextDocumentIdentifier TextDocument { get; set; } + + /// + /// Gets or sets the server-generated version number for the feature request. + /// + /// + /// + /// This is treated as a black box by the client: it is stored on the client + /// for each textDocument and sent back to the server when requesting + /// the feature. The server can use this result ID to avoid resending + /// feature results that had previously been sent. + /// + /// Note that if a client does request results that haven’t changed, the + /// language server should not reply with any results for that document. + /// If the client requests results for a file that has been renamed or + /// deleted, then the language service should respond with null for the + /// results. + /// Also, if a service is reporting multiple reports for the same + /// document, then all reports are expected to have the same + /// previousResultId. + /// + [DataMember(Name = "_vs_previousResultId")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? PreviousResultId { get; set; } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalSymbolInformation.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalSymbolInformation.cs new file mode 100644 index 0000000000000..7e241f9b91960 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalSymbolInformation.cs @@ -0,0 +1,26 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Extension class for SymbolInformation with fields specific to Visual Studio functionalities. + /// + /// + /// This is a temporary protocol and should not be used. + /// + [DataContract] + internal class VSInternalSymbolInformation : VSSymbolInformation + { + /// + /// Gets or sets the string kind used for icons. + /// + [DataMember(Name = "_vs_vsKind")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public VSInternalKindAndModifier? VSKind { get; set; } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalTextDocumentClientCapabilities.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalTextDocumentClientCapabilities.cs new file mode 100644 index 0000000000000..1ae592269a85e --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalTextDocumentClientCapabilities.cs @@ -0,0 +1,26 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Text document capabilities specific to Visual Studio. + /// + internal class VSInternalTextDocumentClientCapabilities : TextDocumentClientCapabilities + { + /// + /// Gets or sets the setting which determines if on auto insert can be dynamically registered. + /// + [DataMember(Name = "_vs_onAutoInsert")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public DynamicRegistrationSetting? OnAutoInsert + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalTextDocumentRegistrationOptions.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalTextDocumentRegistrationOptions.cs new file mode 100644 index 0000000000000..e73b246d01f2e --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalTextDocumentRegistrationOptions.cs @@ -0,0 +1,27 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// / Class representing the options for registering textDocument/_vs_OnAutoInsert support. + /// + [DataContract] + internal class VSInternalTextDocumentRegistrationOptions : TextDocumentRegistrationOptions + { + /// + /// Gets or sets trigger characters for on auto insert. + /// + [DataMember(Name = "_vs_triggerCharacters")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string[]? TriggerCharacters + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalTextPresentationParams.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalTextPresentationParams.cs new file mode 100644 index 0000000000000..3ec280d525972 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalTextPresentationParams.cs @@ -0,0 +1,48 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing the parameters sent for a textDocument/_vs_textPresentation request. + /// + [DataContract] + internal class VSInternalTextPresentationParams : ITextDocumentParams + { + /// + /// Gets or sets the identifier for the text document to be operate on. + /// + [DataMember(Name = "_vs_textDocument")] + [JsonProperty(Required = Required.Always)] + public TextDocumentIdentifier TextDocument + { + get; + set; + } + + /// + /// Gets or sets the range. + /// + [DataMember(Name = "_vs_range")] + [JsonProperty(Required = Required.Always)] + public Range Range + { + get; + set; + } + + /// + /// Gets or sets the text. + /// + [DataMember(Name = "_vs_text")] + public string? Text + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalUriPresentationParams.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalUriPresentationParams.cs new file mode 100644 index 0000000000000..3736b48506e1e --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalUriPresentationParams.cs @@ -0,0 +1,50 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System; + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing the parameters sent for a textDocument/_vs_uriPresentation request. + /// + [DataContract] + internal class VSInternalUriPresentationParams : ITextDocumentParams + { + /// + /// Gets or sets the identifier for the text document to be operate on. + /// + [DataMember(Name = "_vs_textDocument")] + [JsonProperty(Required = Required.Always)] + public TextDocumentIdentifier TextDocument + { + get; + set; + } + + /// + /// Gets or sets the range. + /// + [DataMember(Name = "_vs_range")] + [JsonProperty(Required = Required.Always)] + public Range Range + { + get; + set; + } + + /// + /// Gets or sets the URI values. Valid for DropKind.Uris. + /// + [DataMember(Name = "_vs_uris")] + [JsonProperty(ItemConverterType = typeof(DocumentUriConverter))] + public Uri[]? Uris + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalValidateBreakableRangeParams.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalValidateBreakableRangeParams.cs new file mode 100644 index 0000000000000..f9a4464b2e282 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalValidateBreakableRangeParams.cs @@ -0,0 +1,27 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// Class representing the parameters sent for the textDocument/validateBreakableRange request. + /// + [DataContract] + internal class VSInternalValidateBreakableRangeParams : ITextDocumentParams + { + /// + /// Gets or sets the for the request. + /// + [DataMember(Name = "_vs_textDocument")] + public TextDocumentIdentifier TextDocument { get; set; } + + /// + /// Gets or sets the at which the request was sent. + /// + [DataMember(Name = "_vs_range")] + public Range Range { get; set; } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalWellKnownCodeActionCommands.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalWellKnownCodeActionCommands.cs new file mode 100644 index 0000000000000..3dabb55e89dfe --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalWellKnownCodeActionCommands.cs @@ -0,0 +1,22 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + /// + /// Class which contains the string values for all well-known Visual Studion LSP code action commands. + /// + internal static class VSInternalWellKnownCodeActionCommands + { + /// + /// Command name for '_ms_setClipboard'. + /// + public const string SetClipboard = "_ms_setClipboard"; + + /// + /// Command name for '_ms_openUrl'. + /// + public const string OpenUrl = "_ms_openUrl"; + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalWorkspaceSpellCheckableParams.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalWorkspaceSpellCheckableParams.cs new file mode 100644 index 0000000000000..516eb1c8218ea --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalWorkspaceSpellCheckableParams.cs @@ -0,0 +1,37 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System; + using System.Collections.Generic; + using System.Runtime.Serialization; + using System.Text; + using Newtonsoft.Json; + + /// + /// Parameter for workspace/_vs_spellCheckableRanges. + /// + [DataContract] + internal class VSInternalWorkspaceSpellCheckableParams : IPartialResultParams + { + /// + /// Gets or sets the current state of the documents the client already has received. + /// + [DataMember(Name = "_vs_previousResults")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public VSInternalStreamingParams[]? PreviousResults { get; set; } + + /// + /// Gets or sets an optional token that a server can use to report partial results (e.g. streaming) to the client. + /// + [DataMember(Name = "_vs_partialResultToken")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public IProgress? PartialResultToken + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalWorkspaceSpellCheckableReport.cs b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalWorkspaceSpellCheckableReport.cs new file mode 100644 index 0000000000000..a844892b092b1 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Internal/VSInternalWorkspaceSpellCheckableReport.cs @@ -0,0 +1,24 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System; + using System.Collections.Generic; + using System.Runtime.Serialization; + using System.Text; + + /// + /// Report for workspace spell checkable range request. + /// + [DataContract] + internal class VSInternalWorkspaceSpellCheckableReport : VSInternalSpellCheckableRangeReport, ITextDocumentParams + { + /// + /// Gets or sets the document for which the spell checkable ranges are returned. + /// + [DataMember(Name = "_vs_textDocument", IsRequired = true)] + public TextDocumentIdentifier TextDocument { get; set; } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/LanguageServer.Protocol.csproj b/src/Features/LanguageServer/Protocol/Protocol/LanguageServer.Protocol.csproj new file mode 100644 index 0000000000000..bba922bb53a16 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/LanguageServer.Protocol.csproj @@ -0,0 +1,59 @@ + + + Microsoft.VisualStudio.LanguageServer.Protocol + + + + + + + Microsoft.VisualStudio.LanguageServer.Protocol + netstandard2.0 + true + LanguageServer.Protocol.ruleset + false + true + true + + + true + A .NET implementation of the Language Server Protocol + $(Summary) + false + true + true + Microsoft VisualStudio LanguageServer Language Server Protocol VSSDK + $(PackageOutputPath)\nuget-public + true + RS0037,SA1011,1591,8618,CA1704 + en-US + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + True + True + Resources.resx + + + ResXFileCodeGenerator + Resources.Designer.cs + + + + + + diff --git a/src/Features/LanguageServer/Protocol/Protocol/LanguageServer.Protocol.ruleset b/src/Features/LanguageServer/Protocol/Protocol/LanguageServer.Protocol.ruleset new file mode 100644 index 0000000000000..05183f019ae27 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/LanguageServer.Protocol.ruleset @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Features/LanguageServer/Protocol/Protocol/LinkedEditingRangeOptions.cs b/src/Features/LanguageServer/Protocol/Protocol/LinkedEditingRangeOptions.cs new file mode 100644 index 0000000000000..0afeffb82a826 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/LinkedEditingRangeOptions.cs @@ -0,0 +1,29 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class which represents linked editing range capabilities. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class LinkedEditingRangeOptions : IWorkDoneProgressOptions + { + /// + /// Gets or sets a value indicating whether work done progress is supported. + /// + [DataMember(Name = "workDoneProgress")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool WorkDoneProgress + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/LinkedEditingRangeParams.cs b/src/Features/LanguageServer/Protocol/Protocol/LinkedEditingRangeParams.cs new file mode 100644 index 0000000000000..d24bfd158ddd3 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/LinkedEditingRangeParams.cs @@ -0,0 +1,18 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// Class representing the parameters sent for a textDocument/linkedEditingRange request. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class LinkedEditingRangeParams : TextDocumentPositionParams + { + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/LinkedEditingRanges.cs b/src/Features/LanguageServer/Protocol/Protocol/LinkedEditingRanges.cs new file mode 100644 index 0000000000000..9c0b78fd5c768 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/LinkedEditingRanges.cs @@ -0,0 +1,39 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing the response of an LinkedEditingRanges response. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class LinkedEditingRanges + { + /// + /// Gets or sets the ranges for the type rename. + /// + [DataMember(Name = "ranges")] + public Range[] Ranges + { + get; + set; + } + + /// + /// Gets or sets the word pattern for the type rename. + /// + [DataMember(Name = "wordPattern")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? WordPattern + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Location.cs b/src/Features/LanguageServer/Protocol/Protocol/Location.cs new file mode 100644 index 0000000000000..e91082e4441dd --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Location.cs @@ -0,0 +1,64 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System; + using System.Collections.Generic; + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing a location in a document. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class Location : IEquatable + { + /// + /// Gets or sets the URI for the document the location belongs to. + /// + [DataMember(Name = "uri")] + [JsonConverter(typeof(DocumentUriConverter))] + public Uri Uri + { + get; + set; + } + + /// + /// Gets or sets the range of the location in the document. + /// + [DataMember(Name = "range")] + public Range Range + { + get; + set; + } + + /// + public override bool Equals(object obj) + { + return this.Equals(obj as Location); + } + + /// + public bool Equals(Location? other) + { + return other != null && this.Uri != null && other.Uri != null && + this.Uri.Equals(other.Uri) && + EqualityComparer.Default.Equals(this.Range, other.Range); + } + + /// + public override int GetHashCode() + { + var hashCode = 1486144663; + hashCode = (hashCode * -1521134295) + EqualityComparer.Default.GetHashCode(this.Uri); + hashCode = (hashCode * -1521134295) + EqualityComparer.Default.GetHashCode(this.Range); + return hashCode; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/LogMessageParams.cs b/src/Features/LanguageServer/Protocol/Protocol/LogMessageParams.cs new file mode 100644 index 0000000000000..8d80b156e99a5 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/LogMessageParams.cs @@ -0,0 +1,37 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// Class which represents parameter sent with window/logMessage requests. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class LogMessageParams + { + /// + /// Gets or sets the type of message. + /// + [DataMember(Name = "type")] + public MessageType MessageType + { + get; + set; + } + + /// + /// Gets or sets the message. + /// + [DataMember(Name = "message")] + public string Message + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/LspNotification.cs b/src/Features/LanguageServer/Protocol/Protocol/LspNotification.cs new file mode 100644 index 0000000000000..6466578c0a0ba --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/LspNotification.cs @@ -0,0 +1,27 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + /// + /// Strongly typed object used to specify a LSP notification's parameter type. + /// + /// The parameter type. + internal class LspNotification + { + /// + /// Initializes a new instance of the class. + /// + /// The name of the JSON-RPC notification. + public LspNotification(string name) + { + this.Name = name; + } + + /// + /// Gets the name of the JSON-RPC notification. + /// + public string Name { get; } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/LspRequest.cs b/src/Features/LanguageServer/Protocol/Protocol/LspRequest.cs new file mode 100644 index 0000000000000..17a0cf2c97441 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/LspRequest.cs @@ -0,0 +1,28 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + /// + /// Strongly typed object used to specify a LSP requests's parameter and return types. + /// + /// The parameter type. + /// The return type. + internal class LspRequest + { + /// + /// Initializes a new instance of the class. + /// + /// The name of the JSON-RPC request. + public LspRequest(string name) + { + this.Name = name; + } + + /// + /// Gets the name of the JSON-RPC request. + /// + public string Name { get; } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/MarkedString.cs b/src/Features/LanguageServer/Protocol/Protocol/MarkedString.cs new file mode 100644 index 0000000000000..62c6b0d8a16d1 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/MarkedString.cs @@ -0,0 +1,40 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing human readable text that should be rendered. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class MarkedString + { + /// + /// Gets or sets the language of the code stored in . + /// + [DataMember(Name = "language")] + [JsonProperty(Required = Required.Always)] + public string Language + { + get; + set; + } + + /// + /// Gets or sets the code. + /// + [DataMember(Name = "value")] + [JsonProperty(Required = Required.Always)] + public string Value + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/MarkupContent.cs b/src/Features/LanguageServer/Protocol/Protocol/MarkupContent.cs new file mode 100644 index 0000000000000..ce92eda072808 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/MarkupContent.cs @@ -0,0 +1,37 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// Class representing text and an associated format that should be rendered. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class MarkupContent + { + /// + /// Gets or sets the representing the text's format. + /// + [DataMember(Name = "kind")] + public MarkupKind Kind + { + get; + set; + } + + /// + /// Gets or sets the text that should be rendered. + /// + [DataMember(Name = "value")] + public string Value + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/MarkupKind.cs b/src/Features/LanguageServer/Protocol/Protocol/MarkupKind.cs new file mode 100644 index 0000000000000..29dda1ba997c7 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/MarkupKind.cs @@ -0,0 +1,31 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.ComponentModel; + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Value representing the various formats of markup text. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + [JsonConverter(typeof(StringEnumConverter))] + [TypeConverter(typeof(StringEnumConverter.TypeConverter))] + internal readonly record struct MarkupKind(string Value) : IStringEnum + { + /// + /// Markup type is plain text. + /// + public static readonly MarkupKind PlainText = new("plaintext"); + + /// + /// Markup type is Markdown. + /// + public static readonly MarkupKind Markdown = new("markdown"); + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/MessageActionItem.cs b/src/Features/LanguageServer/Protocol/Protocol/MessageActionItem.cs new file mode 100644 index 0000000000000..4dc981f6f1827 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/MessageActionItem.cs @@ -0,0 +1,27 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// Class which represent an action the user performs after a window/showMessageRequest request is sent. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class MessageActionItem + { + /// + /// Gets or sets the title. + /// + [DataMember(Name = "title")] + public string Title + { + get; + set; + } + } +} \ No newline at end of file diff --git a/src/Features/LanguageServer/Protocol/Protocol/MessageType.cs b/src/Features/LanguageServer/Protocol/Protocol/MessageType.cs new file mode 100644 index 0000000000000..3b243d8a2f55f --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/MessageType.cs @@ -0,0 +1,37 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// Message type enum. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal enum MessageType + { + /// + /// Error message. + /// + Error = 1, + + /// + /// Warning message. + /// + Warning = 2, + + /// + /// Info message. + /// + Info = 3, + + /// + /// Log message. + /// + Log = 4, + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Methods.cs b/src/Features/LanguageServer/Protocol/Protocol/Methods.cs new file mode 100644 index 0000000000000..0bf3fd4109733 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Methods.cs @@ -0,0 +1,603 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + /// + /// Class which contains the string values for all common language protocol methods. + /// + internal static class Methods + { + /// + /// Method name for 'initialize'. + /// + public const string InitializeName = "initialize"; + + /// + /// Method name for 'initialized'. + /// + public const string InitializedName = "initialized"; + + /// + /// Method name for '$/progress' notifications. + /// + public const string ProgressNotificationName = "$/progress"; + + /// + /// Name of the progress token in the request. + /// + public const string PartialResultTokenName = "partialResultToken"; + + /// + /// Name of the progress token in the request. + /// + public const string PartialResultTokenPropertyName = "PartialResultToken"; + + /// + /// Name of the work done token in the request. + /// + public const string WorkDoneTokenName = "workDoneToken"; + + /// + /// Name of the progress token in the $/progress notification. + /// + public const string ProgressNotificationTokenName = "token"; + + /// + /// Method name for 'textDocument/codeAction'. + /// + public const string TextDocumentCodeActionName = "textDocument/codeAction"; + + /// + /// Method name for 'textDocument/codeLens'. + /// + public const string TextDocumentCodeLensName = "textDocument/codeLens"; + + /// + /// Method name for 'codeAction/resolve'. + /// + public const string CodeActionResolveName = "codeAction/resolve"; + + /// + /// Method name for 'codeLens/resolve'. + /// + public const string CodeLensResolveName = "codeLens/resolve"; + + /// + /// Method name for 'textDocument/completion'. + /// + public const string TextDocumentCompletionName = "textDocument/completion"; + + /// + /// Method name for 'completionItem/resolve'. + /// + public const string TextDocumentCompletionResolveName = "completionItem/resolve"; + + /// + /// Method name for 'textDocument/definition'. + /// + public const string TextDocumentDefinitionName = "textDocument/definition"; + + /// + /// Method name for 'textDocument/diagnostic'. + /// + public const string TextDocumentDiagnosticName = "textDocument/diagnostic"; + + /// + /// Method name for 'textDocument/didOpen'. + /// + public const string TextDocumentDidOpenName = "textDocument/didOpen"; + + /// + /// Method name for 'textDocument/didClose'. + /// + public const string TextDocumentDidCloseName = "textDocument/didClose"; + + /// + /// Method name for 'textDocument/didChange'. + /// + public const string TextDocumentDidChangeName = "textDocument/didChange"; + + /// + /// Method name for 'textDocument/didSave'. + /// + public const string TextDocumentDidSaveName = "textDocument/didSave"; + + /// + /// Method name for 'textDocument/documentHighlight'. + /// + public const string TextDocumentDocumentHighlightName = "textDocument/documentHighlight"; + + /// + /// Method name for 'textDocument/documentLink'. + /// + public const string TextDocumentDocumentLinkName = "textDocument/documentLink"; + + /// + /// Method name for 'documentLink/resolve'. + /// + public const string DocumentLinkResolveName = "documentLink/resolve"; + + /// + /// Method name for 'textDocument/documentColor'. + /// + public const string TextDocumentDocumentColorName = "textDocument/documentColor"; + + /// + /// Method name for 'textDocument/documentSymbol'. + /// + public const string TextDocumentDocumentSymbolName = "textDocument/documentSymbol"; + + /// + /// Method name for 'textDocument/foldingRange'. + /// + public const string TextDocumentFoldingRangeName = "textDocument/foldingRange"; + + /// + /// Method name for 'textDocument/formatting'. + /// + public const string TextDocumentFormattingName = "textDocument/formatting"; + + /// + /// Method name for 'textDocument/hover'. + /// + public const string TextDocumentHoverName = "textDocument/hover"; + + /// + /// Method name for 'textDocument/onTypeFormatting'. + /// + public const string TextDocumentOnTypeFormattingName = "textDocument/onTypeFormatting"; + + /// + /// Method name for 'textDocument/rangeFormatting'. + /// + public const string TextDocumentRangeFormattingName = "textDocument/rangeFormatting"; + + /// + /// Method name for 'textDocument/publishDiagnostics'. + /// + public const string TextDocumentPublishDiagnosticsName = "textDocument/publishDiagnostics"; + + /// + /// Method name for 'textDocument/implementation'. + /// + public const string TextDocumentImplementationName = "textDocument/implementation"; + + /// + /// Method name for 'textDocument/inlayHint'. + /// + public const string TextDocumentInlayHintName = "textDocument/inlayHint"; + + /// + /// Method name for 'inlayHint/resolve'. + /// + public const string InlayHintResolveName = "inlayHint/resolve"; + + /// + /// Method name for 'textDocument/typeDefinition'. + /// + public const string TextDocumentTypeDefinitionName = "textDocument/typeDefinition"; + + /// + /// Method name for 'textDocument/references'. + /// + public const string TextDocumentReferencesName = "textDocument/references"; + + /// + /// Method name for 'textDocument/rename'. + /// + public const string TextDocumentRenameName = "textDocument/rename"; + + /// + /// Method name for 'textDocument/prepareRename'. + /// + public const string TextDocumentPrepareRenameName = "textDocument/prepareRename"; + + /// + /// Method name for 'textDocument/semanticTokens/full'. + /// + public const string TextDocumentSemanticTokensFullName = "textDocument/semanticTokens/full"; + + /// + /// Method name for 'textDocument/semanticTokens/range'. + /// + public const string TextDocumentSemanticTokensRangeName = "textDocument/semanticTokens/range"; + + /// + /// Method name for 'textDocument/semanticTokens/full/delta'. + /// + public const string TextDocumentSemanticTokensFullDeltaName = "textDocument/semanticTokens/full/delta"; + + /// + /// Method name for 'textDocument/signatureHelp'. + /// + public const string TextDocumentSignatureHelpName = "textDocument/signatureHelp"; + + /// + /// Method name for 'textDocument/willSave'. + /// + public const string TextDocumentWillSaveName = "textDocument/willSave"; + + /// + /// Method name for 'textDocument/willSaveWaitUntil'. + /// + public const string TextDocumentWillSaveWaitUntilName = "textDocument/willSaveWaitUntil"; + + /// + /// Method name for 'textDocument/linkedEditingRange'. + /// + public const string TextDocumentLinkedEditingRangeName = "textDocument/linkedEditingRange"; + + /// + /// Method name for 'window/logMessage'. + /// + public const string WindowLogMessageName = "window/logMessage"; + + /// + /// Method name for 'window/showMessage'. + /// + public const string WindowShowMessageName = "window/showMessage"; + + /// + /// Method name for 'window/showMessageRequest'. + /// + public const string WindowShowMessageRequestName = "window/showMessageRequest"; + + /// + /// Method name for 'workspace/applyEdit'. + /// + public const string WorkspaceApplyEditName = "workspace/applyEdit"; + + /// + /// Method name for 'workspace/semanticTokens/refresh'. + /// + public const string WorkspaceSemanticTokensRefreshName = "workspace/semanticTokens/refresh"; + + /// + /// Method name for 'workspace/configuration'. + /// + public const string WorkspaceConfigurationName = "workspace/configuration"; + + /// + /// Method name for 'workspace/diagnostic'. + /// + public const string WorkspaceDiagnosticName = "workspace/diagnostic"; + + /// + /// Method name for 'workspace/diagnostic/refresh'. + /// + public const string WorkspaceDiagnosticRefreshName = "workspace/diagnostic/refresh"; + + /// + /// Method name for 'workspace/didChangeConfiguration'. + /// + public const string WorkspaceDidChangeConfigurationName = "workspace/didChangeConfiguration"; + + /// + /// Method name for 'workspace/executeCommand'. + /// + public const string WorkspaceExecuteCommandName = "workspace/executeCommand"; + + /// + /// Method name for 'workspace/symbol'. + /// + public const string WorkspaceSymbolName = "workspace/symbol"; + + /// + /// Method name for 'workspace/didChangeWatchedFiles'. + /// + public const string WorkspaceDidChangeWatchedFilesName = "workspace/didChangeWatchedFiles"; + + /// + /// Method name for 'workspace/codeLens/refresh'. + /// + public const string WorkspaceCodeLensRefreshName = "workspace/codeLens/refresh"; + + /// + /// Method name for 'workspace/inlayHint/refresh'. + /// + public const string WorkspaceInlayHintRefreshName = "workspace/inlayHint/refresh"; + + /// + /// Method name for 'shutdown'. + /// + public const string ShutdownName = "shutdown"; + + /// + /// Method name for 'exit'. + /// + public const string ExitName = "exit"; + + /// + /// Method name for 'telemetry/event'. + /// + public const string TelemetryEventName = "telemetry/event"; + + /// + /// Method name for 'client/registerCapability'. + /// + public const string ClientRegisterCapabilityName = "client/registerCapability"; + + /// + /// Method name for 'client/unregisterCapability'. + /// + public const string ClientUnregisterCapabilityName = "client/unregisterCapability"; + + /// + /// Strongly typed message object for 'initialize'. + /// + public static readonly LspRequest Initialize = new LspRequest(InitializeName); + + /// + /// Strongly typed message object for 'initialized'. + /// + public static readonly LspNotification Initialized = new LspNotification(InitializedName); + + /// + /// Strongly typed message object for 'textDocument/codeAction'. + /// + public static readonly LspRequest[]?> TextDocumentCodeAction = new LspRequest[]?>(TextDocumentCodeActionName); + + /// + /// Strongly typed message object for 'textDocument/codeLens'. + /// + public static readonly LspRequest TextDocumentCodeLens = new LspRequest(TextDocumentCodeLensName); + + /// + /// Strongly typed message object for 'codeAction/resolve'. + /// + public static readonly LspRequest CodeActionResolve = new LspRequest(CodeActionResolveName); + + /// + /// Strongly typed message object for 'codeLens/resolve'. + /// + public static readonly LspRequest CodeLensResolve = new LspRequest(CodeLensResolveName); + + /// + /// Strongly typed message object for 'textDocument/completion'. + /// + public static readonly LspRequest?> TextDocumentCompletion = new LspRequest?>(TextDocumentCompletionName); + + /// + /// Strongly typed message object for 'completionItem/resolve'. + /// + public static readonly LspRequest TextDocumentCompletionResolve = new LspRequest(TextDocumentCompletionResolveName); + + /// + /// Strongly typed message object for 'textDocument/definition'. + /// + public static readonly LspRequest?> TextDocumentDefinition = new LspRequest?>(TextDocumentDefinitionName); + + /// + /// Strongly typed message object for 'textDocument/didOpen'. + /// + public static readonly LspNotification TextDocumentDidOpen = new LspNotification(TextDocumentDidOpenName); + + /// + /// Strongly typed message object for 'textDocument/didClose'. + /// + public static readonly LspNotification TextDocumentDidClose = new LspNotification(TextDocumentDidCloseName); + + /// + /// Strongly typed message object for 'textDocument/didChange'. + /// + public static readonly LspNotification TextDocumentDidChange = new LspNotification(TextDocumentDidChangeName); + + /// + /// Strongly typed message object for 'textDocument/didSave'. + /// + public static readonly LspNotification TextDocumentDidSave = new LspNotification(TextDocumentDidSaveName); + + /// + /// Strongly typed message object for 'textDocument/documentHighlight'. + /// + public static readonly LspRequest TextDocumentDocumentHighlight = new LspRequest(TextDocumentDocumentHighlightName); + + /// + /// Strongly typed message object for 'textDocument/documentLink'. + /// + public static readonly LspRequest TextDocumentDocumentLink = new LspRequest(TextDocumentDocumentLinkName); + + /// + /// Strongly typed message object for 'documentLink/resolve'. + /// + public static readonly LspRequest DocumentLinkResolve = new LspRequest(DocumentLinkResolveName); + + /// + /// Strongly typed message object for 'textDocument/documentColor'. + /// + public static readonly LspRequest DocumentColorRequest = new LspRequest(TextDocumentDocumentColorName); + + /// + /// Strongly typed message object for 'textDocument/documentSymbol'. + /// + public static readonly LspRequest TextDocumentDocumentSymbol = new LspRequest(TextDocumentDocumentSymbolName); + + /// + /// Stronly typed message object for 'textDocument/foldingRange'. + /// + public static readonly LspRequest TextDocumentFoldingRange = new LspRequest(TextDocumentFoldingRangeName); + + /// + /// Strongly typed message object for 'textDocument/formatting'. + /// + public static readonly LspRequest TextDocumentFormatting = new LspRequest(TextDocumentFormattingName); + + /// + /// Strongly typed message object for 'textDocument/hover'. + /// + public static readonly LspRequest TextDocumentHover = new LspRequest(TextDocumentHoverName); + + /// + /// Strongly typed message object for 'textDocument/onTypeFormatting'. + /// + public static readonly LspRequest TextDocumentOnTypeFormatting = new LspRequest(TextDocumentOnTypeFormattingName); + + /// + /// Strongly typed message object for 'textDocument/rangeFormatting'. + /// + public static readonly LspRequest TextDocumentRangeFormatting = new LspRequest(TextDocumentRangeFormattingName); + + /// + /// Strongly typed message object for 'textDocument/publishDiagnostics'. + /// + public static readonly LspNotification TextDocumentPublishDiagnostics = new LspNotification(TextDocumentPublishDiagnosticsName); + + /// + /// Strongly typed message object for 'textDocument/implementation'. + /// + public static readonly LspRequest?> TextDocumentImplementation = new LspRequest?>(TextDocumentImplementationName); + + /// + /// Strongly typed message object for 'textDocument/inlayHint'. + /// + public static readonly LspRequest TextDocumentInlayHint = new LspRequest(TextDocumentInlayHintName); + + /// + /// Strongly typed message object for 'inlayHint/resolve'. + /// + public static readonly LspRequest InlayHintResolve = new LspRequest(InlayHintResolveName); + + /// + /// Strongly typed message object for 'textDocument/typeDefinition'. + /// + public static readonly LspRequest?> TextDocumentTypeDefinition = new LspRequest?>(TextDocumentTypeDefinitionName); + + /// + /// Strongly typed message object for 'textDocument/references'. + /// + public static readonly LspRequest TextDocumentReferences = new LspRequest(TextDocumentReferencesName); + + /// + /// Strongly typed message object for 'textDocument/rename'. + /// + public static readonly LspRequest TextDocumentRename = new LspRequest(TextDocumentRenameName); + + /// + /// Strongly typed message object for 'textDocument/prepareRename'. + /// + public static readonly LspRequest?> TextDocumentPrepareRename = new LspRequest?>(TextDocumentPrepareRenameName); + + /// + /// Strongly typed message object for 'textDocument/signatureHelp'. + /// + public static readonly LspRequest TextDocumentSignatureHelp = new LspRequest(TextDocumentSignatureHelpName); + + /// + /// Strongly typed message object for 'textDocument/willSave'. + /// + public static readonly LspNotification TextDocumentWillSave = new LspNotification(TextDocumentWillSaveName); + + /// + /// Strongly typed message object for 'textDocument/willSaveWaitUntil'. + /// + public static readonly LspRequest TextDocumentWillSaveWaitUntil = new LspRequest(TextDocumentWillSaveWaitUntilName); + + /// + /// Strongly typed message object for 'textDocument/linkedEditingRange'. + /// + public static readonly LspRequest TextDocumentLinkedEditingRange = new LspRequest(TextDocumentLinkedEditingRangeName); + + /// + /// Strongly typed message object for 'window/logMessage'. + /// + public static readonly LspNotification WindowLogMessage = new LspNotification(WindowLogMessageName); + + /// + /// Strongly typed message object for 'window/showMessage'. + /// + public static readonly LspNotification WindowShowMessage = new LspNotification(WindowShowMessageName); + + /// + /// Strongly typed message object for 'window/showMessageRequest'. + /// + public static readonly LspRequest WindowShowMessageRequest = new LspRequest(WindowShowMessageRequestName); + + /// + /// Strongly typed message object for 'workspace/applyEdit'. + /// + public static readonly LspRequest WorkspaceApplyEdit = new LspRequest(WorkspaceApplyEditName); + + /// + /// Strongly typed message object for 'workspace/semanticTokens/refresh'. + /// + public static readonly LspRequest WorkspaceSemanticTokensRefresh = new LspRequest(WorkspaceSemanticTokensRefreshName); + + /// + /// Strongly typed message object for 'workspace/configuration'. + /// + public static readonly LspRequest WorkspaceConfiguration = new LspRequest(WorkspaceConfigurationName); + + /// + /// Strongly typed message object for 'workspace/didChangeConfiguration'. + /// + public static readonly LspNotification WorkspaceDidChangeConfiguration = new LspNotification(WorkspaceDidChangeConfigurationName); + + /// + /// Strongly typed message object for 'workspace/executeCommand'. + /// + public static readonly LspRequest WorkspaceExecuteCommand = new LspRequest(WorkspaceExecuteCommandName); + + /// + /// Strongly typed message object for 'workspace/symbol'. + /// + public static readonly LspRequest WorkspaceSymbol = new LspRequest(WorkspaceSymbolName); + + /// + /// Strongly typed message object for 'workspace/didChangeWatchedFiles'. + /// + public static readonly LspNotification WorkspaceDidChangeWatchedFiles = new LspNotification(WorkspaceDidChangeWatchedFilesName); + + /// + /// Strongly typed message object for 'workspace/codeLens/refresh'. + /// + public static readonly LspRequest WorkspaceCodeLensRefresh = new LspRequest(WorkspaceCodeLensRefreshName); + + /// + /// Strongly typed message object for 'workspace/inlayHint/refresh'. + /// + public static readonly LspRequest WorkspaceInlayHintRefresh = new LspRequest(WorkspaceInlayHintRefreshName); + + /// + /// Strongly typed message object for 'shutdown'. + /// + public static readonly LspRequest Shutdown = new LspRequest(ShutdownName); + + /// + /// Strongly typed message object for 'exit'. + /// + public static readonly LspNotification Exit = new LspNotification(ExitName); + + /// + /// Strongly typed message object for 'telemetry/event'. + /// + public static readonly LspNotification TelemetryEvent = new LspNotification(TelemetryEventName); + + /// + /// Strongly typed message object for 'client/registerCapability'. + /// + public static readonly LspRequest ClientRegisterCapability = new LspRequest(ClientRegisterCapabilityName); + + /// + /// Strongly typed message object for 'client/unregisterCapability'. + /// + public static readonly LspRequest ClientUnregisterCapability = new LspRequest(ClientUnregisterCapabilityName); + + /// + /// Strongly typed message object for 'textDocument/semanticTokens/full'. + /// + public static readonly LspRequest TextDocumentSemanticTokensFull = new LspRequest(TextDocumentSemanticTokensFullName); + + /// + /// Strongly typed message object for 'textDocument/semanticTokens/range'. + /// + public static readonly LspRequest TextDocumentSemanticTokensRange = new LspRequest(TextDocumentSemanticTokensRangeName); + + /// + /// Strongly typed message object for 'textDocument/semanticTokens/full/delta'. + /// + public static readonly LspRequest?> TextDocumentSemanticTokensFullDelta + = new LspRequest?>(TextDocumentSemanticTokensFullDeltaName); + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/OptionalVersionedTextDocumentIdentifier.cs b/src/Features/LanguageServer/Protocol/Protocol/OptionalVersionedTextDocumentIdentifier.cs new file mode 100644 index 0000000000000..d34f9a1010fd7 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/OptionalVersionedTextDocumentIdentifier.cs @@ -0,0 +1,87 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System; + using System.Globalization; + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class which represents a text document, but optionally has a version identifier. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class OptionalVersionedTextDocumentIdentifier : TextDocumentIdentifier, IEquatable + { + /// + /// Gets or sets the version of the document. + /// + [DataMember(Name = "version")] + [JsonProperty(NullValueHandling = NullValueHandling.Include)] + public int? Version + { + get; + set; + } + + public static bool operator ==(OptionalVersionedTextDocumentIdentifier? value1, OptionalVersionedTextDocumentIdentifier? value2) + { + if (ReferenceEquals(value1, value2)) + { + return true; + } + + // Is null? + if (ReferenceEquals(null, value2)) + { + return false; + } + + return value1?.Equals(value2) ?? false; + } + + public static bool operator !=(OptionalVersionedTextDocumentIdentifier? value1, OptionalVersionedTextDocumentIdentifier? value2) + { + return !(value1 == value2); + } + + /// + public bool Equals(OptionalVersionedTextDocumentIdentifier other) + { + return other is not null + && this.Version == other.Version + && base.Equals(other); + } + + /// + public override bool Equals(object obj) + { + if (obj is OptionalVersionedTextDocumentIdentifier other) + { + return this.Equals(other); + } + else + { + return false; + } + } + + /// + public override int GetHashCode() + { + return this.Version == null ? 89 : this.Version.GetHashCode() + ^ (base.GetHashCode() * 79); + } + + /// + public override string ToString() + { + // Invariant culture because the culture on the server vs client may vary. + return base.ToString() + "|" + this.Version?.ToString(CultureInfo.InvariantCulture); + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/ParameterInformation.cs b/src/Features/LanguageServer/Protocol/Protocol/ParameterInformation.cs new file mode 100644 index 0000000000000..38327189dcf73 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/ParameterInformation.cs @@ -0,0 +1,41 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System; + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing a parameter of a callable signature. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + [JsonConverter(typeof(ParameterInformationConverter))] + internal class ParameterInformation + { + /// + /// Gets or sets the label of the parameter. + /// + [DataMember(Name = "label")] + public SumType> Label + { + get; + set; + } + + /// + /// Gets or sets the human-readable documentation of the parameter. + /// + [DataMember(Name = "documentation")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public SumType? Documentation + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/ParameterInformationSetting.cs b/src/Features/LanguageServer/Protocol/Protocol/ParameterInformationSetting.cs new file mode 100644 index 0000000000000..debdaa4cdcbd0 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/ParameterInformationSetting.cs @@ -0,0 +1,29 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing the parameter information initialization setting. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class ParameterInformationSetting + { + /// + /// Gets or sets a value indicating whether the client supports label offset. + /// + [DataMember(Name = "labelOffsetSupport")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool LabelOffsetSupport + { + get; + set; + } + } +} \ No newline at end of file diff --git a/src/Features/LanguageServer/Protocol/Protocol/Position.cs b/src/Features/LanguageServer/Protocol/Protocol/Position.cs new file mode 100644 index 0000000000000..ec4a102e561be --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Position.cs @@ -0,0 +1,121 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System; + using System.Diagnostics.CodeAnalysis; + using System.Runtime.Serialization; + + /// + /// Class which represents a position on a text document. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class Position : IEquatable + { + /// + /// Initializes a new instance of the class. + /// + public Position() + { + } + + /// + /// Initializes a new instance of the class. + /// + /// Line number. + /// Character number. + public Position(int line, int character) + { + this.Line = line; + this.Character = character; + } + + /// + /// Gets or sets the line number. + /// + [DataMember(Name = "line")] + public int Line + { + get; + set; + } + + /// + /// Gets or sets the character number. + /// + [DataMember(Name = "character")] + public int Character + { + get; + set; + } + + /// + /// Overrides default equals operator. Two positions are equal if they are both null or one of them is the object equivalent of the other. + /// + /// The first position to compare. + /// The second position to compare. + /// True if both positions are null or one of them is the object equivalent of the other, false otherwise. + public static bool operator ==(Position? firstPosition, Position? secondPosition) + { + if (firstPosition is null && secondPosition is null) + { + return true; + } + + if (firstPosition is null && secondPosition is not null) + { + return false; + } + + if (firstPosition is not null && secondPosition is null) + { + return false; + } + + return firstPosition!.Equals(secondPosition!); + } + + /// + /// Overrides the default not equals operator. + /// + /// The first position to compare. + /// The second position to compare. + /// True if first and second positions are not equivalent. + public static bool operator !=(Position? firstPosition, Position? secondPosition) + { + return !(firstPosition == secondPosition); + } + + /// + /// Overrides base class method . Two positions are equal if their line and character are the same. + /// + /// Object to compare to. + /// True if the given position has the same line and character; false otherwise. + public override bool Equals(object obj) + { + return this.Equals(obj as Position); + } + + /// + public bool Equals(Position? other) + { + return other != null && + this.Line == other.Line && + this.Character == other.Character; + } + + /// + /// Overrides base class method . + /// + /// Hashcode for this object. + public override int GetHashCode() + { + return this.Line ^ this.Character; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/PrepareRenameParams.cs b/src/Features/LanguageServer/Protocol/Protocol/PrepareRenameParams.cs new file mode 100644 index 0000000000000..73184699a73db --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/PrepareRenameParams.cs @@ -0,0 +1,37 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// Class representing the parameters for the 'textDocument/prepare' request. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class PrepareRenameParams : ITextDocumentPositionParams + { + /// + /// Gets or sets the value which identifies the document. + /// + [DataMember(Name = "textDocument")] + public TextDocumentIdentifier TextDocument + { + get; + set; + } + + /// + /// Gets or sets the position in which the rename is requested. + /// + [DataMember(Name = "position")] + public Position Position + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/PrepareSupportDefaultBehavior.cs b/src/Features/LanguageServer/Protocol/Protocol/PrepareSupportDefaultBehavior.cs new file mode 100644 index 0000000000000..90dfe145b7c39 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/PrepareSupportDefaultBehavior.cs @@ -0,0 +1,22 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// Enum representing the default behavior used by the client for computing a rename range. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal enum PrepareSupportDefaultBehavior + { + /// + /// The client's default behavior is to select the identifier according to the language's syntax rule. + /// + Identifier = 1, + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/PreviousResultId.cs b/src/Features/LanguageServer/Protocol/Protocol/PreviousResultId.cs new file mode 100644 index 0000000000000..59026f13ff01c --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/PreviousResultId.cs @@ -0,0 +1,39 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol; + +using System; +using System.Runtime.Serialization; +using Newtonsoft.Json; + +/// +/// Class representing a previous result id in a workspace pull request. +/// +/// See the Language Server Protocol specification for additional information. +/// +[DataContract] +internal class PreviousResultId +{ + /// + /// Gets or sets the URI for which the client knows a result id. + /// + [DataMember(Name = "uri")] + [JsonConverter(typeof(DocumentUriConverter))] + public Uri Uri + { + get; + set; + } + + /// + /// Gets or sets the value of the previous result id. + /// + [DataMember(Name = "value")] + public string Value + { + get; + set; + } +} \ No newline at end of file diff --git a/src/Features/LanguageServer/Protocol/Protocol/PublishDiagnosticParams.cs b/src/Features/LanguageServer/Protocol/Protocol/PublishDiagnosticParams.cs new file mode 100644 index 0000000000000..c8cdae892ad2e --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/PublishDiagnosticParams.cs @@ -0,0 +1,40 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System; + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class which represents the parameter that's sent with 'textDocument/publishDiagnostics' messages. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class PublishDiagnosticParams + { + /// + /// Gets or sets the URI of the text document. + /// + [DataMember(Name = "uri")] + [JsonConverter(typeof(DocumentUriConverter))] + public Uri Uri + { + get; + set; + } + + /// + /// Gets or sets the collection of diagnostics. + /// + [DataMember(Name = "diagnostics")] + public Diagnostic[] Diagnostics + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/PublishDiagnosticsSetting.cs b/src/Features/LanguageServer/Protocol/Protocol/PublishDiagnosticsSetting.cs new file mode 100644 index 0000000000000..044cc92b08910 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/PublishDiagnosticsSetting.cs @@ -0,0 +1,29 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing the initialization setting for publish diagnostics. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class PublishDiagnosticsSetting + { + /// + /// Gets or sets a value indicating whether gets or sets the capabilities. + /// + [DataMember(Name = "tagSupport")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public TagSupport? TagSupport + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Range.cs b/src/Features/LanguageServer/Protocol/Protocol/Range.cs new file mode 100644 index 0000000000000..47284808a2d33 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Range.cs @@ -0,0 +1,86 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System; + using System.Collections.Generic; + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class which represents a text document text range. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class Range : IEquatable + { + /// + /// Gets or sets the text start position. + /// + [DataMember(Name = "start")] + [JsonProperty(Required = Required.Always)] + public Position Start + { + get; + set; + } + + /// + /// Gets or sets the text end position. + /// + [DataMember(Name = "end")] + [JsonProperty(Required = Required.Always)] + public Position End + { + get; + set; + } + + public static bool operator ==(Range? value1, Range? value2) + { + if (ReferenceEquals(value1, value2)) + { + return true; + } + + // Is null? + if (ReferenceEquals(null, value2)) + { + return false; + } + + return value1?.Equals(value2) ?? false; + } + + public static bool operator !=(Range? value1, Range? value2) + { + return !(value1 == value2); + } + + /// + public override bool Equals(object obj) + { + return this.Equals(obj as Range); + } + + /// + public bool Equals(Range? other) + { + return other != null && + EqualityComparer.Default.Equals(this.Start, other.Start) && + EqualityComparer.Default.Equals(this.End, other.End); + } + + /// + public override int GetHashCode() + { + var hashCode = -1676728671; + hashCode = (hashCode * -1521134295) + EqualityComparer.Default.GetHashCode(this.Start); + hashCode = (hashCode * -1521134295) + EqualityComparer.Default.GetHashCode(this.End); + return hashCode; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/ReferenceContext.cs b/src/Features/LanguageServer/Protocol/Protocol/ReferenceContext.cs new file mode 100644 index 0000000000000..36703524d53bd --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/ReferenceContext.cs @@ -0,0 +1,27 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// Class representing reference context information for find reference request parameter. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class ReferenceContext + { + /// + /// Gets or sets a value indicating whether declaration should be included. + /// + [DataMember(Name = "includeDeclaration")] + public bool IncludeDeclaration + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/ReferenceOptions.cs b/src/Features/LanguageServer/Protocol/Protocol/ReferenceOptions.cs new file mode 100644 index 0000000000000..28efc1c1f90d4 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/ReferenceOptions.cs @@ -0,0 +1,29 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class which represents workspace symbols capabilities. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class ReferenceOptions : IWorkDoneProgressOptions + { + /// + /// Gets or sets a value indicating whether work done progress is supported. + /// + [DataMember(Name = "workDoneProgress")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool WorkDoneProgress + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/ReferenceParams.cs b/src/Features/LanguageServer/Protocol/Protocol/ReferenceParams.cs new file mode 100644 index 0000000000000..0809067d7a9ef --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/ReferenceParams.cs @@ -0,0 +1,43 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System; + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing find reference parameter for find reference request. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class ReferenceParams : TextDocumentPositionParams, IPartialResultParams + { + // Using IPartialResultParams instead of IPartialResultParams to + // allow the VS protocol extension to allow returning VSReferenceItem[] + + /// + /// Gets or sets the reference context. + /// + [DataMember(Name = "context")] + public ReferenceContext Context + { + get; + set; + } + + /// + /// Gets or sets the value of the PartialResultToken instance. + /// + [DataMember(Name = Methods.PartialResultTokenName, IsRequired = false)] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public IProgress? PartialResultToken + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Registration.cs b/src/Features/LanguageServer/Protocol/Protocol/Registration.cs new file mode 100644 index 0000000000000..fcf186fb298ff --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Registration.cs @@ -0,0 +1,49 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing the general registration information for registering for a capability. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class Registration + { + /// + /// Gets or sets the id used to register the request. This can be used to deregister later. + /// + [DataMember(Name = "id")] + public string Id + { + get; + set; + } + + /// + /// Gets or sets the method / capability to register for. + /// + [DataMember(Name = "method")] + public string Method + { + get; + set; + } + + /// + /// Gets or sets the options necessary for registration. + /// + [DataMember(Name = "registerOptions")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public object? RegisterOptions + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/RegistrationParams.cs b/src/Features/LanguageServer/Protocol/Protocol/RegistrationParams.cs new file mode 100644 index 0000000000000..0a212c4740440 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/RegistrationParams.cs @@ -0,0 +1,27 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// Class representing the parameters sent for the client/registerCapability request. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class RegistrationParams + { + /// + /// Gets or sets the set of capabilities that are being registered. + /// + [DataMember(Name = "registrations")] + public Registration[] Registrations + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/RelatedFullDocumentDiagnosticReport.cs b/src/Features/LanguageServer/Protocol/Protocol/RelatedFullDocumentDiagnosticReport.cs new file mode 100644 index 0000000000000..6c672b19efdaf --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/RelatedFullDocumentDiagnosticReport.cs @@ -0,0 +1,31 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol; + +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; +using Newtonsoft.Json; + +/// +/// Class representing a full diagnostic report with a set of related documents. +/// +/// See the Language Server Protocol specification for additional information. +/// +[DataContract] +[Kind(DocumentDiagnosticReportKind.Full)] +internal class RelatedFullDocumentDiagnosticReport : FullDocumentDiagnosticReport +{ + /// + /// Gets or sets the map of related document diagnostic reports. + /// + [DataMember(Name = "relatedDocuments")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public Dictionary>? RelatedDocuments + { + get; + set; + } +} \ No newline at end of file diff --git a/src/Features/LanguageServer/Protocol/Protocol/RelatedUnchangedDocumentDiagnosticReport.cs b/src/Features/LanguageServer/Protocol/Protocol/RelatedUnchangedDocumentDiagnosticReport.cs new file mode 100644 index 0000000000000..b4f1c2949d759 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/RelatedUnchangedDocumentDiagnosticReport.cs @@ -0,0 +1,31 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol; + +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; +using Newtonsoft.Json; + +/// +/// Class representing an unchanged diagnostic report with a set of related documents. +/// +/// See the Language Server Protocol specification for additional information. +/// +[DataContract] +[Kind(DocumentDiagnosticReportKind.Unchanged)] +internal class RelatedUnchangedDocumentDiagnosticReport : UnchangedDocumentDiagnosticReport +{ + /// + /// Gets or sets the map of related document diagnostic reports. + /// + [DataMember(Name = "relatedDocuments")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public Dictionary>? RelatedDocuments + { + get; + set; + } +} \ No newline at end of file diff --git a/src/Features/LanguageServer/Protocol/Protocol/RenameClientCapabilities.cs b/src/Features/LanguageServer/Protocol/Protocol/RenameClientCapabilities.cs new file mode 100644 index 0000000000000..df1fc09d55b7f --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/RenameClientCapabilities.cs @@ -0,0 +1,57 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using System.Xml.Linq; + using Newtonsoft.Json; + using Newtonsoft.Json.Linq; + using static System.Net.Mime.MediaTypeNames; + + /// + /// Class which represents renaming client capabilities. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class RenameClientCapabilities : DynamicRegistrationSetting + { + /// + /// Gets or sets a value indicating whether the client supports testing for validity of rename operations before execution. + /// + [DataMember(Name = "prepareSupport")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool PrepareSupport + { + get; + set; + } + + /// + /// Gets or sets the value indicating the default behavior used by the client when the (`{ defaultBehavior: boolean }`) + /// result is used in the 'textDocument/prepareRename' request. + /// + [DataMember(Name = "prepareSupportDefaultBehavior")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public PrepareSupportDefaultBehavior? PrepareSupportDefaultBehavior + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether the client honors the change annotations in text edits and resource + /// operations returned via the rename request's workspace edit, by for example presenting the workspace edit in + /// the user interface and asking for confirmation. + /// + [DataMember(Name = "honorsChangeAnnotations")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool HonorsChangeAnnotations + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/RenameFile.cs b/src/Features/LanguageServer/Protocol/Protocol/RenameFile.cs new file mode 100644 index 0000000000000..9e7a366ef345a --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/RenameFile.cs @@ -0,0 +1,60 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System; + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing a rename file operation. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + [Kind("rename")] + internal class RenameFile + { + /// + /// Gets the kind value. + /// + [DataMember(Name = "kind")] + [System.Diagnostics.CodeAnalysis.SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "Member can't be static since it's part of the protocol")] + public string Kind => "rename"; + + /// + /// Gets or sets the old (existing) location. + /// + [DataMember(Name = "oldUri", IsRequired = true)] + [JsonConverter(typeof(DocumentUriConverter))] + public Uri OldUri + { + get; + set; + } + + /// + /// Gets or sets the new location. + /// + [DataMember(Name = "newUri", IsRequired = true)] + [JsonConverter(typeof(DocumentUriConverter))] + public Uri NewUri + { + get; + set; + } + + /// + /// Gets or sets the rename options. + /// + [DataMember(Name = "options")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public RenameFileOptions? Options + { + get; + set; + } + } +} \ No newline at end of file diff --git a/src/Features/LanguageServer/Protocol/Protocol/RenameFileOptions.cs b/src/Features/LanguageServer/Protocol/Protocol/RenameFileOptions.cs new file mode 100644 index 0000000000000..64af96d73853a --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/RenameFileOptions.cs @@ -0,0 +1,40 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing the options for a create file operation. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class RenameFileOptions + { + /// + /// Gets or sets a value indicating whether the rename should overwrite the target if it already exists. (Overwrite wins over ignoreIfExists). + /// + [DataMember(Name = "overwrite")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool Overwrite + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether the action should be ignored if the file already exists. + /// + [DataMember(Name = "ignoreIfExists")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool IgnoreIfExists + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/RenameOptions.cs b/src/Features/LanguageServer/Protocol/Protocol/RenameOptions.cs new file mode 100644 index 0000000000000..0b82f0e875713 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/RenameOptions.cs @@ -0,0 +1,40 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing the rename options for server capabilities. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class RenameOptions : IWorkDoneProgressOptions + { + /// + /// Gets or sets a value indicating whether renames should be checked and tested before being executed. + /// + [DataMember(Name = "prepareProvider")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool PrepareProvider + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether work done progress is supported. + /// + [DataMember(Name = "workDoneProgress")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool WorkDoneProgress + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/RenameParams.cs b/src/Features/LanguageServer/Protocol/Protocol/RenameParams.cs new file mode 100644 index 0000000000000..29b85b249c9a3 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/RenameParams.cs @@ -0,0 +1,27 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// Class representing the rename parameters for the textDocument/rename request. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class RenameParams : TextDocumentPositionParams + { + /// + /// Gets or sets the new name of the renamed symbol. + /// + [DataMember(Name = "newName")] + public string NewName + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/RenameRange.cs b/src/Features/LanguageServer/Protocol/Protocol/RenameRange.cs new file mode 100644 index 0000000000000..f424a260e236c --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/RenameRange.cs @@ -0,0 +1,40 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class which represents a possible result value of the 'textDocument/prepareRename' request. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class RenameRange + { + /// + /// Gets or sets the range of the string to rename. + /// + [DataMember(Name = "range")] + [JsonProperty(Required = Required.Always)] + public Range Range + { + get; + set; + } + + /// + /// Gets or sets the placeholder text of the string content to be renamed. + /// + [DataMember(Name = "placeholder")] + [JsonProperty(Required = Required.Always)] + public string Placeholder + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/ResolveSupportSetting.cs b/src/Features/LanguageServer/Protocol/Protocol/ResolveSupportSetting.cs new file mode 100644 index 0000000000000..aa05c8d8e28ed --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/ResolveSupportSetting.cs @@ -0,0 +1,27 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// Class which represents initialization setting for properties a client can resolve lazily on a completion item. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class ResolveSupportSetting + { + /// + /// Gets or sets a value indicating the properties that a client can resolve lazily. + /// + [DataMember(Name = "properties", IsRequired = true)] + public string[] Properties + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/ResourceOperationKind.cs b/src/Features/LanguageServer/Protocol/Protocol/ResourceOperationKind.cs new file mode 100644 index 0000000000000..1b56ff4510eaf --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/ResourceOperationKind.cs @@ -0,0 +1,36 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.ComponentModel; + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Value representing the kind of resource operations supported by the client. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + [JsonConverter(typeof(StringEnumConverter))] + [TypeConverter(typeof(StringEnumConverter.TypeConverter))] + internal readonly record struct ResourceOperationKind(string Value) : IStringEnum + { + /// + /// Supports creating new files and folders. + /// + public static readonly ResourceOperationKind Create = new("create"); + + /// + /// Supports renaming existing files and folders. + /// + public static readonly ResourceOperationKind Rename = new("rename"); + + /// + /// Supports deleting existing files and folders. + /// + public static readonly ResourceOperationKind Delete = new("delete"); + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/SaveOptions.cs b/src/Features/LanguageServer/Protocol/Protocol/SaveOptions.cs new file mode 100644 index 0000000000000..e14887dc310ef --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/SaveOptions.cs @@ -0,0 +1,29 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class which represents save option configurations. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class SaveOptions + { + /// + /// Gets or sets a value indicating whether clients include text content on save. + /// + [DataMember(Name = "includeText")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool IncludeText + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/SemanticTokens/SemanticTokenFormat.cs b/src/Features/LanguageServer/Protocol/Protocol/SemanticTokens/SemanticTokenFormat.cs new file mode 100644 index 0000000000000..3b46370ef84c7 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/SemanticTokens/SemanticTokenFormat.cs @@ -0,0 +1,26 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.ComponentModel; + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Value representing the format used to describe semantic tokens. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + [JsonConverter(typeof(StringEnumConverter))] + [TypeConverter(typeof(StringEnumConverter.TypeConverter))] + internal readonly record struct SemanticTokenFormat(string Value) : IStringEnum + { + /// + /// Tokens are described using relative positions. + /// + public static readonly SemanticTokenFormat Relative = new("relative"); + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/SemanticTokens/SemanticTokenModifiers.cs b/src/Features/LanguageServer/Protocol/Protocol/SemanticTokens/SemanticTokenModifiers.cs new file mode 100644 index 0000000000000..4505618601577 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/SemanticTokens/SemanticTokenModifiers.cs @@ -0,0 +1,81 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Collections.Generic; + + /// + /// Well-known semantic token modifiers. + /// + internal static class SemanticTokenModifiers + { + /// + /// Semantic token modifier for 'declaration'. + /// + public const string Declaration = "declaration"; + + /// + /// Semantic token modifier for 'definition'. + /// + public const string Definition = "definition"; + + /// + /// Semantic token modifier for 'readonly'. + /// + public const string Readonly = "readonly"; + + /// + /// Semantic token modifier for 'static'. + /// + public const string Static = "static"; + + /// + /// Semantic token modifier for 'deprecated'. + /// + public const string Deprecated = "deprecated"; + + /// + /// Semantic token modifier for 'abstract'. + /// + public const string Abstract = "abstract"; + + /// + /// Semantic token modifier for 'async'. + /// + public const string Async = "async"; + + /// + /// Semantic token modifier for 'modification'. + /// + public const string Modification = "modification"; + + /// + /// Semantic token modifier for 'documentation'. + /// + public const string Documentation = "documentation"; + + /// + /// Semantic token modifier for 'defaultLibrary'. + /// + public const string DefaultLibrary = "defaultLibrary"; + + /// + /// Collection containing all well-known semantic tokens modifiers. + /// + public static readonly IReadOnlyList AllModifiers = new[] + { + Declaration, + Definition, + Readonly, + Static, + Deprecated, + Abstract, + Async, + Modification, + Documentation, + DefaultLibrary, + }; + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/SemanticTokens/SemanticTokenTypes.cs b/src/Features/LanguageServer/Protocol/Protocol/SemanticTokens/SemanticTokenTypes.cs new file mode 100644 index 0000000000000..c4d4d4278729d --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/SemanticTokens/SemanticTokenTypes.cs @@ -0,0 +1,154 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Collections.Generic; + + /// + /// Well-known semantic tokens types. + /// + internal static class SemanticTokenTypes + { + /// + /// Semantic token modifier for 'namespace'. + /// + public const string Namespace = "namespace"; + + /// + /// Semantic token modifier for 'type'. + /// + public const string Type = "type"; + + /// + /// Semantic token modifier for 'class'. + /// + public const string Class = "class"; + + /// + /// Semantic token modifier for 'enum'. + /// + public const string Enum = "enum"; + + /// + /// Semantic token modifier for 'interface'. + /// + public const string Interface = "interface"; + + /// + /// Semantic token modifier for 'struct'. + /// + public const string Struct = "struct"; + + /// + /// Semantic token modifier for 'typeParameter'. + /// + public const string TypeParameter = "typeParameter"; + + /// + /// Semantic token modifier for 'parameter'. + /// + public const string Parameter = "parameter"; + + /// + /// Semantic token modifier for 'variable'. + /// + public const string Variable = "variable"; + + /// + /// Semantic token modifier for 'property'. + /// + public const string Property = "property"; + + /// + /// Semantic token modifier for 'enumMember'. + /// + public const string EnumMember = "enumMember"; + + /// + /// Semantic token modifier for 'event'. + /// + public const string Event = "event"; + + /// + /// Semantic token modifier for 'function'. + /// + public const string Function = "function"; + + /// + /// Semantic token modifier for 'method'. + /// + public const string Method = "method"; + + /// + /// Semantic token modifier for 'macro'. + /// + public const string Macro = "macro"; + + /// + /// Semantic token modifier for 'keyword'. + /// + public const string Keyword = "keyword"; + + /// + /// Semantic token modifier for 'modifier'. + /// + public const string Modifier = "modifier"; + + /// + /// Semantic token modifier for 'comment'. + /// + public const string Comment = "comment"; + + /// + /// Semantic token modifier for 'string'. + /// + [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1720:Identifier contains type name", Justification = "Protocol defines this as String")] + public const string String = "string"; + + /// + /// Semantic token modifier for 'number'. + /// + public const string Number = "number"; + + /// + /// Semantic token modifier for 'regexp'. + /// + public const string Regexp = "regexp"; + + /// + /// Semantic token modifier for 'operator'. + /// + public const string Operator = "operator"; + + /// + /// Collection containing all well-known semantic tokens types. + /// + public static readonly IReadOnlyList AllTypes = new[] + { + Namespace, + Type, + Class, + Enum, + Interface, + Struct, + TypeParameter, + Parameter, + Variable, + Property, + EnumMember, + Event, + Function, + Method, + Macro, + Keyword, + Modifier, + Comment, + String, + Number, + Regexp, + Operator, + }; + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/SemanticTokens/SemanticTokens.cs b/src/Features/LanguageServer/Protocol/Protocol/SemanticTokens/SemanticTokens.cs new file mode 100644 index 0000000000000..5b1c243765f2a --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/SemanticTokens/SemanticTokens.cs @@ -0,0 +1,31 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing response to semantic tokens messages. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class SemanticTokens + { + /// + /// Gets or sets a property that identifies this version of the document's semantic tokens. + /// + [DataMember(Name = "resultId")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? ResultId { get; set; } + + /// + /// Gets or sets and array containing encoded semantic tokens data. + /// + [DataMember(Name = "data", IsRequired = true)] + public int[] Data { get; set; } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/SemanticTokens/SemanticTokensDelta.cs b/src/Features/LanguageServer/Protocol/Protocol/SemanticTokens/SemanticTokensDelta.cs new file mode 100644 index 0000000000000..c67e0d1e61523 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/SemanticTokens/SemanticTokensDelta.cs @@ -0,0 +1,34 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System; + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Represents a response from a semantic tokens Document provider Edits request. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class SemanticTokensDelta + { + /// + /// Gets or sets the Id for the client's new version after applying all + /// edits to their current semantic tokens data. + /// + [DataMember(Name = "resultId")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? ResultId { get; set; } + + /// + /// Gets or sets an array of edits to apply to a previous response from a + /// semantic tokens Document provider. + /// + [DataMember(Name = "edits", IsRequired = true)] + public SemanticTokensEdit[] Edits { get; set; } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/SemanticTokens/SemanticTokensDeltaParams.cs b/src/Features/LanguageServer/Protocol/Protocol/SemanticTokens/SemanticTokensDeltaParams.cs new file mode 100644 index 0000000000000..eee3588bb8a02 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/SemanticTokens/SemanticTokensDeltaParams.cs @@ -0,0 +1,44 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System; + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Parameters for a request for Edits that can be applied to a previous response + /// from a semantic tokens Document provider. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class SemanticTokensDeltaParams : ITextDocumentParams, IPartialResultParams + { + /// + /// Gets or sets an identifier for the document to fetch semantic tokens from. + /// + [DataMember(Name = "textDocument")] + public TextDocumentIdentifier TextDocument { get; set; } + + /// + /// Gets or sets a property indicating the version of the semantic + /// tokens Document provider response that the edits will be applied to. + /// + [DataMember(Name = "previousResultId")] + public string PreviousResultId { get; set; } + + /// + /// Gets or sets the value of the Progress instance. + /// + [DataMember(Name = Methods.PartialResultTokenName, IsRequired = false)] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public IProgress? PartialResultToken + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/SemanticTokens/SemanticTokensDeltaPartialResult.cs b/src/Features/LanguageServer/Protocol/Protocol/SemanticTokens/SemanticTokensDeltaPartialResult.cs new file mode 100644 index 0000000000000..5905b06a385ab --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/SemanticTokens/SemanticTokensDeltaPartialResult.cs @@ -0,0 +1,26 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System; + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Represents a response from a semantic tokens Document provider Edits request. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class SemanticTokensDeltaPartialResult + { + /// + /// Gets or sets an array of edits to apply to a previous response from a + /// semantic tokens Document provider. + /// + [DataMember(Name = "edits", IsRequired = true)] + public SemanticTokensEdit[] Edits { get; set; } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/SemanticTokens/SemanticTokensEdit.cs b/src/Features/LanguageServer/Protocol/Protocol/SemanticTokens/SemanticTokensEdit.cs new file mode 100644 index 0000000000000..9958a6d858b5c --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/SemanticTokens/SemanticTokensEdit.cs @@ -0,0 +1,51 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System; + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing an individual edit incrementally applied to a previous + /// semantic tokens response from the Document provider. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1036:Override methods on comparable types", Justification = "Pending implementation of IComparable")] + internal class SemanticTokensEdit : IComparable + { + /// + /// Gets or sets the position in the previous response's + /// to begin the edit. + /// + [DataMember(Name = "start")] + public int Start { get; set; } + + /// + /// Gets or sets the number of numbers to delete in the + /// from the previous response. + /// + [DataMember(Name = "deleteCount")] + public int DeleteCount { get; set; } + + /// + /// Gets or sets an array containing the encoded semantic tokens information to insert + /// into a previous response. + /// + [DataMember(Name = "data")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public int[]? Data { get; set; } + + /// + /// Compares two s based on their order. + /// + /// The other edit. + /// -1 if this item comes first and 1 if it comes second. + public int CompareTo(SemanticTokensEdit? other) + => other is null ? -1 : this.Start.CompareTo(other.Start); + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/SemanticTokens/SemanticTokensFullOptions.cs b/src/Features/LanguageServer/Protocol/Protocol/SemanticTokens/SemanticTokensFullOptions.cs new file mode 100644 index 0000000000000..ac04122c1dd4e --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/SemanticTokens/SemanticTokensFullOptions.cs @@ -0,0 +1,29 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Options for the full document semantic tokens classification provider. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class SemanticTokensFullOptions + { + /// + /// Gets or sets a value indicating whether the server supports deltas for full documents. + /// + [DataMember(Name = "delta")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool Delta + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/SemanticTokens/SemanticTokensLegend.cs b/src/Features/LanguageServer/Protocol/Protocol/SemanticTokens/SemanticTokensLegend.cs new file mode 100644 index 0000000000000..1e2deb490d8b4 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/SemanticTokens/SemanticTokensLegend.cs @@ -0,0 +1,37 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// Legend used to encode semantic token types in . + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class SemanticTokensLegend + { + /// + /// Gets or sets an array of token types that can be encoded in semantic tokens responses. + /// + [DataMember(Name = "tokenTypes")] + public string[] TokenTypes + { + get; + set; + } + + /// + /// Gets or sets an array of token modfiers that can be encoded in semantic tokens responses. + /// + [DataMember(Name = "tokenModifiers")] + public string[] TokenModifiers + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/SemanticTokens/SemanticTokensOptions.cs b/src/Features/LanguageServer/Protocol/Protocol/SemanticTokens/SemanticTokensOptions.cs new file mode 100644 index 0000000000000..d3b2e6b98f9a1 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/SemanticTokens/SemanticTokensOptions.cs @@ -0,0 +1,49 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Initialization options for semantic tokens support. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class SemanticTokensOptions : IWorkDoneProgressOptions + { + /// + /// Gets or sets a legend describing how semantic token types and modifiers are encoded in responses. + /// + [DataMember(Name = "legend")] + public SemanticTokensLegend Legend { get; set; } + + /// + /// Gets or sets a value indicating whether semantic tokens Range provider requests are supported. + /// + [DataMember(Name = "range")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public SumType? Range { get; set; } + + /// + /// Gets or sets whether or not the server supports providing semantic tokens for a full document. + /// + [DataMember(Name = "full")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public SumType? Full { get; set; } + + /// + /// Gets or sets a value indicating whether work done progress is supported. + /// + [DataMember(Name = "workDoneProgress")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool WorkDoneProgress + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/SemanticTokens/SemanticTokensParams.cs b/src/Features/LanguageServer/Protocol/Protocol/SemanticTokens/SemanticTokensParams.cs new file mode 100644 index 0000000000000..f388365622b58 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/SemanticTokens/SemanticTokensParams.cs @@ -0,0 +1,36 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System; + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Parameters for semantic tokens full Document request. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class SemanticTokensParams : ITextDocumentParams, IPartialResultParams + { + /// + /// Gets or sets an identifier for the document to fetch semantic tokens from. + /// + [DataMember(Name = "textDocument")] + public TextDocumentIdentifier TextDocument { get; set; } + + /// + /// Gets or sets the value of the Progress instance. + /// + [DataMember(Name = Methods.PartialResultTokenName, IsRequired = false)] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public IProgress? PartialResultToken + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/SemanticTokens/SemanticTokensPartialResult.cs b/src/Features/LanguageServer/Protocol/Protocol/SemanticTokens/SemanticTokensPartialResult.cs new file mode 100644 index 0000000000000..fef2fa0b35b48 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/SemanticTokens/SemanticTokensPartialResult.cs @@ -0,0 +1,23 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// Class representing response to semantic tokens messages. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class SemanticTokensPartialResult + { + /// + /// Gets or sets and array containing encoded semantic tokens data. + /// + [DataMember(Name = "data", IsRequired = true)] + public int[] Data { get; set; } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/SemanticTokens/SemanticTokensRangeParams.cs b/src/Features/LanguageServer/Protocol/Protocol/SemanticTokens/SemanticTokensRangeParams.cs new file mode 100644 index 0000000000000..b99746321df5b --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/SemanticTokens/SemanticTokensRangeParams.cs @@ -0,0 +1,23 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// Parameters for the semantic tokens Range request. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class SemanticTokensRangeParams : SemanticTokensParams + { + /// + /// Gets or sets the range within the document to fetch semantic tokens for. + /// + [DataMember(Name = "range")] + public Range Range { get; set; } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/SemanticTokens/SemanticTokensRequestsFullSetting.cs b/src/Features/LanguageServer/Protocol/Protocol/SemanticTokens/SemanticTokensRequestsFullSetting.cs new file mode 100644 index 0000000000000..60311963550f3 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/SemanticTokens/SemanticTokensRequestsFullSetting.cs @@ -0,0 +1,28 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Client settings for semantic tokens related to the + /// `textDocument/semanticTokens/full` message. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class SemanticTokensRequestsFullSetting + { + /// + /// Gets or sets a value indicating whether the client will send the + /// textDocument/semanticTokens/full/delta request if the server + /// provides a corresponding handler. + /// + [DataMember(Name = "range")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool Delta { get; set; } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/SemanticTokens/SemanticTokensRequestsSetting.cs b/src/Features/LanguageServer/Protocol/Protocol/SemanticTokens/SemanticTokensRequestsSetting.cs new file mode 100644 index 0000000000000..26884ccc267b2 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/SemanticTokens/SemanticTokensRequestsSetting.cs @@ -0,0 +1,36 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Requests client settings for semantic tokens. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class SemanticTokensRequestsSetting + { + /// + /// Gets or sets a value indicating whether the client will send the + /// `textDocument/semanticTokens/range` request if the server provides a + /// corresponding handler. + /// + [DataMember(Name = "range")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public SumType? Range { get; set; } + + /// + /// Gets or sets a value indicating whether the client will send the + /// `textDocument/semanticTokens/full` request if the server provides a + /// corresponding handler. + /// + [DataMember(Name = "full")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public SumType? Full { get; set; } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/SemanticTokens/SemanticTokensSetting.cs b/src/Features/LanguageServer/Protocol/Protocol/SemanticTokens/SemanticTokensSetting.cs new file mode 100644 index 0000000000000..ddef8c880b076 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/SemanticTokens/SemanticTokensSetting.cs @@ -0,0 +1,59 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Client settings for semantic tokens. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class SemanticTokensSetting : DynamicRegistrationSetting + { + /// + /// Gets or sets a value indicating which requests the client supports and might send to the server + /// depending on the server's capability. + /// + [DataMember(Name = "requests")] + public SemanticTokensRequestsSetting Requests { get; set; } + + /// + /// Gets or sets an array of token types supported by the client for encoding + /// semantic tokens. + /// + [DataMember(Name = "tokenTypes")] + public string[] TokenTypes { get; set; } + + /// + /// Gets or sets an array of token modifiers supported by the client for encoding + /// semantic tokens. + /// + [DataMember(Name = "tokenModifiers")] + public string[] TokenModifiers { get; set; } + + /// + /// Gets or sets an array of formats the clients supports. + /// + [DataMember(Name = "formats")] + public SemanticTokenFormat[] Formats { get; set; } + + /// + /// Gets or sets a value indicating whether the client supports tokens that can overlap each other. + /// + [DataMember(Name = "overlappingTokenSupport")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool OverlappingTokenSupport { get; set; } + + /// + /// Gets or sets a value indicating whether the client supports tokens that can span multiple lines. + /// + [DataMember(Name = "multilineTokenSupport")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool MultilineTokenSupport { get; set; } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/SemanticTokens/SemanticTokensWorkspaceSetting.cs b/src/Features/LanguageServer/Protocol/Protocol/SemanticTokens/SemanticTokensWorkspaceSetting.cs new file mode 100644 index 0000000000000..dd101255ae22e --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/SemanticTokens/SemanticTokensWorkspaceSetting.cs @@ -0,0 +1,32 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Capabilities specific to the semantic token requests scoped to the workspace. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class SemanticTokensWorkspaceSetting + { + /// + /// Gets or sets a value indicating whether the client implementation + /// supports a refresh request sent from the server to the client. + /// + /// + /// Note that this event is global and will force the client to refresh all + /// semantic tokens currently shown.It should be used with absolute care + /// and is useful for situation where a server for example detect a project + /// wide change that requires such a calculation. + /// + [DataMember(Name = "refreshSupport")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool RefreshSupport { get; set; } + } +} \ No newline at end of file diff --git a/src/Features/LanguageServer/Protocol/Protocol/ServerCapabilities.cs b/src/Features/LanguageServer/Protocol/Protocol/ServerCapabilities.cs new file mode 100644 index 0000000000000..8e7416165f35f --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/ServerCapabilities.cs @@ -0,0 +1,315 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Diagnostics.CodeAnalysis; + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class which represents server capabilities. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class ServerCapabilities + { + /// + /// Gets or sets the value which indicates how text document are synced. + /// + [DataMember(Name = "textDocumentSync")] + [JsonConverter(typeof(TextDocumentSyncConverter))] + [SuppressMessage("Microsoft.StyleCop.CSharp.LayoutRules", "SA1513:ClosingCurlyBracketMustBeFollowedByBlankLine", Justification = "There are no issues with this code")] + [SuppressMessage("Microsoft.StyleCop.CSharp.LayoutRules", "SA1500:BracesForMultiLineStatementsShouldNotShareLine", Justification = "There are no issues with this code")] + public TextDocumentSyncOptions? TextDocumentSync + { + get; + set; + } = new TextDocumentSyncOptions + { + OpenClose = true, + Change = TextDocumentSyncKind.None, + Save = new SaveOptions + { + IncludeText = false, + }, + }; + + /// + /// Gets or sets the value which indicates if completions are supported. + /// + [DataMember(Name = "completionProvider")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public CompletionOptions? CompletionProvider + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether the server provides hover support. + /// + [DataMember(Name = "hoverProvider")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public SumType? HoverProvider + { + get; + set; + } + + /// + /// Gets or sets the value which indicates if signature help is supported. + /// + [DataMember(Name = "signatureHelpProvider")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public SignatureHelpOptions? SignatureHelpProvider + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether go to definition is supported. + /// + [DataMember(Name = "definitionProvider")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public SumType? DefinitionProvider + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether go to type definition is supported. + /// + [DataMember(Name = "typeDefinitionProvider")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public SumType? TypeDefinitionProvider + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether go to implementation is supported. + /// + [DataMember(Name = "implementationProvider")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public SumType? ImplementationProvider + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether find all references is supported. + /// + [DataMember(Name = "referencesProvider")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public SumType? ReferencesProvider + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether the server supports document highlight. + /// + [DataMember(Name = "documentHighlightProvider")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public SumType? DocumentHighlightProvider + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether document symbols are supported. + /// + [DataMember(Name = "documentSymbolProvider")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public SumType? DocumentSymbolProvider + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether code actions are supported. + /// + [DataMember(Name = "codeActionProvider")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public SumType? CodeActionProvider + { + get; + set; + } + + /// + /// Gets or sets the value which indicates if code lens is supported. + /// + [DataMember(Name = "codeLensProvider")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public CodeLensOptions? CodeLensProvider + { + get; + set; + } + + /// + /// Gets or sets the value which indicates if document link is supported. + /// + [DataMember(Name = "documentLinkProvider")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public DocumentLinkOptions? DocumentLinkProvider + { + get; + set; + } + + /// + /// Gets or sets the value which indicates if document color is supported. + /// + [DataMember(Name = "colorProvider")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public SumType? DocumentColorProvider + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether document formatting is supported. + /// + [DataMember(Name = "documentFormattingProvider")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public SumType? DocumentFormattingProvider + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether document range formatting is supported. + /// + [DataMember(Name = "documentRangeFormattingProvider")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public SumType? DocumentRangeFormattingProvider + { + get; + set; + } + + /// + /// Gets or sets the value which indicates if document on type formatting is supported. + /// + [DataMember(Name = "documentOnTypeFormattingProvider")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public DocumentOnTypeFormattingOptions? DocumentOnTypeFormattingProvider + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether rename is supported. + /// + [DataMember(Name = "renameProvider")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public SumType? RenameProvider + { + get; + set; + } + + /// + /// Gets or sets the value which indicates if folding range is supported. + /// + [DataMember(Name = "foldingRangeProvider")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public SumType? FoldingRangeProvider + { + get; + set; + } + + /// + /// Gets or sets the value which indicates if execute command is supported. + /// + [DataMember(Name = "executeCommandProvider")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public ExecuteCommandOptions? ExecuteCommandProvider + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether workspace symbols are supported. + /// + [DataMember(Name = "workspaceSymbolProvider")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public SumType? WorkspaceSymbolProvider + { + get; + set; + } + + /// + /// Gets or sets experimental server capabilities. + /// + [DataMember(Name = "experimental")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public object? Experimental + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether the server supports linked editing range. + /// + [DataMember(Name = "linkedEditingRangeProvider")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public SumType? LinkedEditingRangeProvider + { + get; + set; + } + + /// + /// Gets or sets the value which indicates if semantic tokens is supported. + /// + [DataMember(Name = "semanticTokensProvider")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public SemanticTokensOptions? SemanticTokensOptions + { + get; + set; + } + + /// + /// Gets or sets the value which indicates what support the server has for pull diagnostics. + /// + [DataMember(Name = "diagnosticProvider")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public DiagnosticOptions? DiagnosticOptions + { + get; + set; + } + + /// + /// Gets or sets the value which indicates what support the server has for inlay hints. + /// + [DataMember(Name = "inlayHintProvider")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public SumType? InlayHintOptions + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/ShowMessageParams.cs b/src/Features/LanguageServer/Protocol/Protocol/ShowMessageParams.cs new file mode 100644 index 0000000000000..d86b0e3ec53e7 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/ShowMessageParams.cs @@ -0,0 +1,37 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// Class which represents parameter sent with window/showMessage requests. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class ShowMessageParams + { + /// + /// Gets or sets the type of message. + /// + [DataMember(Name = "type")] + public MessageType MessageType + { + get; + set; + } + + /// + /// Gets or sets the message. + /// + [DataMember(Name = "message")] + public string Message + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/ShowMessageRequestParams.cs b/src/Features/LanguageServer/Protocol/Protocol/ShowMessageRequestParams.cs new file mode 100644 index 0000000000000..803ee910b8fa3 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/ShowMessageRequestParams.cs @@ -0,0 +1,29 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class which represents parameter sent with window/showMessageRequest requests. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class ShowMessageRequestParams : ShowMessageParams + { + /// + /// Gets or sets an array of s to present. + /// + [DataMember(Name = "actions")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public MessageActionItem[]? Actions + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/SignatureHelp.cs b/src/Features/LanguageServer/Protocol/Protocol/SignatureHelp.cs new file mode 100644 index 0000000000000..ff7baa6c8c6c2 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/SignatureHelp.cs @@ -0,0 +1,51 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing the signature of something callable. This class is returned from the textDocument/signatureHelp request. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class SignatureHelp + { + /// + /// Gets or sets an array of signatures associated with the callable item. + /// + [DataMember(Name = "signatures")] + [JsonProperty(Required = Required.Always)] + public SignatureInformation[] Signatures + { + get; + set; + } + + /// + /// Gets or sets the active signature. If the value is omitted or falls outside the range of Signatures it defaults to zero. + /// + [DataMember(Name = "activeSignature")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public int? ActiveSignature + { + get; + set; + } + + /// + /// Gets or sets the active parameter. If the value is omitted or falls outside the range of Signatures[ActiveSignature].Parameters it defaults to zero. + /// + [DataMember(Name = "activeParameter")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public int? ActiveParameter + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/SignatureHelpContext.cs b/src/Features/LanguageServer/Protocol/Protocol/SignatureHelpContext.cs new file mode 100644 index 0000000000000..4bc39650fc574 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/SignatureHelpContext.cs @@ -0,0 +1,61 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing additional information about the context in which a signature help request is triggered. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class SignatureHelpContext + { + /// + /// Gets or sets the indicating how the signature help was triggered. + /// + [DataMember(Name = "triggerKind")] + public SignatureHelpTriggerKind TriggerKind + { + get; + set; + } + + /// + /// Gets or sets the character that caused signature help to be triggered. + /// This value is null when triggerKind is not TriggerCharacter. + /// + [DataMember(Name = "triggerCharacter")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? TriggerCharacter + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether signature help was already showing when it was triggered. + /// + [DataMember(Name = "isRetrigger")] + public bool IsRetrigger + { + get; + set; + } + + /// + /// Gets or sets the currently active . + /// + [DataMember(Name = "activeSignatureHelp")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public SignatureHelp? ActiveSignatureHelp + { + get; + set; + } + } +} \ No newline at end of file diff --git a/src/Features/LanguageServer/Protocol/Protocol/SignatureHelpOptions.cs b/src/Features/LanguageServer/Protocol/Protocol/SignatureHelpOptions.cs new file mode 100644 index 0000000000000..9f73e0c712e0a --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/SignatureHelpOptions.cs @@ -0,0 +1,52 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing the options for signature help support. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class SignatureHelpOptions : IWorkDoneProgressOptions + { + /// + /// Gets or sets the characters that trigger signature help automatically. + /// + [DataMember(Name = "triggerCharacters")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string[]? TriggerCharacters + { + get; + set; + } + + /// + /// Gets or sets the characters that re-trigger signature help + /// when signature help is already showing. + /// + [DataMember(Name = "retriggerCharacters")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string[]? RetriggerCharacters + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether work done progress is supported. + /// + [DataMember(Name = "workDoneProgress")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool WorkDoneProgress + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/SignatureHelpParams.cs b/src/Features/LanguageServer/Protocol/Protocol/SignatureHelpParams.cs new file mode 100644 index 0000000000000..765bf13dbb073 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/SignatureHelpParams.cs @@ -0,0 +1,29 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing the parameters for the textDocument/signatureHelp request. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class SignatureHelpParams : TextDocumentPositionParams + { + /// + /// Gets or sets the signature help context. + /// + [DataMember(Name = "context")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public SignatureHelpContext? Context + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/SignatureHelpSetting.cs b/src/Features/LanguageServer/Protocol/Protocol/SignatureHelpSetting.cs new file mode 100644 index 0000000000000..7d12130ab2a96 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/SignatureHelpSetting.cs @@ -0,0 +1,41 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing the signature help initialization setting. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class SignatureHelpSetting : DynamicRegistrationSetting + { + /// + /// Gets or sets the information. + /// + [DataMember(Name = "signatureInformation")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public SignatureInformationSetting? SignatureInformation + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether additional context information + /// is supported for the `textDocument/signatureHelp` request. + /// + [DataMember(Name = "contextSupport")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool ContextSupport + { + get; + set; + } + } +} \ No newline at end of file diff --git a/src/Features/LanguageServer/Protocol/Protocol/SignatureHelpTriggerKind.cs b/src/Features/LanguageServer/Protocol/Protocol/SignatureHelpTriggerKind.cs new file mode 100644 index 0000000000000..2ffba29c58692 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/SignatureHelpTriggerKind.cs @@ -0,0 +1,32 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// Enum which represents the various ways in which completion can be triggered. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal enum SignatureHelpTriggerKind + { + /// + /// Signature help was invoked manually by the user or a command. + /// + Invoked = 1, + + /// + /// Signature help was triggered by a trigger character. + /// + TriggerCharacter = 2, + + /// + /// Signature help was triggered by the cursor moving or by the document content changing. + /// + ContentChange = 3, + } +} \ No newline at end of file diff --git a/src/Features/LanguageServer/Protocol/Protocol/SignatureInformation.cs b/src/Features/LanguageServer/Protocol/Protocol/SignatureInformation.cs new file mode 100644 index 0000000000000..6e68c4d386a97 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/SignatureInformation.cs @@ -0,0 +1,50 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing a single signature of a callable item. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class SignatureInformation + { + /// + /// Gets or sets the label of this signature. + /// + [DataMember(Name = "label")] + public string Label + { + get; + set; + } + + /// + /// Gets or sets the human-readable documentation of this signature. + /// + [DataMember(Name = "documentation")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public SumType? Documentation + { + get; + set; + } + + /// + /// Gets or sets the parameters of this signature. + /// + [DataMember(Name = "parameters")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public ParameterInformation[]? Parameters + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/SignatureInformationSetting.cs b/src/Features/LanguageServer/Protocol/Protocol/SignatureInformationSetting.cs new file mode 100644 index 0000000000000..083fa7dfc90a9 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/SignatureInformationSetting.cs @@ -0,0 +1,40 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing the signature information initialization setting. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class SignatureInformationSetting + { + /// + /// Gets or sets the set of documentation formats the client supports. + /// + [DataMember(Name = "documentationFormat")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public MarkupKind[]? DocumentationFormat + { + get; + set; + } + + /// + /// Gets or sets the parameter information the client supports. + /// + [DataMember(Name = "parameterInformation")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public ParameterInformationSetting? ParameterInformation + { + get; + set; + } + } +} \ No newline at end of file diff --git a/src/Features/LanguageServer/Protocol/Protocol/SumType.cs b/src/Features/LanguageServer/Protocol/Protocol/SumType.cs new file mode 100644 index 0000000000000..3c50c415f59a8 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/SumType.cs @@ -0,0 +1,889 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System; + using System.Collections.Generic; + using System.Diagnostics.CodeAnalysis; + using Newtonsoft.Json; + using System.Runtime.CompilerServices; + using Microsoft.CommonLanguageServerProtocol.Framework; + using Microsoft.CodeAnalysis.LanguageServer; + + /// + /// Struct that may contain a or a . + /// + /// The first type this struct is designed to contain. + /// The second type this struct is designed to contain. + [JsonConverter(typeof(SumConverter))] + internal struct SumType : ISumType, IEquatable> + where T1 : notnull + where T2 : notnull + { + static SumType() + { + SumTypeUtils.ValidateTypeParameter(typeof(T1)); + SumTypeUtils.ValidateTypeParameter(typeof(T2)); + } + + /// + /// Initializes a new instance of the struct containing a . + /// + /// The value to store in the . + public SumType(T1 val) + { + this.Value = val; + } + + /// + /// Initializes a new instance of the struct containing a . + /// + /// The value to store in the . + public SumType(T2 val) + { + this.Value = val; + } + + /// + public object? Value { get; } + + /// + /// Gets the value as the first specified type. + /// + public T1 First => (T1)this; + + /// + /// Gets the value as the second specified type. + /// + public T2 Second => (T2)this; + + /// + /// Implicitly wraps a value of type with a . + /// + /// Value to be wrapped. + public static implicit operator SumType(T1 val) => new SumType(val); + + /// + /// Implicitly wraps a value of type with a . + /// + /// Value to be wrapped. + public static implicit operator SumType?(T1? val) => val is null ? null : new SumType(val); + + /// + /// Implicitly wraps a value of type with a . + /// + /// Value to be wrapped. + public static implicit operator SumType(T2 val) => new SumType(val); + + /// + /// Implicitly wraps a value of type with a . + /// + /// Value to be wrapped. + public static implicit operator SumType?(T2? val) => val is null ? null : new SumType(val); + + /// + /// Attempts to cast an instance of to an instance of . + /// + /// Thrown if this instance of does not contain an instance of . + /// Instance to unwrap. + public static explicit operator T1(SumType sum) => sum.Value is T1 tVal ? tVal : throw new InvalidCastException(); + + /// + /// Attempts to cast an instance of to an instance of . + /// + /// Thrown if this instance of does not contain an instance of . + /// Instance to unwrap. + public static explicit operator T2(SumType sum) => sum.Value is T2 tVal ? tVal : throw new InvalidCastException(); + + public static bool operator ==(SumType left, SumType right) + { + return left.Equals(right); + } + + public static bool operator !=(SumType left, SumType right) + { + return !(left == right); + } + + /// + /// Tries to get the value as the first specified type. + /// + /// the value in the specified type. + /// if the type matches. + public bool TryGetFirst([MaybeNullWhen(false)] out T1 value) + { + if (this.Value is T1 typeValue) + { + value = typeValue; + return true; + } + + value = default; + return false; + } + + /// + /// Tries to get the value as the second specified type. + /// + /// the value in the specified type/>. + /// if the type matches. + public bool TryGetSecond([MaybeNullWhen(false)] out T2 value) + { + if (this.Value is T2 typeValue) + { + value = typeValue; + return true; + } + + value = default; + return false; + } + + /// + /// Runs a delegate corresponding to which type is contained inside this instance. + /// + /// The type that all the delegates will return. + /// Delegate to handle the case where this instance contains a . + /// Delegate to handle the case where this instance contains a . + /// + /// Delegate to handle the case where this instance is uninhabited. If this delegate isn't provided the default + /// will be returned instead. + /// + /// The instance created by the delegate corresponding to the current type stored in this instance. + public TResult Match(Func firstMatch, Func secondMatch, Func? defaultMatch = null) + { + if (firstMatch == null) + { + throw new ArgumentNullException(nameof(firstMatch)); + } + + if (secondMatch == null) + { + throw new ArgumentNullException(nameof(secondMatch)); + } + + if (this.Value is T1 tOne) + { + return firstMatch(tOne); + } + + if (this.Value is T2 tTwo) + { + return secondMatch(tTwo); + } + + if (defaultMatch != null) + { + return defaultMatch(); + } + +#pragma warning disable CS8603 // Possible null reference return. + return default(TResult); +#pragma warning restore CS8603 // Possible null reference return. + } + + /// + public override bool Equals(object obj) + { + return obj is SumType type && this.Equals(type); + } + + /// + public bool Equals(SumType other) + { + return EqualityComparer.Default.Equals(this.Value, other.Value); + } + + /// + public override int GetHashCode() + { + return -1937169414 + EqualityComparer.Default.GetHashCode(this.Value); + } + } + + /// + /// Struct that may contain a , a , or a . + /// + /// The first type this struct is designed to contain. + /// The second type this struct is designed to contain. + /// The third type this struct is designed to contain. + [JsonConverter(typeof(SumConverter))] + internal struct SumType : ISumType, IEquatable> + where T1 : notnull + where T2 : notnull + where T3 : notnull + { + static SumType() + { + SumTypeUtils.ValidateTypeParameter(typeof(T1)); + SumTypeUtils.ValidateTypeParameter(typeof(T2)); + SumTypeUtils.ValidateTypeParameter(typeof(T3)); + } + + /// + /// Initializes a new instance of the struct containing a . + /// + /// The value to store in the . + public SumType(T1 val) + { + this.Value = val; + } + + /// + /// Initializes a new instance of the struct containing a . + /// + /// The value to store in the . + public SumType(T2 val) + { + this.Value = val; + } + + /// + /// Initializes a new instance of the struct containing a . + /// + /// The value to store in the . + public SumType(T3 val) + { + this.Value = val; + } + + /// + public object? Value { get; } + + /// + /// Gets the value as the first specified type. + /// + public T1 First => (T1)this; + + /// + /// Gets the value as the second specified type. + /// + public T2 Second => (T2)this; + + /// + /// Gets the value as the third specified type. + /// + public T3 Third => (T3)this; + + /// + /// Implicitly wraps a value of type with a . + /// + /// Value to be wrap. + public static implicit operator SumType(T1 val) => new SumType(val); + + /// + /// Implicitly wraps a value of type with a . + /// + /// Value to be wrapped. + public static implicit operator SumType?(T1? val) => val is null ? null : new SumType(val); + + /// + /// Implicitly wraps a value of type with a . + /// + /// Value to be wrap. + public static implicit operator SumType(T2 val) => new SumType(val); + + /// + /// Implicitly wraps a value of type with a . + /// + /// Value to be wrapped. + public static implicit operator SumType?(T2? val) => val is null ? null : new SumType(val); + + /// + /// Implicitly wraps a value of type with a . + /// + /// Value to be wrap. + public static implicit operator SumType(T3 val) => new SumType(val); + + /// + /// Implicitly wraps a value of type with a . + /// + /// Value to be wrapped. + public static implicit operator SumType?(T3? val) => val is null ? null : new SumType(val); + + /// + /// Implicitly wraps an instance of with a . + /// + /// Sum instance to wrap. + public static implicit operator SumType(SumType sum) + => sum.Match( + (v) => new SumType(v), + (v) => new SumType(v)); + + /// + /// Attempts to cast an instance of into a . + /// + /// Sum instance to downcast. + public static explicit operator SumType(SumType sum) + { + if (sum.Value is T1 tOne) + { + return tOne; + } + + if (sum.Value is T2 tTwo) + { + return tTwo; + } + + throw new InvalidCastException(); + } + + /// + /// Attempts to cast an instance of to an instance of . + /// + /// Thrown if this instance of does not contain an instance of . + /// Instance to unwrap. + public static explicit operator T1(SumType sum) => sum.Value is T1 tVal ? tVal : throw new InvalidCastException(); + + /// + /// Attempts to cast an instance of to an instance of . + /// + /// Thrown if this instance of does not contain an instance of . + /// Instance to unwrap. + public static explicit operator T2(SumType sum) => sum.Value is T2 tVal ? tVal : throw new InvalidCastException(); + + /// + /// Attempts to cast an instance of to an instance of . + /// + /// Thrown if this instance of does not contain an instance of . + /// Instance to unwrap. + public static explicit operator T3(SumType sum) => sum.Value is T3 tVal ? tVal : throw new InvalidCastException(); + + public static bool operator ==(SumType left, SumType right) + { + return left.Equals(right); + } + + public static bool operator !=(SumType left, SumType right) + { + return !(left == right); + } + + /// + /// Tries to get the value as the first specified type. + /// + /// the value in the specified type/>. + /// if the type matches. + public bool TryGetFirst([MaybeNullWhen(false)] out T1 value) + { + if (this.Value is T1 typeValue) + { + value = typeValue; + return true; + } + + value = default; + return false; + } + + /// + /// Tries to get the value as the second specified type. + /// + /// the value in the specified type/>. + /// if the type matches. + public bool TryGetSecond([MaybeNullWhen(false)] out T2 value) + { + if (this.Value is T2 typeValue) + { + value = typeValue; + return true; + } + + value = default; + return false; + } + + /// + /// Tries to get the value as the third specified type. + /// + /// the value in the specified type/>. + /// if the type matches. + public bool TryGetThird([MaybeNullWhen(false)] out T3 value) + { + if (this.Value is T3 typeValue) + { + value = typeValue; + return true; + } + + value = default; + return false; + } + + /// + /// Runs a delegate corresponding to which type is contained inside this instance. + /// + /// The type that all the delegates will return. + /// Delegate to handle the case where this instance contains a . + /// Delegate to handle the case where this instance contains a . + /// Delegate to handle the case where this instance contains a . + /// + /// Delegate to handle the case where this instance is uninhabited. If this delegate isn't provided the default + /// will be returned instead. + /// + /// The instance created by the delegate corresponding to the current type stored in this instance. + public TResult Match(Func firstMatch, Func secondMatch, Func thirdMatch, Func? defaultMatch = null) + { + if (firstMatch == null) + { + throw new ArgumentNullException(nameof(firstMatch)); + } + + if (secondMatch == null) + { + throw new ArgumentNullException(nameof(secondMatch)); + } + + if (thirdMatch == null) + { + throw new ArgumentNullException(nameof(thirdMatch)); + } + + if (this.Value is T1 tOne) + { + return firstMatch(tOne); + } + + if (this.Value is T2 tTwo) + { + return secondMatch(tTwo); + } + + if (this.Value is T3 tThree) + { + return thirdMatch(tThree); + } + + if (defaultMatch != null) + { + return defaultMatch(); + } + +#pragma warning disable CS8603 // Possible null reference return. + return default(TResult); +#pragma warning restore CS8603 // Possible null reference return. + } + + /// + public override bool Equals(object obj) + { + return obj is SumType type && this.Equals(type); + } + + /// + public bool Equals(SumType other) + { + return EqualityComparer.Default.Equals(this.Value, other.Value); + } + + /// + public override int GetHashCode() + { + return -1937169414 + EqualityComparer.Default.GetHashCode(this.Value); + } + } + + /// + /// Struct that may contain a , a , a , or a . + /// + /// The first type this struct is designed to contain. + /// The second type this struct is designed to contain. + /// The third type this struct is designed to contain. + /// The fourth type this struct is designed to contain. + [JsonConverter(typeof(SumConverter))] + internal struct SumType : ISumType, IEquatable> + where T1 : notnull + where T2 : notnull + where T3 : notnull + where T4 : notnull + { + static SumType() + { + SumTypeUtils.ValidateTypeParameter(typeof(T1)); + SumTypeUtils.ValidateTypeParameter(typeof(T2)); + SumTypeUtils.ValidateTypeParameter(typeof(T3)); + SumTypeUtils.ValidateTypeParameter(typeof(T4)); + } + + /// + /// Initializes a new instance of the struct containing a . + /// + /// The value to store in the . + public SumType(T1 val) + { + this.Value = val; + } + + /// + /// Initializes a new instance of the struct containing a . + /// + /// The value to store in the . + public SumType(T2 val) + { + this.Value = val; + } + + /// + /// Initializes a new instance of the struct containing a . + /// + /// The value to store in the . + public SumType(T3 val) + { + this.Value = val; + } + + /// + /// Initializes a new instance of the struct containing a . + /// + /// The value to store in the . + public SumType(T4 val) + { + this.Value = val; + } + + /// + public object? Value { get; } + + /// + /// Gets the value as the first specified type. + /// + public T1 First => (T1)this; + + /// + /// Gets the value as the second specified type. + /// + public T2 Second => (T2)this; + + /// + /// Gets the value as the third specified type. + /// + public T3 Third => (T3)this; + + /// + /// Gets the value as the fourth specified type. + /// + public T4 Fourth => (T4)this; + + /// + /// Implicitly wraps a value of type with a . + /// + /// Value to be wrap. + public static implicit operator SumType(T1 val) => new SumType(val); + + /// + /// Implicitly wraps a value of type with a . + /// + /// Value to be wrapped. + public static implicit operator SumType?(T1? val) => val is null ? null : new SumType(val); + + /// + /// Implicitly wraps a value of type with a . + /// + /// Value to be wrap. + public static implicit operator SumType(T2 val) => new SumType(val); + + /// + /// Implicitly wraps a value of type with a . + /// + /// Value to be wrapped. + public static implicit operator SumType?(T2? val) => val is null ? null : new SumType(val); + + /// + /// Implicitly wraps a value of type with a . + /// + /// Value to be wrap. + public static implicit operator SumType(T3 val) => new SumType(val); + + /// + /// Implicitly wraps a value of type with a . + /// + /// Value to be wrapped. + public static implicit operator SumType?(T3? val) => val is null ? null : new SumType(val); + + /// + /// Implicitly wraps a value of type with a . + /// + /// Value to be wrap. + public static implicit operator SumType(T4 val) => new SumType(val); + + /// + /// Implicitly wraps a value of type with a . + /// + /// Value to be wrapped. + public static implicit operator SumType?(T4? val) => val is null ? null : new SumType(val); + + /// + /// Implicitly wraps an instance of with a . + /// + /// Sum instance to wrap. + public static implicit operator SumType(SumType sum) + => sum.Match( + (v) => new SumType(v), + (v) => new SumType(v)); + + /// + /// Implicitly wraps an instance of with a . + /// + /// Sum instance to wrap. + public static implicit operator SumType(SumType sum) + => sum.Match( + (v) => new SumType(v), + (v) => new SumType(v), + (v) => new SumType(v)); + + /// + /// Attempts to cast an instance of into a . + /// + /// Sum instance to downcast. + public static explicit operator SumType(SumType sum) + { + if (sum.Value is T1 tOne) + { + return tOne; + } + + if (sum.Value is T2 tTwo) + { + return tTwo; + } + + throw new InvalidCastException(); + } + + /// + /// Attempts to cast an instance of into a . + /// + /// Sum instance to downcast. + public static explicit operator SumType(SumType sum) + { + if (sum.Value is T1 tOne) + { + return tOne; + } + + if (sum.Value is T2 tTwo) + { + return tTwo; + } + + if (sum.Value is T3 tThree) + { + return tThree; + } + + throw new InvalidCastException(); + } + + /// + /// Attempts to cast an instance of to an instance of . + /// + /// Thrown if this instance of does not contain an instance of . + /// Instance to unwrap. + public static explicit operator T1(SumType sum) => sum.Value is T1 tVal ? tVal : throw new InvalidCastException(); + + /// + /// Attempts to cast an instance of to an instance of . + /// + /// Thrown if this instance of does not contain an instance of . + /// Instance to unwrap. + public static explicit operator T2(SumType sum) => sum.Value is T2 tVal ? tVal : throw new InvalidCastException(); + + /// + /// Attempts to cast an instance of to an instance of . + /// + /// Thrown if this instance of does not contain an instance of . + /// Instance to unwrap. + public static explicit operator T3(SumType sum) => sum.Value is T3 tVal ? tVal : throw new InvalidCastException(); + + /// + /// Attempts to cast an instance of to an instance of . + /// + /// Thrown if this instance of does not contain an instance of . + /// Instance to unwrap. + public static explicit operator T4(SumType sum) => sum.Value is T4 tVal ? tVal : throw new InvalidCastException(); + + public static bool operator ==(SumType left, SumType right) + { + return left.Equals(right); + } + + public static bool operator !=(SumType left, SumType right) + { + return !(left == right); + } + + /// + /// Tries to get the value as the first specified type. + /// + /// the value in the specified type/>. + /// if the type matches. + public bool TryGetFirst([MaybeNullWhen(false)] out T1 value) + { + if (this.Value is T1 typeValue) + { + value = typeValue; + return true; + } + + value = default; + return false; + } + + /// + /// Tries to get the value as the second specified type. + /// + /// the value in the specified type/>. + /// if the type matches. + public bool TryGetSecond([MaybeNullWhen(false)] out T2 value) + { + if (this.Value is T2 typeValue) + { + value = typeValue; + return true; + } + + value = default; + return false; + } + + /// + /// Tries to get the value as the third specified type. + /// + /// the value in the specified type/>. + /// if the type matches. + public bool TryGetThird([MaybeNullWhen(false)] out T3 value) + { + if (this.Value is T3 typeValue) + { + value = typeValue; + return true; + } + + value = default; + return false; + } + + /// + /// Tries to get the value as the fourth specified type. + /// + /// the value in the specified type/>. + /// if the type matches. + public bool TryGetFourth([MaybeNullWhen(false)] out T4 value) + { + if (this.Value is T4 typeValue) + { + value = typeValue; + return true; + } + + value = default; + return false; + } + + /// + /// Runs a delegate corresponding to which type is contained inside this instance. + /// + /// The type that all the delegates will return. + /// Delegate to handle the case where this instance contains a . + /// Delegate to handle the case where this instance contains a . + /// Delegate to handle the case where this instance contains a . + /// Delegate to handle the case where this instance contains a . + /// + /// Delegate to handle the case where this instance is uninhabited. If this delegate isn't provided the default + /// will be returned instead. + /// + /// The instance created by the delegate corresponding to the current type stored in this instance. + public TResult Match(Func firstMatch, Func secondMatch, Func thirdMatch, Func fourthMatch, Func? defaultMatch = null) + { + if (firstMatch == null) + { + throw new ArgumentNullException(nameof(firstMatch)); + } + + if (secondMatch == null) + { + throw new ArgumentNullException(nameof(secondMatch)); + } + + if (thirdMatch == null) + { + throw new ArgumentNullException(nameof(thirdMatch)); + } + + if (fourthMatch == null) + { + throw new ArgumentNullException(nameof(fourthMatch)); + } + + if (this.Value is T1 tOne) + { + return firstMatch(tOne); + } + + if (this.Value is T2 tTwo) + { + return secondMatch(tTwo); + } + + if (this.Value is T3 tThree) + { + return thirdMatch(tThree); + } + + if (this.Value is T4 tFour) + { + return fourthMatch(tFour); + } + + if (defaultMatch != null) + { + return defaultMatch(); + } + +#pragma warning disable CS8603 // Possible null reference return. + return default(TResult); +#pragma warning restore CS8603 // Possible null reference return. + } + + /// + public override bool Equals(object obj) + { + return obj is SumType type && this.Equals(type); + } + + /// + public bool Equals(SumType other) + { + return EqualityComparer.Default.Equals(this.Value, other.Value); + } + + /// + public override int GetHashCode() + { + return -1937169414 + EqualityComparer.Default.GetHashCode(this.Value); + } + } + + /// + /// Utility methods for implementations. + /// + internal static class SumTypeUtils + { + /// + /// Validates that is a valid type parameter for a SumType. + /// + /// The type to validate. + /// If is not supported as a type parameter for a + /// SumType. + public static void ValidateTypeParameter(Type type) + { + if (typeof(ISumType).IsAssignableFrom(type)) + { + throw new NotSupportedException(LanguageServerProtocolResources.NestedSumType); + } + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/SymbolInformation.cs b/src/Features/LanguageServer/Protocol/Protocol/SymbolInformation.cs new file mode 100644 index 0000000000000..dc3b38d0cdacb --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/SymbolInformation.cs @@ -0,0 +1,88 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System; + using System.Collections.Generic; + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing information about programming constructs like variables, classes, interfaces, etc. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class SymbolInformation : IEquatable + { + /// + /// Gets or sets the name of this symbol. + /// + [DataMember(Name = "name")] + public string Name + { + get; + set; + } + + /// + /// Gets or sets the of this symbol. + /// + [DataMember(Name = "kind")] + public SymbolKind Kind + { + get; + set; + } + + /// + /// Gets or sets the of this symbol. + /// + [DataMember(Name = "location")] + public Location Location + { + get; + set; + } + + /// + /// Gets or sets the name of the symbol containing this symbol. + /// + [DataMember(Name = "containerName")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? ContainerName + { + get; + set; + } + + /// + public override bool Equals(object obj) + { + return this.Equals(obj as SymbolInformation); + } + + /// + public bool Equals(SymbolInformation? other) + { + return other != null && + this.Name == other.Name && + this.Kind == other.Kind && + EqualityComparer.Default.Equals(this.Location, other.Location) && + this.ContainerName == other.ContainerName; + } + + /// + public override int GetHashCode() + { + var hashCode = 1633890234; + hashCode = (hashCode * -1521134295) + EqualityComparer.Default.GetHashCode(this.Name); + hashCode = (hashCode * -1521134295) + (int)this.Kind; + hashCode = (hashCode * -1521134295) + EqualityComparer.Default.GetHashCode(this.Location); + hashCode = (hashCode * -1521134295) + EqualityComparer.Default.GetHashCode(this.ContainerName); + return hashCode; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/SymbolKind.cs b/src/Features/LanguageServer/Protocol/Protocol/SymbolKind.cs new file mode 100644 index 0000000000000..e2d98be0daac4 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/SymbolKind.cs @@ -0,0 +1,149 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Enum which represents the various kinds of symbols. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1720:Identifier contains type name", Justification = "Names are defined by the LSP")] + internal enum SymbolKind + { + /// + /// Symbol is a file. + /// + File = 1, + + /// + /// Symbol is a module. + /// + Module = 2, + + /// + /// Symbol is a namespace. + /// + Namespace = 3, + + /// + /// Symbol is a package. + /// + Package = 4, + + /// + /// Symbol is a class. + /// + Class = 5, + + /// + /// Symbol is a method. + /// + Method = 6, + + /// + /// Symbol is a property. + /// + Property = 7, + + /// + /// Symbol is a field. + /// + Field = 8, + + /// + /// Symbol is a constructor. + /// + Constructor = 9, + + /// + /// Symbol is an enum. + /// + Enum = 10, + + /// + /// Symbol is an interface. + /// + Interface = 11, + + /// + /// Symbol is a function. + /// + Function = 12, + + /// + /// Symbol is a variable. + /// + Variable = 13, + + /// + /// Symbol is a constant. + /// + Constant = 14, + + /// + /// Symbol is a string. + /// + String = 15, + + /// + /// Symbol is a number. + /// + Number = 16, + + /// + /// Symbol is a boolean. + /// + Boolean = 17, + + /// + /// Symbol is an array. + /// + Array = 18, + + /// + /// Symbol is an object. + /// + Object = 19, + + /// + /// Symbol is a key. + /// + Key = 20, + + /// + /// Symbol is null. + /// + Null = 21, + + /// + /// Symbol is an enum member. + /// + EnumMember = 22, + + /// + /// Symbol is a struct. + /// + Struct = 23, + + /// + /// Symbol is an event. + /// + Event = 24, + + /// + /// Symbol is an operator. + /// + Operator = 25, + + /// + /// Symbol is a type parameter. + /// + TypeParameter = 26, + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/SymbolKindSetting.cs b/src/Features/LanguageServer/Protocol/Protocol/SymbolKindSetting.cs new file mode 100644 index 0000000000000..ce32110d895d1 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/SymbolKindSetting.cs @@ -0,0 +1,29 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing the symbol kind setting in initialization. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class SymbolKindSetting + { + /// + /// Gets or sets the types of symbol kind the client supports. + /// + [DataMember(Name = "valueSet")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public SymbolKind[]? ValueSet + { + get; + set; + } + } +} \ No newline at end of file diff --git a/src/Features/LanguageServer/Protocol/Protocol/SymbolSetting.cs b/src/Features/LanguageServer/Protocol/Protocol/SymbolSetting.cs new file mode 100644 index 0000000000000..a1b609d5a041e --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/SymbolSetting.cs @@ -0,0 +1,29 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing the symbol setting for initialization. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class SymbolSetting : DynamicRegistrationSetting + { + /// + /// Gets or sets the information. + /// + [DataMember(Name = "symbolKind")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public SymbolKindSetting? SymbolKind + { + get; + set; + } + } +} \ No newline at end of file diff --git a/src/Features/LanguageServer/Protocol/Protocol/SynchronizationSetting.cs b/src/Features/LanguageServer/Protocol/Protocol/SynchronizationSetting.cs new file mode 100644 index 0000000000000..87da1fdc6ac1e --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/SynchronizationSetting.cs @@ -0,0 +1,51 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class which represents synchronization initialization setting. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class SynchronizationSetting : DynamicRegistrationSetting + { + /// + /// Gets or sets a value indicating whether WillSave event is supported. + /// + [DataMember(Name = "willSave")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool WillSave + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether WillSaveWaitUntil event is supported. + /// + [DataMember(Name = "willSaveWaitUntil")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool WillSaveWaitUntil + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether DidSave event is supported. + /// + [DataMember(Name = "didSave")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool DidSave + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/TagSupport.cs b/src/Features/LanguageServer/Protocol/Protocol/TagSupport.cs new file mode 100644 index 0000000000000..e5dfaffa0e439 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/TagSupport.cs @@ -0,0 +1,27 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// Class representing the capabilities. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class TagSupport + { + /// + /// Gets or sets a value indicating the tags supported by the client. + /// + [DataMember(Name = "valueSet")] + public DiagnosticTag[] ValueSet + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/TextDocumentClientCapabilities.cs b/src/Features/LanguageServer/Protocol/Protocol/TextDocumentClientCapabilities.cs new file mode 100644 index 0000000000000..5ea26816eaf94 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/TextDocumentClientCapabilities.cs @@ -0,0 +1,270 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class which represents text document capabilities. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class TextDocumentClientCapabilities + { + /// + /// Gets or sets the synchronization setting. + /// + [DataMember(Name = "synchronization")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public SynchronizationSetting? Synchronization + { + get; + set; + } + + /// + /// Gets or sets the completion setting. + /// + [DataMember(Name = "completion")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public CompletionSetting? Completion + { + get; + set; + } + + /// + /// Gets or sets the setting which determines if hover can be dynamically registered. + /// + [DataMember(Name = "hover")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public HoverSetting? Hover + { + get; + set; + } + + /// + /// Gets or sets the setting which determines if signature help can be dynamically registered. + /// + [DataMember(Name = "signatureHelp")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public SignatureHelpSetting? SignatureHelp + { + get; + set; + } + + /// + /// Gets or sets the setting which determines if definition can be dynamically registered. + /// + [DataMember(Name = "definition")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public DynamicRegistrationSetting? Definition + { + get; + set; + } + + /// + /// Gets or sets the settings which determines if type definition can be dynamically registered. + /// + [DataMember(Name = "typeDefinition")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public DynamicRegistrationSetting? TypeDefinition + { + get; + set; + } + + /// + /// Gets or sets the settings which determines if implementation can be dynamically registered. + /// + [DataMember(Name = "implementation")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public DynamicRegistrationSetting? Implementation + { + get; + set; + } + + /// + /// Gets or sets the setting which determines if references can be dynamically registered. + /// + [DataMember(Name = "references")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public DynamicRegistrationSetting? References + { + get; + set; + } + + /// + /// Gets or sets the setting which determines if document highlight can be dynamically registered. + /// + [DataMember(Name = "documentHighlight")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public DynamicRegistrationSetting? DocumentHighlight + { + get; + set; + } + + /// + /// Gets or sets the setting which determines if document symbol can be dynamically registered. + /// + [DataMember(Name = "documentSymbol")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public DocumentSymbolSetting? DocumentSymbol + { + get; + set; + } + + /// + /// Gets or sets the setting which determines if code action can be dynamically registered. + /// + [DataMember(Name = "codeAction")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public CodeActionSetting? CodeAction + { + get; + set; + } + + /// + /// Gets or sets the setting which determines if code lens can be dynamically registered. + /// + [DataMember(Name = "codeLens")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public DynamicRegistrationSetting? CodeLens + { + get; + set; + } + + /// + /// Gets or sets the setting which determines if document link can be dynamically registered. + /// + [DataMember(Name = "documentLink")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public DynamicRegistrationSetting? DocumentLink + { + get; + set; + } + + /// + /// Gets or sets the setting which determines if formatting can be dynamically registered. + /// + [DataMember(Name = "formatting")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public DynamicRegistrationSetting? Formatting + { + get; + set; + } + + /// + /// Gets or sets the setting which determines if range formatting can be dynamically registered. + /// + [DataMember(Name = "rangeFormatting")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public DynamicRegistrationSetting? RangeFormatting + { + get; + set; + } + + /// + /// Gets or sets the setting which determines if on type formatting can be dynamically registered. + /// + [DataMember(Name = "onTypeFormatting")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public DynamicRegistrationSetting? OnTypeFormatting + { + get; + set; + } + + /// + /// Gets or sets the setting which determines if rename can be dynamically registered. + /// + [DataMember(Name = "rename")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public RenameClientCapabilities? Rename + { + get; + set; + } + + /// + /// Gets or sets the setting publish diagnostics setting. + /// + [DataMember(Name = "publishDiagnostics")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public PublishDiagnosticsSetting? PublishDiagnostics + { + get; + set; + } + + /// + /// Gets or sets the setting which determines how folding range is supported. + /// + [DataMember(Name = "foldingRange")] + public FoldingRangeSetting? FoldingRange + { + get; + set; + } + + /// + /// Gets or sets the setting which determines if linked editing range can be dynamically registered. + /// + [DataMember(Name = "linkedEditingRange")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public DynamicRegistrationSetting LinkedEditingRange + { + get; + set; + } + + /// + /// Gets or sets a setting indicating whether semantic tokens is supported. + /// + [DataMember(Name = "semanticTokens")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public SemanticTokensSetting? SemanticTokens + { + get; + set; + } + + /// + /// Gets or sets the setting which determines what support the client has for pull diagnostics. + /// + [DataMember(Name = "diagnostic")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public DiagnosticSetting? Diagnostic + { + get; + set; + } + + /// + /// Gets or sets the setting which determines what support the client has for pull diagnostics. + /// + [DataMember(Name = "inlayHint")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public InlayHintSetting? InlayHint + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/TextDocumentContentChangeEvent.cs b/src/Features/LanguageServer/Protocol/Protocol/TextDocumentContentChangeEvent.cs new file mode 100644 index 0000000000000..8c2dd3dbb9566 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/TextDocumentContentChangeEvent.cs @@ -0,0 +1,49 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class which encapsulates a text document changed event. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class TextDocumentContentChangeEvent + { + /// + /// Gets or sets the range of the text that was changed. + /// + [DataMember(Name = "range")] + public Range Range + { + get; + set; + } + + /// + /// Gets or sets the length of the range that got replaced. + /// + [DataMember(Name = "rangeLength")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public int? RangeLength + { + get; + set; + } + + /// + /// Gets or sets the new text of the range/document. + /// + [DataMember(Name = "text")] + public string Text + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/TextDocumentEdit.cs b/src/Features/LanguageServer/Protocol/Protocol/TextDocumentEdit.cs new file mode 100644 index 0000000000000..bfe8999beff4c --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/TextDocumentEdit.cs @@ -0,0 +1,37 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// Class representing a set of changes to a single text document. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class TextDocumentEdit + { + /// + /// Gets or sets a document identifier indication which document to apply the edits to. + /// + [DataMember(Name = "textDocument", IsRequired = true)] + public OptionalVersionedTextDocumentIdentifier TextDocument + { + get; + set; + } + + /// + /// Gets or sets the array of edits to be applied to the document. + /// + [DataMember(Name = "edits", IsRequired = true)] + public TextEdit[] Edits + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/TextDocumentIdentifier.cs b/src/Features/LanguageServer/Protocol/Protocol/TextDocumentIdentifier.cs new file mode 100644 index 0000000000000..78ffa87d73c42 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/TextDocumentIdentifier.cs @@ -0,0 +1,83 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System; + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class which identifies a text document. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class TextDocumentIdentifier : IEquatable + { + /// + /// Gets or sets the URI of the text document. + /// + [DataMember(Name = "uri")] + [JsonConverter(typeof(DocumentUriConverter))] + public Uri Uri + { + get; + set; + } + + public static bool operator ==(TextDocumentIdentifier? value1, TextDocumentIdentifier? value2) + { + if (ReferenceEquals(value1, value2)) + { + return true; + } + + // Is null? + if (ReferenceEquals(null, value2)) + { + return false; + } + + return value1?.Equals(value2) ?? false; + } + + public static bool operator !=(TextDocumentIdentifier? value1, TextDocumentIdentifier? value2) + { + return !(value1 == value2); + } + + /// + public bool Equals(TextDocumentIdentifier other) + { + return other is not null + && this.Uri == other.Uri; + } + + /// + public override bool Equals(object obj) + { + if (obj is TextDocumentIdentifier other) + { + return this.Equals(other); + } + else + { + return false; + } + } + + /// + public override int GetHashCode() + { + return this.Uri == null ? 89 : this.Uri.GetHashCode(); + } + + /// + public override string ToString() + { + return this.Uri == null ? string.Empty : this.Uri.AbsolutePath; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/TextDocumentItem.cs b/src/Features/LanguageServer/Protocol/Protocol/TextDocumentItem.cs new file mode 100644 index 0000000000000..4885efdb848b9 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/TextDocumentItem.cs @@ -0,0 +1,60 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System; + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class which represents a text document. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class TextDocumentItem + { + /// + /// Gets or sets the document URI. + /// + [DataMember(Name = "uri")] + [JsonConverter(typeof(DocumentUriConverter))] + public Uri Uri + { + get; + set; + } + + /// + /// Gets or sets the document language identifier. + /// + [DataMember(Name = "languageId")] + public string LanguageId + { + get; + set; + } + + /// + /// Gets or sets the document version. + /// + [DataMember(Name = "version")] + public int Version + { + get; + set; + } + + /// + /// Gets or sets the content of the opened text document. + /// + [DataMember(Name = "text")] + public string Text + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/TextDocumentPositionParams.cs b/src/Features/LanguageServer/Protocol/Protocol/TextDocumentPositionParams.cs new file mode 100644 index 0000000000000..7886b68fb690a --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/TextDocumentPositionParams.cs @@ -0,0 +1,37 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// Class which represents a position within a text document. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class TextDocumentPositionParams : ITextDocumentPositionParams + { + /// + /// Gets or sets the value which identifies the document. + /// + [DataMember(Name = "textDocument")] + public TextDocumentIdentifier TextDocument + { + get; + set; + } + + /// + /// Gets or sets the value which indicates the position within the document. + /// + [DataMember(Name = "position")] + public Position Position + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/TextDocumentRegistrationOptions.cs b/src/Features/LanguageServer/Protocol/Protocol/TextDocumentRegistrationOptions.cs new file mode 100644 index 0000000000000..6fee4bee03e0f --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/TextDocumentRegistrationOptions.cs @@ -0,0 +1,29 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing the registration options for many different text document functions. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class TextDocumentRegistrationOptions : ITextDocumentRegistrationOptions + { + /// + /// Gets or sets the document filters for this registration option. + /// + [DataMember(Name = "documentSelector")] + [JsonProperty(NullValueHandling = NullValueHandling.Include)] + public DocumentFilter[]? DocumentSelector + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/TextDocumentSaveReason.cs b/src/Features/LanguageServer/Protocol/Protocol/TextDocumentSaveReason.cs new file mode 100644 index 0000000000000..c0ad11d2cf815 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/TextDocumentSaveReason.cs @@ -0,0 +1,33 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Enum representing the reason a document was saved. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal enum TextDocumentSaveReason + { + /// + /// Save was manually triggered. + /// + Manual = 1, + + /// + /// Save was automatic after some delay. + /// + AfterDelay = 2, + + /// + /// Save was automatic after the editor lost focus. + /// + FocusOut = 3, + } +} \ No newline at end of file diff --git a/src/Features/LanguageServer/Protocol/Protocol/TextDocumentSyncKind.cs b/src/Features/LanguageServer/Protocol/Protocol/TextDocumentSyncKind.cs new file mode 100644 index 0000000000000..105d0dbe2d5fe --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/TextDocumentSyncKind.cs @@ -0,0 +1,32 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// Enum which represents the various ways to sync text documents. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal enum TextDocumentSyncKind + { + /// + /// Documents should not be synced at all. + /// + None = 0, + + /// + /// Documents are synced by always sending the full text. + /// + Full = 1, + + /// + /// Documents are synced by sending only incremental updates. + /// + Incremental = 2, + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/TextDocumentSyncOptions.cs b/src/Features/LanguageServer/Protocol/Protocol/TextDocumentSyncOptions.cs new file mode 100644 index 0000000000000..2c398b13b22e2 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/TextDocumentSyncOptions.cs @@ -0,0 +1,75 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.ComponentModel; + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class which represents configuration values indicating how text documents should be synced. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class TextDocumentSyncOptions + { + /// + /// Gets or sets a value indicating whether open and close notifications are sent to the server. + /// + [DataMember(Name = "openClose")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool OpenClose + { + get; + set; + } + + /// + /// Gets or sets the value indicating how text documents are synced with the server. + /// + [DataMember(Name = "change")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + [DefaultValue(TextDocumentSyncKind.None)] + public TextDocumentSyncKind? Change + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether 'will save' notifications are sent to the server. + /// + [DataMember(Name = "willSave")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool WillSave + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether 'will save until' notifications are sent to the server. + /// + [DataMember(Name = "willSaveWaitUntil")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool WillSaveWaitUntil + { + get; + set; + } + + /// + /// Gets or sets a value indicating whether save notifications are sent to the server. + /// + [DataMember(Name = "save")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public SumType? Save + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/TextEdit.cs b/src/Features/LanguageServer/Protocol/Protocol/TextEdit.cs new file mode 100644 index 0000000000000..dccc1ce6887c5 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/TextEdit.cs @@ -0,0 +1,37 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// Class which represents a text edit to a document. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class TextEdit + { + /// + /// Gets or sets the value which indicates the range of the text edit. + /// + [DataMember(Name = "range", IsRequired = true)] + public Range Range + { + get; + set; + } + + /// + /// Gets or sets the value of the new text. + /// + [DataMember(Name = "newText")] + public string NewText + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/TraceSetting.cs b/src/Features/LanguageServer/Protocol/Protocol/TraceSetting.cs new file mode 100644 index 0000000000000..92261d6fc1790 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/TraceSetting.cs @@ -0,0 +1,34 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.ComponentModel; + using Newtonsoft.Json; + + /// + /// Value representing the language server trace setting. + /// + /// See the Language Server Protocol specification for additional information. + /// + [JsonConverter(typeof(StringEnumConverter))] + [TypeConverter(typeof(StringEnumConverter.TypeConverter))] + internal readonly record struct TraceSetting(string Value) : IStringEnum + { + /// + /// Setting for 'off'. + /// + public static readonly TraceSetting Off = new("off"); + + /// + /// Setting for 'messages'. + /// + public static readonly TraceSetting Messages = new("messages"); + + /// + /// Setting for 'verbose'. + /// + public static readonly TraceSetting Verbose = new("verbose"); + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/TypeDefinitionOptions.cs b/src/Features/LanguageServer/Protocol/Protocol/TypeDefinitionOptions.cs new file mode 100644 index 0000000000000..480ddcd93f2ca --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/TypeDefinitionOptions.cs @@ -0,0 +1,29 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class which represents workspace symbols capabilities. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class TypeDefinitionOptions : IWorkDoneProgressOptions + { + /// + /// Gets or sets a value indicating whether work done progress is supported. + /// + [DataMember(Name = "workDoneProgress")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool WorkDoneProgress + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/UnchangedDocumentDiagnosticReport.cs b/src/Features/LanguageServer/Protocol/Protocol/UnchangedDocumentDiagnosticReport.cs new file mode 100644 index 0000000000000..eaff6e3e52e55 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/UnchangedDocumentDiagnosticReport.cs @@ -0,0 +1,35 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol; + +using System.Runtime.Serialization; + +/// +/// Class representing a diagnostic report indicating that the last returned report is still accurate. +/// +/// See the Language Server Protocol specification for additional information. +/// +[DataContract] +[Kind(DocumentDiagnosticReportKind.Unchanged)] +internal class UnchangedDocumentDiagnosticReport +{ + /// + /// Gets the kind of this report. + /// + [DataMember(Name = "kind")] +#pragma warning disable CA1822 // Mark members as static + public string Kind => DocumentDiagnosticReportKind.Unchanged; +#pragma warning restore CA1822 // Mark members as static + + /// + /// Gets or sets the optional result id. + /// + [DataMember(Name = "resultId")] + public string ResultId + { + get; + set; + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/Unregistration.cs b/src/Features/LanguageServer/Protocol/Protocol/Unregistration.cs new file mode 100644 index 0000000000000..03493010e0a44 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/Unregistration.cs @@ -0,0 +1,37 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// Class representing the information needed for unregistering a capability. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class Unregistration + { + /// + /// Gets or sets the id of the unregistration. + /// + [DataMember(Name = "id")] + public string Id + { + get; + set; + } + + /// + /// Gets or sets the method to unregister. + /// + [DataMember(Name = "method")] + public string Method + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/UnregistrationParams.cs b/src/Features/LanguageServer/Protocol/Protocol/UnregistrationParams.cs new file mode 100644 index 0000000000000..54d954451b88e --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/UnregistrationParams.cs @@ -0,0 +1,27 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// Class representing the parameter sent for the client/unregisterCapability request. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class UnregistrationParams + { + /// + /// Gets or sets the capabilities to unregister. + /// + [DataMember(Name = "unregistrations")] + public Unregistration[] Unregistrations + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/VersionedTextDocumentIdentifier.cs b/src/Features/LanguageServer/Protocol/Protocol/VersionedTextDocumentIdentifier.cs new file mode 100644 index 0000000000000..ecffd30fcdbba --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/VersionedTextDocumentIdentifier.cs @@ -0,0 +1,86 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System; + using System.Globalization; + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class which represents a text document, but has a version identifier. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class VersionedTextDocumentIdentifier : TextDocumentIdentifier, IEquatable + { + /// + /// Gets or sets the version of the document. + /// + [DataMember(Name = "version")] + public int Version + { + get; + set; + } + + public static bool operator ==(VersionedTextDocumentIdentifier? value1, VersionedTextDocumentIdentifier? value2) + { + if (ReferenceEquals(value1, value2)) + { + return true; + } + + // Is null? + if (ReferenceEquals(null, value2)) + { + return false; + } + + return value1?.Equals(value2) ?? false; + } + + public static bool operator !=(VersionedTextDocumentIdentifier? value1, VersionedTextDocumentIdentifier? value2) + { + return !(value1 == value2); + } + + /// + public bool Equals(VersionedTextDocumentIdentifier other) + { + return other is not null + && this.Version == other.Version + && base.Equals(other); + } + + /// + public override bool Equals(object obj) + { + if (obj is VersionedTextDocumentIdentifier other) + { + return this.Equals(other); + } + else + { + return false; + } + } + + /// + public override int GetHashCode() + { + return this.Version.GetHashCode() + ^ (base.GetHashCode() * 79); + } + + /// + public override string ToString() + { + // Invariant culture because the culture on the server vs client may vary. + return base.ToString() + "|" + this.Version.ToString(CultureInfo.InvariantCulture); + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/WillSaveTextDocumentParams.cs b/src/Features/LanguageServer/Protocol/Protocol/WillSaveTextDocumentParams.cs new file mode 100644 index 0000000000000..fb88efda26c86 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/WillSaveTextDocumentParams.cs @@ -0,0 +1,37 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + + /// + /// Class representing the parameters sent for the textDocument/willSave request. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class WillSaveTextDocumentParams : ITextDocumentParams + { + /// + /// Gets or sets the representing the document to be saved. + /// + [DataMember(Name = "textDocument")] + public TextDocumentIdentifier TextDocument + { + get; + set; + } + + /// + /// Gets or sets the reason that the text document was saved. + /// + [DataMember(Name = "reason")] + public TextDocumentSaveReason Reason + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/WorkspaceClientCapabilities.cs b/src/Features/LanguageServer/Protocol/Protocol/WorkspaceClientCapabilities.cs new file mode 100644 index 0000000000000..74cb04f4e3912 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/WorkspaceClientCapabilities.cs @@ -0,0 +1,139 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class which represents workspace capabilities. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class WorkspaceClientCapabilities + { + /// + /// Gets or sets a value indicating whether apply edit is supported. + /// + [DataMember(Name = "applyEdit")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool ApplyEdit + { + get; + set; + } + + /// + /// Gets or sets the workspace edit setting. + /// + [DataMember(Name = "workspaceEdit")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public WorkspaceEditSetting? WorkspaceEdit + { + get; + set; + } + + /// + /// Gets or sets the setting which determines if did change configuration can be dynamically registered. + /// + [DataMember(Name = "didChangeConfiguration")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public DynamicRegistrationSetting? DidChangeConfiguration + { + get; + set; + } + + /// + /// Gets or sets the setting which determines if did change watched files can be dynamically registered. + /// + [DataMember(Name = "didChangeWatchedFiles")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public DynamicRegistrationSetting? DidChangeWatchedFiles + { + get; + set; + } + + /// + /// Gets or sets the setting which determines if symbols can be dynamically registered. + /// + [DataMember(Name = "symbol")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public SymbolSetting? Symbol + { + get; + set; + } + + /// + /// Gets or sets the setting which determines if execute command can be dynamically registered. + /// + [DataMember(Name = "executeCommand")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public DynamicRegistrationSetting? ExecuteCommand + { + get; + set; + } + + /// + /// Gets or sets capabilities specific to the semantic token requests scoped to the workspace. + /// + [DataMember(Name = "semanticTokens")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public SemanticTokensWorkspaceSetting? SemanticTokens + { + get; + set; + } + + /// + /// Gets or sets capabilities indicating what support the client has for workspace pull diagnostics. + /// + [DataMember(Name = "diagnostics")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public DiagnosticWorkspaceSetting? Diagnostics + { + get; + set; + } + + /// + /// Gets or sets the capabilities if client support 'workspace/configuration' requests. + /// + [DataMember(Name = "configuration")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool Configuration + { + get; + set; + } + + /// + /// Gets of sets capabilities specific to the inlay hint requests scoped to the workspace. + /// + [DataMember(Name = "inlayHint")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public InlayHintWorkspaceSetting? InlayHint + { + get; + set; + } + + /// + /// Gets of sets capabilities specific to the code lens requests scoped to the workspace. + /// + [DataMember(Name = "codeLens")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public CodeLensWorkspaceSetting? CodeLens + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/WorkspaceDiagnosticParams.cs b/src/Features/LanguageServer/Protocol/Protocol/WorkspaceDiagnosticParams.cs new file mode 100644 index 0000000000000..f8c2cdb7dcfef --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/WorkspaceDiagnosticParams.cs @@ -0,0 +1,54 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol; + +using System; +using System.Runtime.Serialization; +using Newtonsoft.Json; + +/// +/// Class representing the workspace diagnostic request parameters +/// +/// See the Language Server Protocol specification for additional information. +/// +/// +/// Note that the first literal send needs to be a +/// followed by n literals. +/// +[DataContract] +internal class WorkspaceDiagnosticParams : IPartialResultParams> +{ + /// + /// Gets or sets the value of the Progress instance. + /// + [DataMember(Name = Methods.PartialResultTokenName, IsRequired = false)] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public IProgress>? PartialResultToken + { + get; + set; + } + + /// + /// Gets or sets the identifier for which the client is requesting diagnostics for. + /// + [DataMember(Name = "identifier")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string? Identifier + { + get; + set; + } + + /// + /// Gets or sets the result id of a previous diagnostics response if provided. + /// + [DataMember(Name = "previousResultIds")] + public PreviousResultId[] PreviousResultId + { + get; + set; + } +} \ No newline at end of file diff --git a/src/Features/LanguageServer/Protocol/Protocol/WorkspaceDiagnosticReport.cs b/src/Features/LanguageServer/Protocol/Protocol/WorkspaceDiagnosticReport.cs new file mode 100644 index 0000000000000..fff52c02f2e2e --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/WorkspaceDiagnosticReport.cs @@ -0,0 +1,28 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol; + +using System; +using System.Runtime.Serialization; +using Newtonsoft.Json; + +/// +/// Class representing a workspace diagnostic report. +/// +/// See the Language Server Protocol specification for additional information. +/// +[DataContract] +internal class WorkspaceDiagnosticReport +{ + /// + /// Gets or sets the items in this diagnostic report. + /// + [DataMember(Name = "items")] + public SumType[] Items + { + get; + set; + } +} \ No newline at end of file diff --git a/src/Features/LanguageServer/Protocol/Protocol/WorkspaceDiagnosticReportPartialResult.cs b/src/Features/LanguageServer/Protocol/Protocol/WorkspaceDiagnosticReportPartialResult.cs new file mode 100644 index 0000000000000..f2e3387cc2c88 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/WorkspaceDiagnosticReportPartialResult.cs @@ -0,0 +1,28 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol; + +using System; +using System.Runtime.Serialization; +using Newtonsoft.Json; + +/// +/// Class representing a partial result for a workspace diagnostic report. +/// +/// See the Language Server Protocol specification for additional information. +/// +[DataContract] +internal class WorkspaceDiagnosticReportPartialResult +{ + /// + /// Gets or sets the items in this diagnostic report. + /// + [DataMember(Name = "items")] + public SumType[] Items + { + get; + set; + } +} \ No newline at end of file diff --git a/src/Features/LanguageServer/Protocol/Protocol/WorkspaceEdit.cs b/src/Features/LanguageServer/Protocol/Protocol/WorkspaceEdit.cs new file mode 100644 index 0000000000000..23fba470b1e07 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/WorkspaceEdit.cs @@ -0,0 +1,41 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Collections.Generic; + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class representing a request sent from a language server to modify resources in the workspace. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class WorkspaceEdit + { + /// + /// Gets or sets a dictionary holding changes to existing resources. + /// + [DataMember(Name = "changes")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public Dictionary? Changes + { + get; + set; + } + + /// + /// Gets or sets an array representing versioned document changes. + /// + [DataMember(Name = "documentChanges")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public SumType[]>? DocumentChanges + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/WorkspaceEditSetting.cs b/src/Features/LanguageServer/Protocol/Protocol/WorkspaceEditSetting.cs new file mode 100644 index 0000000000000..26265677883bd --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/WorkspaceEditSetting.cs @@ -0,0 +1,40 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class which represents initialization settings for workspace edit. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class WorkspaceEditSetting + { + /// + /// Gets or sets a value indicating whether document changes event is supported. + /// + [DataMember(Name = "documentChanges")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool DocumentChanges + { + get; + set; + } + + /// + /// GEts or sets the resource operations the client supports. + /// + [DataMember(Name = "resourceOperations")] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public ResourceOperationKind[]? ResourceOperations + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/WorkspaceFullDocumentDiagnosticReport.cs b/src/Features/LanguageServer/Protocol/Protocol/WorkspaceFullDocumentDiagnosticReport.cs new file mode 100644 index 0000000000000..7a2f9d84ee9d2 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/WorkspaceFullDocumentDiagnosticReport.cs @@ -0,0 +1,41 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol; + +using System; +using System.Runtime.Serialization; +using Newtonsoft.Json; + +/// +/// Class representing a full document diagnostic report for workspace diagnostic result. +/// +/// See the Language Server Protocol specification for additional information. +/// +[DataContract] +[Kind(DocumentDiagnosticReportKind.Full)] +internal class WorkspaceFullDocumentDiagnosticReport : FullDocumentDiagnosticReport +{ + /// + /// Gets or sets the URI associated with this diagnostic report. + /// + [DataMember(Name = "uri")] + [JsonConverter(typeof(DocumentUriConverter))] + public Uri Uri + { + get; + set; + } + + /// + /// Gets or sets the version number for which the diagnostics are reported. + /// If the document is not marked as open 'null' can be provided. + /// + [DataMember(Name = "version")] + public int? Version + { + get; + set; + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/WorkspaceSymbolOptions.cs b/src/Features/LanguageServer/Protocol/Protocol/WorkspaceSymbolOptions.cs new file mode 100644 index 0000000000000..b3fc09e174d7d --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/WorkspaceSymbolOptions.cs @@ -0,0 +1,29 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class which represents workspace symbols capabilities. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class WorkspaceSymbolOptions : IWorkDoneProgressOptions + { + /// + /// Gets or sets a value indicating whether work done progress is supported. + /// + [DataMember(Name = "workDoneProgress")] + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool WorkDoneProgress + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/WorkspaceSymbolParams.cs b/src/Features/LanguageServer/Protocol/Protocol/WorkspaceSymbolParams.cs new file mode 100644 index 0000000000000..2ef10ea9fa3ef --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/WorkspaceSymbolParams.cs @@ -0,0 +1,40 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol +{ + using System; + using System.Runtime.Serialization; + using Newtonsoft.Json; + + /// + /// Class which represents the parameter that's sent with the 'workspace/symbol' request. + /// + /// See the Language Server Protocol specification for additional information. + /// + [DataContract] + internal class WorkspaceSymbolParams : IPartialResultParams + { + /// + /// Gets or sets the query (a non-empty string). + /// + [DataMember(Name = "query")] + public string Query + { + get; + set; + } + + /// + /// Gets or sets the value of the Progress instance. + /// + [DataMember(Name = Methods.PartialResultTokenName)] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public IProgress? PartialResultToken + { + get; + set; + } + } +} diff --git a/src/Features/LanguageServer/Protocol/Protocol/WorkspaceUnchangedDocumentDiagnosticReport.cs b/src/Features/LanguageServer/Protocol/Protocol/WorkspaceUnchangedDocumentDiagnosticReport.cs new file mode 100644 index 0000000000000..d7aa7192da725 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/Protocol/WorkspaceUnchangedDocumentDiagnosticReport.cs @@ -0,0 +1,41 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.LanguageServer.Protocol; + +using System; +using System.Runtime.Serialization; +using Newtonsoft.Json; + +/// +/// Class representing a unchanged document diagnostic report for workspace diagnostic result. +/// +/// See the Language Server Protocol specification for additional information. +/// +[DataContract] +[Kind(DocumentDiagnosticReportKind.Unchanged)] +internal class WorkspaceUnchangedDocumentDiagnosticReport : UnchangedDocumentDiagnosticReport +{ + /// + /// Gets or sets the URI associated with this diagnostic report. + /// + [DataMember(Name = "uri")] + [JsonConverter(typeof(DocumentUriConverter))] + public Uri Uri + { + get; + set; + } + + /// + /// Gets or sets the version number for which the diagnostics are reported. + /// If the document is not marked as open 'null' can be provided. + /// + [DataMember(Name = "version")] + public int? Version + { + get; + set; + } +} diff --git a/src/Features/LanguageServer/Protocol/RoslynLanguageServer.cs b/src/Features/LanguageServer/Protocol/RoslynLanguageServer.cs index dcc541071dc89..4d3ae283ceb6f 100644 --- a/src/Features/LanguageServer/Protocol/RoslynLanguageServer.cs +++ b/src/Features/LanguageServer/Protocol/RoslynLanguageServer.cs @@ -11,7 +11,7 @@ using Microsoft.CodeAnalysis.LanguageServer.Handler; using Microsoft.CodeAnalysis.LanguageServer.Handler.ServerLifetime; using Microsoft.CommonLanguageServerProtocol.Framework; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Roslyn.Utilities; using StreamJsonRpc; diff --git a/src/Features/LanguageServer/Protocol/Workspaces/ILspWorkspace.cs b/src/Features/LanguageServer/Protocol/Workspaces/ILspWorkspace.cs index b210250478cb1..519ed552fb875 100644 --- a/src/Features/LanguageServer/Protocol/Workspaces/ILspWorkspace.cs +++ b/src/Features/LanguageServer/Protocol/Workspaces/ILspWorkspace.cs @@ -5,7 +5,7 @@ using Microsoft.CodeAnalysis.Text; using System.Threading; using System.Threading.Tasks; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer; diff --git a/src/Features/LanguageServer/Protocol/Workspaces/LspWorkspaceManager.cs b/src/Features/LanguageServer/Protocol/Workspaces/LspWorkspaceManager.cs index 15cf5611badc9..9f060f208e55d 100644 --- a/src/Features/LanguageServer/Protocol/Workspaces/LspWorkspaceManager.cs +++ b/src/Features/LanguageServer/Protocol/Workspaces/LspWorkspaceManager.cs @@ -16,7 +16,7 @@ using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.Text; using Microsoft.CommonLanguageServerProtocol.Framework; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.LanguageServer; diff --git a/src/Features/LanguageServer/Protocol/xlf/LanguageServerProtocolResources.cs.xlf b/src/Features/LanguageServer/Protocol/xlf/LanguageServerProtocolResources.cs.xlf new file mode 100644 index 0000000000000..b71c0adf33dd1 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/xlf/LanguageServerProtocolResources.cs.xlf @@ -0,0 +1,42 @@ + + + + + + Unable to deserialize Uri. Unexpected value encountered: {0} + Unable to deserialize Uri. Unexpected value encountered: {0} + + + + Unable to deserialize MarkupContent. Unexpected value encountered: {0} + Unable to deserialize MarkupContent. Unexpected value encountered: {0} + + + + A SumType cannot have another SumType as type parameter. + A SumType cannot have another SumType as type parameter. + + + + None of the SumType type parameters could be deserialized + None of the SumType type parameters could be deserialized + + + + Type {0} is missing a contructor that takes a single string as parameter. + Type {0} is missing a contructor that takes a single string as parameter. + + + + Unable to deserialize string-based enum. Unexpected data encountered: {0} + Unable to deserialize string-based enum. Unexpected data encountered: {0} + + + + Unable to deserialize TextDocumentSyncOptions. Unexpected value encountered: {0} + Unable to deserialize TextDocumentSyncOptions. Unexpected value encountered: {0} + + + + + \ No newline at end of file diff --git a/src/Features/LanguageServer/Protocol/xlf/LanguageServerProtocolResources.de.xlf b/src/Features/LanguageServer/Protocol/xlf/LanguageServerProtocolResources.de.xlf new file mode 100644 index 0000000000000..3bf1bf65b72e9 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/xlf/LanguageServerProtocolResources.de.xlf @@ -0,0 +1,42 @@ + + + + + + Unable to deserialize Uri. Unexpected value encountered: {0} + Unable to deserialize Uri. Unexpected value encountered: {0} + + + + Unable to deserialize MarkupContent. Unexpected value encountered: {0} + Unable to deserialize MarkupContent. Unexpected value encountered: {0} + + + + A SumType cannot have another SumType as type parameter. + A SumType cannot have another SumType as type parameter. + + + + None of the SumType type parameters could be deserialized + None of the SumType type parameters could be deserialized + + + + Type {0} is missing a contructor that takes a single string as parameter. + Type {0} is missing a contructor that takes a single string as parameter. + + + + Unable to deserialize string-based enum. Unexpected data encountered: {0} + Unable to deserialize string-based enum. Unexpected data encountered: {0} + + + + Unable to deserialize TextDocumentSyncOptions. Unexpected value encountered: {0} + Unable to deserialize TextDocumentSyncOptions. Unexpected value encountered: {0} + + + + + \ No newline at end of file diff --git a/src/Features/LanguageServer/Protocol/xlf/LanguageServerProtocolResources.es.xlf b/src/Features/LanguageServer/Protocol/xlf/LanguageServerProtocolResources.es.xlf new file mode 100644 index 0000000000000..7b0b92e7d121d --- /dev/null +++ b/src/Features/LanguageServer/Protocol/xlf/LanguageServerProtocolResources.es.xlf @@ -0,0 +1,42 @@ + + + + + + Unable to deserialize Uri. Unexpected value encountered: {0} + Unable to deserialize Uri. Unexpected value encountered: {0} + + + + Unable to deserialize MarkupContent. Unexpected value encountered: {0} + Unable to deserialize MarkupContent. Unexpected value encountered: {0} + + + + A SumType cannot have another SumType as type parameter. + A SumType cannot have another SumType as type parameter. + + + + None of the SumType type parameters could be deserialized + None of the SumType type parameters could be deserialized + + + + Type {0} is missing a contructor that takes a single string as parameter. + Type {0} is missing a contructor that takes a single string as parameter. + + + + Unable to deserialize string-based enum. Unexpected data encountered: {0} + Unable to deserialize string-based enum. Unexpected data encountered: {0} + + + + Unable to deserialize TextDocumentSyncOptions. Unexpected value encountered: {0} + Unable to deserialize TextDocumentSyncOptions. Unexpected value encountered: {0} + + + + + \ No newline at end of file diff --git a/src/Features/LanguageServer/Protocol/xlf/LanguageServerProtocolResources.fr.xlf b/src/Features/LanguageServer/Protocol/xlf/LanguageServerProtocolResources.fr.xlf new file mode 100644 index 0000000000000..a74931dcbd67f --- /dev/null +++ b/src/Features/LanguageServer/Protocol/xlf/LanguageServerProtocolResources.fr.xlf @@ -0,0 +1,42 @@ + + + + + + Unable to deserialize Uri. Unexpected value encountered: {0} + Unable to deserialize Uri. Unexpected value encountered: {0} + + + + Unable to deserialize MarkupContent. Unexpected value encountered: {0} + Unable to deserialize MarkupContent. Unexpected value encountered: {0} + + + + A SumType cannot have another SumType as type parameter. + A SumType cannot have another SumType as type parameter. + + + + None of the SumType type parameters could be deserialized + None of the SumType type parameters could be deserialized + + + + Type {0} is missing a contructor that takes a single string as parameter. + Type {0} is missing a contructor that takes a single string as parameter. + + + + Unable to deserialize string-based enum. Unexpected data encountered: {0} + Unable to deserialize string-based enum. Unexpected data encountered: {0} + + + + Unable to deserialize TextDocumentSyncOptions. Unexpected value encountered: {0} + Unable to deserialize TextDocumentSyncOptions. Unexpected value encountered: {0} + + + + + \ No newline at end of file diff --git a/src/Features/LanguageServer/Protocol/xlf/LanguageServerProtocolResources.it.xlf b/src/Features/LanguageServer/Protocol/xlf/LanguageServerProtocolResources.it.xlf new file mode 100644 index 0000000000000..95b1cb4926719 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/xlf/LanguageServerProtocolResources.it.xlf @@ -0,0 +1,42 @@ + + + + + + Unable to deserialize Uri. Unexpected value encountered: {0} + Unable to deserialize Uri. Unexpected value encountered: {0} + + + + Unable to deserialize MarkupContent. Unexpected value encountered: {0} + Unable to deserialize MarkupContent. Unexpected value encountered: {0} + + + + A SumType cannot have another SumType as type parameter. + A SumType cannot have another SumType as type parameter. + + + + None of the SumType type parameters could be deserialized + None of the SumType type parameters could be deserialized + + + + Type {0} is missing a contructor that takes a single string as parameter. + Type {0} is missing a contructor that takes a single string as parameter. + + + + Unable to deserialize string-based enum. Unexpected data encountered: {0} + Unable to deserialize string-based enum. Unexpected data encountered: {0} + + + + Unable to deserialize TextDocumentSyncOptions. Unexpected value encountered: {0} + Unable to deserialize TextDocumentSyncOptions. Unexpected value encountered: {0} + + + + + \ No newline at end of file diff --git a/src/Features/LanguageServer/Protocol/xlf/LanguageServerProtocolResources.ja.xlf b/src/Features/LanguageServer/Protocol/xlf/LanguageServerProtocolResources.ja.xlf new file mode 100644 index 0000000000000..b887612bdea33 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/xlf/LanguageServerProtocolResources.ja.xlf @@ -0,0 +1,42 @@ + + + + + + Unable to deserialize Uri. Unexpected value encountered: {0} + Unable to deserialize Uri. Unexpected value encountered: {0} + + + + Unable to deserialize MarkupContent. Unexpected value encountered: {0} + Unable to deserialize MarkupContent. Unexpected value encountered: {0} + + + + A SumType cannot have another SumType as type parameter. + A SumType cannot have another SumType as type parameter. + + + + None of the SumType type parameters could be deserialized + None of the SumType type parameters could be deserialized + + + + Type {0} is missing a contructor that takes a single string as parameter. + Type {0} is missing a contructor that takes a single string as parameter. + + + + Unable to deserialize string-based enum. Unexpected data encountered: {0} + Unable to deserialize string-based enum. Unexpected data encountered: {0} + + + + Unable to deserialize TextDocumentSyncOptions. Unexpected value encountered: {0} + Unable to deserialize TextDocumentSyncOptions. Unexpected value encountered: {0} + + + + + \ No newline at end of file diff --git a/src/Features/LanguageServer/Protocol/xlf/LanguageServerProtocolResources.ko.xlf b/src/Features/LanguageServer/Protocol/xlf/LanguageServerProtocolResources.ko.xlf new file mode 100644 index 0000000000000..107178ba6596b --- /dev/null +++ b/src/Features/LanguageServer/Protocol/xlf/LanguageServerProtocolResources.ko.xlf @@ -0,0 +1,42 @@ + + + + + + Unable to deserialize Uri. Unexpected value encountered: {0} + Unable to deserialize Uri. Unexpected value encountered: {0} + + + + Unable to deserialize MarkupContent. Unexpected value encountered: {0} + Unable to deserialize MarkupContent. Unexpected value encountered: {0} + + + + A SumType cannot have another SumType as type parameter. + A SumType cannot have another SumType as type parameter. + + + + None of the SumType type parameters could be deserialized + None of the SumType type parameters could be deserialized + + + + Type {0} is missing a contructor that takes a single string as parameter. + Type {0} is missing a contructor that takes a single string as parameter. + + + + Unable to deserialize string-based enum. Unexpected data encountered: {0} + Unable to deserialize string-based enum. Unexpected data encountered: {0} + + + + Unable to deserialize TextDocumentSyncOptions. Unexpected value encountered: {0} + Unable to deserialize TextDocumentSyncOptions. Unexpected value encountered: {0} + + + + + \ No newline at end of file diff --git a/src/Features/LanguageServer/Protocol/xlf/LanguageServerProtocolResources.pl.xlf b/src/Features/LanguageServer/Protocol/xlf/LanguageServerProtocolResources.pl.xlf new file mode 100644 index 0000000000000..4def9b9667fe1 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/xlf/LanguageServerProtocolResources.pl.xlf @@ -0,0 +1,42 @@ + + + + + + Unable to deserialize Uri. Unexpected value encountered: {0} + Unable to deserialize Uri. Unexpected value encountered: {0} + + + + Unable to deserialize MarkupContent. Unexpected value encountered: {0} + Unable to deserialize MarkupContent. Unexpected value encountered: {0} + + + + A SumType cannot have another SumType as type parameter. + A SumType cannot have another SumType as type parameter. + + + + None of the SumType type parameters could be deserialized + None of the SumType type parameters could be deserialized + + + + Type {0} is missing a contructor that takes a single string as parameter. + Type {0} is missing a contructor that takes a single string as parameter. + + + + Unable to deserialize string-based enum. Unexpected data encountered: {0} + Unable to deserialize string-based enum. Unexpected data encountered: {0} + + + + Unable to deserialize TextDocumentSyncOptions. Unexpected value encountered: {0} + Unable to deserialize TextDocumentSyncOptions. Unexpected value encountered: {0} + + + + + \ No newline at end of file diff --git a/src/Features/LanguageServer/Protocol/xlf/LanguageServerProtocolResources.pt-BR.xlf b/src/Features/LanguageServer/Protocol/xlf/LanguageServerProtocolResources.pt-BR.xlf new file mode 100644 index 0000000000000..d805a81a2a064 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/xlf/LanguageServerProtocolResources.pt-BR.xlf @@ -0,0 +1,42 @@ + + + + + + Unable to deserialize Uri. Unexpected value encountered: {0} + Unable to deserialize Uri. Unexpected value encountered: {0} + + + + Unable to deserialize MarkupContent. Unexpected value encountered: {0} + Unable to deserialize MarkupContent. Unexpected value encountered: {0} + + + + A SumType cannot have another SumType as type parameter. + A SumType cannot have another SumType as type parameter. + + + + None of the SumType type parameters could be deserialized + None of the SumType type parameters could be deserialized + + + + Type {0} is missing a contructor that takes a single string as parameter. + Type {0} is missing a contructor that takes a single string as parameter. + + + + Unable to deserialize string-based enum. Unexpected data encountered: {0} + Unable to deserialize string-based enum. Unexpected data encountered: {0} + + + + Unable to deserialize TextDocumentSyncOptions. Unexpected value encountered: {0} + Unable to deserialize TextDocumentSyncOptions. Unexpected value encountered: {0} + + + + + \ No newline at end of file diff --git a/src/Features/LanguageServer/Protocol/xlf/LanguageServerProtocolResources.ru.xlf b/src/Features/LanguageServer/Protocol/xlf/LanguageServerProtocolResources.ru.xlf new file mode 100644 index 0000000000000..97bddd6544310 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/xlf/LanguageServerProtocolResources.ru.xlf @@ -0,0 +1,42 @@ + + + + + + Unable to deserialize Uri. Unexpected value encountered: {0} + Unable to deserialize Uri. Unexpected value encountered: {0} + + + + Unable to deserialize MarkupContent. Unexpected value encountered: {0} + Unable to deserialize MarkupContent. Unexpected value encountered: {0} + + + + A SumType cannot have another SumType as type parameter. + A SumType cannot have another SumType as type parameter. + + + + None of the SumType type parameters could be deserialized + None of the SumType type parameters could be deserialized + + + + Type {0} is missing a contructor that takes a single string as parameter. + Type {0} is missing a contructor that takes a single string as parameter. + + + + Unable to deserialize string-based enum. Unexpected data encountered: {0} + Unable to deserialize string-based enum. Unexpected data encountered: {0} + + + + Unable to deserialize TextDocumentSyncOptions. Unexpected value encountered: {0} + Unable to deserialize TextDocumentSyncOptions. Unexpected value encountered: {0} + + + + + \ No newline at end of file diff --git a/src/Features/LanguageServer/Protocol/xlf/LanguageServerProtocolResources.tr.xlf b/src/Features/LanguageServer/Protocol/xlf/LanguageServerProtocolResources.tr.xlf new file mode 100644 index 0000000000000..d9c24acadfc31 --- /dev/null +++ b/src/Features/LanguageServer/Protocol/xlf/LanguageServerProtocolResources.tr.xlf @@ -0,0 +1,42 @@ + + + + + + Unable to deserialize Uri. Unexpected value encountered: {0} + Unable to deserialize Uri. Unexpected value encountered: {0} + + + + Unable to deserialize MarkupContent. Unexpected value encountered: {0} + Unable to deserialize MarkupContent. Unexpected value encountered: {0} + + + + A SumType cannot have another SumType as type parameter. + A SumType cannot have another SumType as type parameter. + + + + None of the SumType type parameters could be deserialized + None of the SumType type parameters could be deserialized + + + + Type {0} is missing a contructor that takes a single string as parameter. + Type {0} is missing a contructor that takes a single string as parameter. + + + + Unable to deserialize string-based enum. Unexpected data encountered: {0} + Unable to deserialize string-based enum. Unexpected data encountered: {0} + + + + Unable to deserialize TextDocumentSyncOptions. Unexpected value encountered: {0} + Unable to deserialize TextDocumentSyncOptions. Unexpected value encountered: {0} + + + + + \ No newline at end of file diff --git a/src/Features/LanguageServer/Protocol/xlf/LanguageServerProtocolResources.zh-Hans.xlf b/src/Features/LanguageServer/Protocol/xlf/LanguageServerProtocolResources.zh-Hans.xlf new file mode 100644 index 0000000000000..ee5d59d3e025c --- /dev/null +++ b/src/Features/LanguageServer/Protocol/xlf/LanguageServerProtocolResources.zh-Hans.xlf @@ -0,0 +1,42 @@ + + + + + + Unable to deserialize Uri. Unexpected value encountered: {0} + Unable to deserialize Uri. Unexpected value encountered: {0} + + + + Unable to deserialize MarkupContent. Unexpected value encountered: {0} + Unable to deserialize MarkupContent. Unexpected value encountered: {0} + + + + A SumType cannot have another SumType as type parameter. + A SumType cannot have another SumType as type parameter. + + + + None of the SumType type parameters could be deserialized + None of the SumType type parameters could be deserialized + + + + Type {0} is missing a contructor that takes a single string as parameter. + Type {0} is missing a contructor that takes a single string as parameter. + + + + Unable to deserialize string-based enum. Unexpected data encountered: {0} + Unable to deserialize string-based enum. Unexpected data encountered: {0} + + + + Unable to deserialize TextDocumentSyncOptions. Unexpected value encountered: {0} + Unable to deserialize TextDocumentSyncOptions. Unexpected value encountered: {0} + + + + + \ No newline at end of file diff --git a/src/Features/LanguageServer/Protocol/xlf/LanguageServerProtocolResources.zh-Hant.xlf b/src/Features/LanguageServer/Protocol/xlf/LanguageServerProtocolResources.zh-Hant.xlf new file mode 100644 index 0000000000000..893ee21fdbf7a --- /dev/null +++ b/src/Features/LanguageServer/Protocol/xlf/LanguageServerProtocolResources.zh-Hant.xlf @@ -0,0 +1,42 @@ + + + + + + Unable to deserialize Uri. Unexpected value encountered: {0} + Unable to deserialize Uri. Unexpected value encountered: {0} + + + + Unable to deserialize MarkupContent. Unexpected value encountered: {0} + Unable to deserialize MarkupContent. Unexpected value encountered: {0} + + + + A SumType cannot have another SumType as type parameter. + A SumType cannot have another SumType as type parameter. + + + + None of the SumType type parameters could be deserialized + None of the SumType type parameters could be deserialized + + + + Type {0} is missing a contructor that takes a single string as parameter. + Type {0} is missing a contructor that takes a single string as parameter. + + + + Unable to deserialize string-based enum. Unexpected data encountered: {0} + Unable to deserialize string-based enum. Unexpected data encountered: {0} + + + + Unable to deserialize TextDocumentSyncOptions. Unexpected value encountered: {0} + Unable to deserialize TextDocumentSyncOptions. Unexpected value encountered: {0} + + + + + \ No newline at end of file diff --git a/src/Features/LanguageServer/ProtocolUnitTests/CodeActions/CodeActionResolveTests.cs b/src/Features/LanguageServer/ProtocolUnitTests/CodeActions/CodeActionResolveTests.cs index 86fa8acf2edab..0564f561e6b8c 100644 --- a/src/Features/LanguageServer/ProtocolUnitTests/CodeActions/CodeActionResolveTests.cs +++ b/src/Features/LanguageServer/ProtocolUnitTests/CodeActions/CodeActionResolveTests.cs @@ -12,11 +12,11 @@ using System.Threading.Tasks; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Shared.Extensions; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Roslyn.Test.Utilities; using Xunit; using Xunit.Abstractions; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.UnitTests.CodeActions { diff --git a/src/Features/LanguageServer/ProtocolUnitTests/CodeActions/CodeActionsTests.cs b/src/Features/LanguageServer/ProtocolUnitTests/CodeActions/CodeActionsTests.cs index 5ceb1320728be..2c9d44ed66c84 100644 --- a/src/Features/LanguageServer/ProtocolUnitTests/CodeActions/CodeActionsTests.cs +++ b/src/Features/LanguageServer/ProtocolUnitTests/CodeActions/CodeActionsTests.cs @@ -11,12 +11,12 @@ using Microsoft.CodeAnalysis.CSharp.AddImport; using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.LanguageServer.Handler.CodeActions; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Newtonsoft.Json.Linq; using Roslyn.Test.Utilities; using Xunit; using Xunit.Abstractions; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.UnitTests.CodeActions; diff --git a/src/Features/LanguageServer/ProtocolUnitTests/CodeActions/RunCodeActionsTests.cs b/src/Features/LanguageServer/ProtocolUnitTests/CodeActions/RunCodeActionsTests.cs index 3798eef6a2245..7812d7ac25c1a 100644 --- a/src/Features/LanguageServer/ProtocolUnitTests/CodeActions/RunCodeActionsTests.cs +++ b/src/Features/LanguageServer/ProtocolUnitTests/CodeActions/RunCodeActionsTests.cs @@ -14,7 +14,7 @@ using Roslyn.Utilities; using Xunit; using Xunit.Abstractions; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.UnitTests.CodeActions { diff --git a/src/Features/LanguageServer/ProtocolUnitTests/CodeLens/AbstractCodeLensTests.cs b/src/Features/LanguageServer/ProtocolUnitTests/CodeLens/AbstractCodeLensTests.cs index 62bab340d8ef2..15a821f255992 100644 --- a/src/Features/LanguageServer/ProtocolUnitTests/CodeLens/AbstractCodeLensTests.cs +++ b/src/Features/LanguageServer/ProtocolUnitTests/CodeLens/AbstractCodeLensTests.cs @@ -9,7 +9,7 @@ using Roslyn.Test.Utilities; using Xunit; using Xunit.Abstractions; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.UnitTests.CodeLens; diff --git a/src/Features/LanguageServer/ProtocolUnitTests/CodeLens/CSharpCodeLensTests.cs b/src/Features/LanguageServer/ProtocolUnitTests/CodeLens/CSharpCodeLensTests.cs index b0156d4720c97..f3db678c7c4db 100644 --- a/src/Features/LanguageServer/ProtocolUnitTests/CodeLens/CSharpCodeLensTests.cs +++ b/src/Features/LanguageServer/ProtocolUnitTests/CodeLens/CSharpCodeLensTests.cs @@ -10,7 +10,7 @@ using Roslyn.Test.Utilities; using Xunit; using Xunit.Abstractions; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.UnitTests.CodeLens; diff --git a/src/Features/LanguageServer/ProtocolUnitTests/Completion/CompletionFeaturesTests.cs b/src/Features/LanguageServer/ProtocolUnitTests/Completion/CompletionFeaturesTests.cs index 79ec13c17bf0c..fcd2cd0cf51b0 100644 --- a/src/Features/LanguageServer/ProtocolUnitTests/Completion/CompletionFeaturesTests.cs +++ b/src/Features/LanguageServer/ProtocolUnitTests/Completion/CompletionFeaturesTests.cs @@ -18,12 +18,12 @@ using Microsoft.CodeAnalysis.Shared.TestHooks; using Microsoft.CodeAnalysis.Test.Utilities; using Microsoft.CodeAnalysis.Text; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Roslyn.Test.Utilities; using Roslyn.Utilities; using Xunit; using Xunit.Abstractions; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.UnitTests.Completion; @@ -152,7 +152,7 @@ void M() ? new() { NewText = "System.Threading.Tasks.Task", Range = new() { Start = new(0, 20), End = new(0, 24) } } : new() { NewText = "using System.Threading.Tasks;\r\n\r\n", Range = new() { Start = new(1, 0), End = new(1, 0) } }; - AssertJsonEquals([expectedAdditionalEdit], resolvedItem.AdditionalTextEdits); + AssertJsonEquals(new[] { expectedAdditionalEdit }, resolvedItem.AdditionalTextEdits); Assert.Null(resolvedItem.LabelDetails.Detail); Assert.Null(resolvedItem.FilterText); @@ -234,7 +234,7 @@ void M(object o) Assert.Equal(CompletionItemKind.Method, resolvedItem.Kind); var expectedAdditionalEdit = new TextEdit() { NewText = "using NS2;\r\n\r\n", Range = new() { Start = new(1, 0), End = new(1, 0) } }; - AssertJsonEquals([expectedAdditionalEdit], resolvedItem.AdditionalTextEdits); + AssertJsonEquals(new[] { expectedAdditionalEdit }, resolvedItem.AdditionalTextEdits); Assert.Null(resolvedItem.LabelDetails.Detail); Assert.Null(resolvedItem.FilterText); @@ -640,7 +640,7 @@ void M() Assert.Equal(CompletionItemKind.Class, resolvedItem1.Kind); var expectedAdditionalEdit1 = new TextEdit() { NewText = "using Namespace1;\r\n\r\n", Range = new() { Start = new(1, 0), End = new(1, 0) } }; - AssertJsonEquals([expectedAdditionalEdit1], resolvedItem1.AdditionalTextEdits); + AssertJsonEquals(new[] { expectedAdditionalEdit1 }, resolvedItem1.AdditionalTextEdits); var resolvedItem2 = await testLspServer.ExecuteRequestAsync(LSP.Methods.TextDocumentCompletionResolveName, itemFromNS2, CancellationToken.None).ConfigureAwait(false); Assert.Equal("Namespace2", resolvedItem2.LabelDetails.Description); @@ -648,7 +648,7 @@ void M() Assert.Equal(CompletionItemKind.Class, resolvedItem2.Kind); var expectedAdditionalEdit2 = new TextEdit() { NewText = "using Namespace2;\r\n\r\n", Range = new() { Start = new(1, 0), End = new(1, 0) } }; - AssertJsonEquals([expectedAdditionalEdit2], resolvedItem2.AdditionalTextEdits); + AssertJsonEquals(new[] { expectedAdditionalEdit2 }, resolvedItem2.AdditionalTextEdits); } [Theory, CombinatorialData, WorkItem("https://github.com/dotnet/vscode-csharp/issues/5732")] diff --git a/src/Features/LanguageServer/ProtocolUnitTests/Completion/CompletionResolveTests.cs b/src/Features/LanguageServer/ProtocolUnitTests/Completion/CompletionResolveTests.cs index 484e430cbde73..ded42d6c3be54 100644 --- a/src/Features/LanguageServer/ProtocolUnitTests/Completion/CompletionResolveTests.cs +++ b/src/Features/LanguageServer/ProtocolUnitTests/Completion/CompletionResolveTests.cs @@ -15,13 +15,14 @@ using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.Shared.TestHooks; using Microsoft.CodeAnalysis.Text; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Microsoft.VisualStudio.Text.Adornments; using Newtonsoft.Json; using Roslyn.Test.Utilities; using Xunit; using Xunit.Abstractions; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; +using Microsoft.CodeAnalysis.Extensions; namespace Microsoft.CodeAnalysis.LanguageServer.UnitTests.Completion { @@ -395,7 +396,7 @@ private static VSInternalCompletionItem CreateResolvedCompletionItem( }; } - expectedCompletionItem.Description = description; + expectedCompletionItem.Description = description.ToLSPElement(); return expectedCompletionItem; } diff --git a/src/Features/LanguageServer/ProtocolUnitTests/Completion/CompletionTests.cs b/src/Features/LanguageServer/ProtocolUnitTests/Completion/CompletionTests.cs index 7915af83e6c72..603f21bd9e255 100644 --- a/src/Features/LanguageServer/ProtocolUnitTests/Completion/CompletionTests.cs +++ b/src/Features/LanguageServer/ProtocolUnitTests/Completion/CompletionTests.cs @@ -12,11 +12,11 @@ using Microsoft.CodeAnalysis.Completion; using Microsoft.CodeAnalysis.LanguageServer.Handler.Completion; using Microsoft.CodeAnalysis.Options; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Roslyn.Test.Utilities; using Xunit; using Xunit.Abstractions; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.UnitTests.Completion { diff --git a/src/Features/LanguageServer/ProtocolUnitTests/Configuration/DidChangeConfigurationNotificationHandlerTest.cs b/src/Features/LanguageServer/ProtocolUnitTests/Configuration/DidChangeConfigurationNotificationHandlerTest.cs index dcaef789e760d..5f25d7e7beb89 100644 --- a/src/Features/LanguageServer/ProtocolUnitTests/Configuration/DidChangeConfigurationNotificationHandlerTest.cs +++ b/src/Features/LanguageServer/ProtocolUnitTests/Configuration/DidChangeConfigurationNotificationHandlerTest.cs @@ -12,7 +12,7 @@ using Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces; using Microsoft.CodeAnalysis.LanguageServer.Handler.Configuration; using Microsoft.CodeAnalysis.Options; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Newtonsoft.Json.Linq; using Roslyn.Test.Utilities; using Roslyn.Utilities; diff --git a/src/Features/LanguageServer/ProtocolUnitTests/Definitions/GoToDefinitionTests.cs b/src/Features/LanguageServer/ProtocolUnitTests/Definitions/GoToDefinitionTests.cs index 21dfb82201275..6f573aaeb6e8a 100644 --- a/src/Features/LanguageServer/ProtocolUnitTests/Definitions/GoToDefinitionTests.cs +++ b/src/Features/LanguageServer/ProtocolUnitTests/Definitions/GoToDefinitionTests.cs @@ -12,7 +12,7 @@ using Roslyn.Test.Utilities; using Xunit; using Xunit.Abstractions; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.UnitTests.Definitions { diff --git a/src/Features/LanguageServer/ProtocolUnitTests/Definitions/GoToTypeDefinitionTests.cs b/src/Features/LanguageServer/ProtocolUnitTests/Definitions/GoToTypeDefinitionTests.cs index 7f72c6e6a731c..a4a1aa043ee23 100644 --- a/src/Features/LanguageServer/ProtocolUnitTests/Definitions/GoToTypeDefinitionTests.cs +++ b/src/Features/LanguageServer/ProtocolUnitTests/Definitions/GoToTypeDefinitionTests.cs @@ -10,7 +10,7 @@ using Roslyn.Test.Utilities; using Xunit; using Xunit.Abstractions; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.UnitTests.Definitions { diff --git a/src/Features/LanguageServer/ProtocolUnitTests/Diagnostics/AbstractPullDiagnosticTestsBase.cs b/src/Features/LanguageServer/ProtocolUnitTests/Diagnostics/AbstractPullDiagnosticTestsBase.cs index de681d29cfe1a..625694fe03e29 100644 --- a/src/Features/LanguageServer/ProtocolUnitTests/Diagnostics/AbstractPullDiagnosticTestsBase.cs +++ b/src/Features/LanguageServer/ProtocolUnitTests/Diagnostics/AbstractPullDiagnosticTestsBase.cs @@ -23,12 +23,12 @@ using Microsoft.CodeAnalysis.TaskList; using Microsoft.CodeAnalysis.Test.Utilities; using Microsoft.CodeAnalysis.Text; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Roslyn.Test.Utilities; using Roslyn.Utilities; using Xunit; using Xunit.Abstractions; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.UnitTests.Diagnostics { diff --git a/src/Features/LanguageServer/ProtocolUnitTests/Diagnostics/AdditionalFileDiagnosticsTests.cs b/src/Features/LanguageServer/ProtocolUnitTests/Diagnostics/AdditionalFileDiagnosticsTests.cs index c86b6e2847154..f1402110cb780 100644 --- a/src/Features/LanguageServer/ProtocolUnitTests/Diagnostics/AdditionalFileDiagnosticsTests.cs +++ b/src/Features/LanguageServer/ProtocolUnitTests/Diagnostics/AdditionalFileDiagnosticsTests.cs @@ -15,7 +15,7 @@ using Roslyn.Test.Utilities; using Xunit; using Xunit.Abstractions; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.UnitTests.Diagnostics; public class AdditionalFileDiagnosticsTests : AbstractPullDiagnosticTestsBase diff --git a/src/Features/LanguageServer/ProtocolUnitTests/Diagnostics/PullDiagnosticTests.cs b/src/Features/LanguageServer/ProtocolUnitTests/Diagnostics/PullDiagnosticTests.cs index a01330a5786e9..8ea2769bd20da 100644 --- a/src/Features/LanguageServer/ProtocolUnitTests/Diagnostics/PullDiagnosticTests.cs +++ b/src/Features/LanguageServer/ProtocolUnitTests/Diagnostics/PullDiagnosticTests.cs @@ -14,13 +14,13 @@ using Microsoft.CodeAnalysis.SolutionCrawler; using Microsoft.CodeAnalysis.TaskList; using Microsoft.CodeAnalysis.Text; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Roslyn.Test.Utilities; using Roslyn.Test.Utilities.TestGenerators; using Roslyn.Utilities; using Xunit; using Xunit.Abstractions; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.UnitTests.Diagnostics { @@ -1115,15 +1115,16 @@ class A { } [Theory] - [InlineData("1", VSDiagnosticRank.Low, false)] - [InlineData("1", VSDiagnosticRank.Low, true)] - [InlineData("2", VSDiagnosticRank.Default, false)] - [InlineData("2", VSDiagnosticRank.Default, true)] - [InlineData("3", VSDiagnosticRank.High, false)] - [InlineData("3", VSDiagnosticRank.High, true)] + [InlineData("1", (int)VSDiagnosticRank.Low, false)] + [InlineData("1", (int)VSDiagnosticRank.Low, true)] + [InlineData("2", (int)VSDiagnosticRank.Default, false)] + [InlineData("2", (int)VSDiagnosticRank.Default, true)] + [InlineData("3", (int)VSDiagnosticRank.High, false)] + [InlineData("3", (int)VSDiagnosticRank.High, true)] public async Task TestWorkspaceTodoForClosedFilesWithFSAOffAndTodoOn_Priorities( - string priString, VSDiagnosticRank rank, bool mutatingLspWorkspace) + string priString, int intRank, bool mutatingLspWorkspace) { + var rank = (VSDiagnosticRank)intRank; var markup1 = @" // todo: goo diff --git a/src/Features/LanguageServer/ProtocolUnitTests/Diagnostics/WorkspaceProjectDiagnosticsTests.cs b/src/Features/LanguageServer/ProtocolUnitTests/Diagnostics/WorkspaceProjectDiagnosticsTests.cs index dd00e12d848e2..c89c1bd405aaa 100644 --- a/src/Features/LanguageServer/ProtocolUnitTests/Diagnostics/WorkspaceProjectDiagnosticsTests.cs +++ b/src/Features/LanguageServer/ProtocolUnitTests/Diagnostics/WorkspaceProjectDiagnosticsTests.cs @@ -14,7 +14,7 @@ using Microsoft.CodeAnalysis.Test.Utilities; using Xunit; using Xunit.Abstractions; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.UnitTests.Diagnostics; public class WorkspaceProjectDiagnosticsTests : AbstractPullDiagnosticTestsBase diff --git a/src/Features/LanguageServer/ProtocolUnitTests/DocumentChanges/DocumentChangesTests.LinkedDocuments.cs b/src/Features/LanguageServer/ProtocolUnitTests/DocumentChanges/DocumentChangesTests.LinkedDocuments.cs index db82b356290d7..f16259e730118 100644 --- a/src/Features/LanguageServer/ProtocolUnitTests/DocumentChanges/DocumentChangesTests.LinkedDocuments.cs +++ b/src/Features/LanguageServer/ProtocolUnitTests/DocumentChanges/DocumentChangesTests.LinkedDocuments.cs @@ -6,7 +6,7 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Roslyn.Utilities; using Xunit; diff --git a/src/Features/LanguageServer/ProtocolUnitTests/DocumentChanges/DocumentChangesTests.WithFindAllReferences.cs b/src/Features/LanguageServer/ProtocolUnitTests/DocumentChanges/DocumentChangesTests.WithFindAllReferences.cs index 7ad6732e9ac9c..7f7c16bc01079 100644 --- a/src/Features/LanguageServer/ProtocolUnitTests/DocumentChanges/DocumentChangesTests.WithFindAllReferences.cs +++ b/src/Features/LanguageServer/ProtocolUnitTests/DocumentChanges/DocumentChangesTests.WithFindAllReferences.cs @@ -5,7 +5,7 @@ using System.Linq; using System.Threading.Tasks; using Microsoft.CodeAnalysis.LanguageServer.UnitTests.References; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Xunit; namespace Microsoft.CodeAnalysis.LanguageServer.UnitTests.DocumentChanges diff --git a/src/Features/LanguageServer/ProtocolUnitTests/DocumentChanges/DocumentChangesTests.cs b/src/Features/LanguageServer/ProtocolUnitTests/DocumentChanges/DocumentChangesTests.cs index b810e787e946e..09ab03f8ac5fb 100644 --- a/src/Features/LanguageServer/ProtocolUnitTests/DocumentChanges/DocumentChangesTests.cs +++ b/src/Features/LanguageServer/ProtocolUnitTests/DocumentChanges/DocumentChangesTests.cs @@ -9,11 +9,11 @@ using System.Threading.Tasks; using Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces; using Microsoft.CodeAnalysis.LanguageServer.Handler; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Roslyn.Test.Utilities; using Xunit; using Xunit.Abstractions; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.UnitTests.DocumentChanges { diff --git a/src/Features/LanguageServer/ProtocolUnitTests/FoldingRanges/FoldingRangesTests.cs b/src/Features/LanguageServer/ProtocolUnitTests/FoldingRanges/FoldingRangesTests.cs index d994b0aabdf56..e4d22c2c3cfff 100644 --- a/src/Features/LanguageServer/ProtocolUnitTests/FoldingRanges/FoldingRangesTests.cs +++ b/src/Features/LanguageServer/ProtocolUnitTests/FoldingRanges/FoldingRangesTests.cs @@ -11,7 +11,7 @@ using Roslyn.Test.Utilities; using Xunit; using Xunit.Abstractions; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.UnitTests.FoldingRanges { diff --git a/src/Features/LanguageServer/ProtocolUnitTests/FormatNewFile/FormatNewFileTests.cs b/src/Features/LanguageServer/ProtocolUnitTests/FormatNewFile/FormatNewFileTests.cs index 66b2dff98a2d3..8dd97f5428f23 100644 --- a/src/Features/LanguageServer/ProtocolUnitTests/FormatNewFile/FormatNewFileTests.cs +++ b/src/Features/LanguageServer/ProtocolUnitTests/FormatNewFile/FormatNewFileTests.cs @@ -6,7 +6,7 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.LanguageServer.ExternalAccess.Razor; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Roslyn.Test.Utilities; using Roslyn.Utilities; using Xunit; diff --git a/src/Features/LanguageServer/ProtocolUnitTests/Formatting/FormatDocumentOnTypeTests.cs b/src/Features/LanguageServer/ProtocolUnitTests/Formatting/FormatDocumentOnTypeTests.cs index 4be504bd97971..4da943682de44 100644 --- a/src/Features/LanguageServer/ProtocolUnitTests/Formatting/FormatDocumentOnTypeTests.cs +++ b/src/Features/LanguageServer/ProtocolUnitTests/Formatting/FormatDocumentOnTypeTests.cs @@ -10,7 +10,7 @@ using Roslyn.Test.Utilities; using Xunit; using Xunit.Abstractions; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.UnitTests.Formatting { diff --git a/src/Features/LanguageServer/ProtocolUnitTests/Formatting/FormatDocumentRangeTests.cs b/src/Features/LanguageServer/ProtocolUnitTests/Formatting/FormatDocumentRangeTests.cs index a3a09526bdb9f..70acb3ab8995a 100644 --- a/src/Features/LanguageServer/ProtocolUnitTests/Formatting/FormatDocumentRangeTests.cs +++ b/src/Features/LanguageServer/ProtocolUnitTests/Formatting/FormatDocumentRangeTests.cs @@ -10,7 +10,7 @@ using Roslyn.Test.Utilities; using Xunit; using Xunit.Abstractions; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.UnitTests.Formatting { diff --git a/src/Features/LanguageServer/ProtocolUnitTests/Formatting/FormatDocumentTests.cs b/src/Features/LanguageServer/ProtocolUnitTests/Formatting/FormatDocumentTests.cs index b9dafa1334dc5..bc85cdaf0a894 100644 --- a/src/Features/LanguageServer/ProtocolUnitTests/Formatting/FormatDocumentTests.cs +++ b/src/Features/LanguageServer/ProtocolUnitTests/Formatting/FormatDocumentTests.cs @@ -11,7 +11,7 @@ using Roslyn.Test.Utilities; using Xunit; using Xunit.Abstractions; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.UnitTests.Formatting { diff --git a/src/Features/LanguageServer/ProtocolUnitTests/Highlights/DocumentHighlightTests.cs b/src/Features/LanguageServer/ProtocolUnitTests/Highlights/DocumentHighlightTests.cs index 2a74031ff7064..ed6865185b319 100644 --- a/src/Features/LanguageServer/ProtocolUnitTests/Highlights/DocumentHighlightTests.cs +++ b/src/Features/LanguageServer/ProtocolUnitTests/Highlights/DocumentHighlightTests.cs @@ -11,7 +11,7 @@ using Roslyn.Test.Utilities; using Xunit; using Xunit.Abstractions; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.UnitTests.Highlights { diff --git a/src/Features/LanguageServer/ProtocolUnitTests/Hover/HoverTests.cs b/src/Features/LanguageServer/ProtocolUnitTests/Hover/HoverTests.cs index 020b5fd7186cc..402d309db5426 100644 --- a/src/Features/LanguageServer/ProtocolUnitTests/Hover/HoverTests.cs +++ b/src/Features/LanguageServer/ProtocolUnitTests/Hover/HoverTests.cs @@ -8,20 +8,16 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.PooledObjects; -using Microsoft.VisualStudio.Text.Adornments; using Roslyn.Test.Utilities; +using Roslyn.Text.Adornments; using Xunit; using Xunit.Abstractions; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.UnitTests.Hover { - public class HoverTests : AbstractLanguageServerProtocolTests + public class HoverTests(ITestOutputHelper testOutputHelper) : AbstractLanguageServerProtocolTests(testOutputHelper) { - public HoverTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) - { - } - [Theory, CombinatorialData] public async Task TestGetHoverAsync(bool mutatingLspWorkspace) { diff --git a/src/Features/LanguageServer/ProtocolUnitTests/InlayHint/AbstractInlayHintTests.cs b/src/Features/LanguageServer/ProtocolUnitTests/InlayHint/AbstractInlayHintTests.cs index a8a7b3ca17926..84a63a9e872e2 100644 --- a/src/Features/LanguageServer/ProtocolUnitTests/InlayHint/AbstractInlayHintTests.cs +++ b/src/Features/LanguageServer/ProtocolUnitTests/InlayHint/AbstractInlayHintTests.cs @@ -10,7 +10,7 @@ using Roslyn.Test.Utilities; using Xunit; using Xunit.Abstractions; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.UnitTests.InlayHint; diff --git a/src/Features/LanguageServer/ProtocolUnitTests/InlayHint/CSharpInlayHintTests.cs b/src/Features/LanguageServer/ProtocolUnitTests/InlayHint/CSharpInlayHintTests.cs index a338d1d753c80..d4d0801f11fcc 100644 --- a/src/Features/LanguageServer/ProtocolUnitTests/InlayHint/CSharpInlayHintTests.cs +++ b/src/Features/LanguageServer/ProtocolUnitTests/InlayHint/CSharpInlayHintTests.cs @@ -9,7 +9,7 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.InlineHints; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Microsoft.CodeAnalysis.LanguageServer.Handler.InlayHint; using Microsoft.CodeAnalysis.Text; using Newtonsoft.Json; @@ -17,7 +17,7 @@ using StreamJsonRpc; using Xunit; using Xunit.Abstractions; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.UnitTests.InlayHint { diff --git a/src/Features/LanguageServer/ProtocolUnitTests/InlayHint/VisualBasicInlayHintTests.cs b/src/Features/LanguageServer/ProtocolUnitTests/InlayHint/VisualBasicInlayHintTests.cs index 8c813143bf2e0..e4093edc0a2c9 100644 --- a/src/Features/LanguageServer/ProtocolUnitTests/InlayHint/VisualBasicInlayHintTests.cs +++ b/src/Features/LanguageServer/ProtocolUnitTests/InlayHint/VisualBasicInlayHintTests.cs @@ -8,10 +8,10 @@ using System.Text; using System.Threading.Tasks; using Microsoft.CodeAnalysis.InlineHints; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Xunit; using Xunit.Abstractions; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.UnitTests.InlayHint { diff --git a/src/Features/LanguageServer/ProtocolUnitTests/InlineCompletions/InlineCompletionsTests.cs b/src/Features/LanguageServer/ProtocolUnitTests/InlineCompletions/InlineCompletionsTests.cs index 1f1ef1d0f164c..cf44a18869abb 100644 --- a/src/Features/LanguageServer/ProtocolUnitTests/InlineCompletions/InlineCompletionsTests.cs +++ b/src/Features/LanguageServer/ProtocolUnitTests/InlineCompletions/InlineCompletionsTests.cs @@ -11,7 +11,7 @@ using Roslyn.Utilities; using Xunit; using Xunit.Abstractions; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.UnitTests; diff --git a/src/Features/LanguageServer/ProtocolUnitTests/LanguageServerTargetTests.cs b/src/Features/LanguageServer/ProtocolUnitTests/LanguageServerTargetTests.cs index b2d54797c3c0b..2e0b0d75ea3c9 100644 --- a/src/Features/LanguageServer/ProtocolUnitTests/LanguageServerTargetTests.cs +++ b/src/Features/LanguageServer/ProtocolUnitTests/LanguageServerTargetTests.cs @@ -10,7 +10,7 @@ using Microsoft.CodeAnalysis.LanguageServer.Handler; using Microsoft.CodeAnalysis.LanguageServer.Handler.DocumentChanges; using Microsoft.CodeAnalysis.Test.Utilities; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Roslyn.Test.Utilities; using StreamJsonRpc; using Xunit; diff --git a/src/Features/LanguageServer/ProtocolUnitTests/MapCode/MapCodeTests.cs b/src/Features/LanguageServer/ProtocolUnitTests/MapCode/MapCodeTests.cs index 7123dc19bfda5..34b77184a44cb 100644 --- a/src/Features/LanguageServer/ProtocolUnitTests/MapCode/MapCodeTests.cs +++ b/src/Features/LanguageServer/ProtocolUnitTests/MapCode/MapCodeTests.cs @@ -13,11 +13,11 @@ using Microsoft.CodeAnalysis.MapCode; using Microsoft.CodeAnalysis.Test.Utilities; using Microsoft.CodeAnalysis.Text; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Roslyn.Test.Utilities; using Xunit; using Xunit.Abstractions; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.UnitTests.CodeMapping; diff --git a/src/Features/LanguageServer/ProtocolUnitTests/Miscellaneous/LspMiscellaneousFilesWorkspaceTests.cs b/src/Features/LanguageServer/ProtocolUnitTests/Miscellaneous/LspMiscellaneousFilesWorkspaceTests.cs index 4497ade9c34cd..9173cfd5b6771 100644 --- a/src/Features/LanguageServer/ProtocolUnitTests/Miscellaneous/LspMiscellaneousFilesWorkspaceTests.cs +++ b/src/Features/LanguageServer/ProtocolUnitTests/Miscellaneous/LspMiscellaneousFilesWorkspaceTests.cs @@ -13,7 +13,7 @@ using Roslyn.Utilities; using Xunit; using Xunit.Abstractions; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.UnitTests.Miscellaneous; diff --git a/src/Features/LanguageServer/ProtocolUnitTests/OnAutoInsert/OnAutoInsertTests.cs b/src/Features/LanguageServer/ProtocolUnitTests/OnAutoInsert/OnAutoInsertTests.cs index 2ae8f329d7b9a..8d486e0c11af7 100644 --- a/src/Features/LanguageServer/ProtocolUnitTests/OnAutoInsert/OnAutoInsertTests.cs +++ b/src/Features/LanguageServer/ProtocolUnitTests/OnAutoInsert/OnAutoInsertTests.cs @@ -6,12 +6,12 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Test.Utilities; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Roslyn.Test.Utilities; using Roslyn.Utilities; using Xunit; using Xunit.Abstractions; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.UnitTests.OnAutoInsert { diff --git a/src/Features/LanguageServer/ProtocolUnitTests/Ordering/FailingMutatingRequestHandler.cs b/src/Features/LanguageServer/ProtocolUnitTests/Ordering/FailingMutatingRequestHandler.cs index 1968051ca3771..dd6253890813c 100644 --- a/src/Features/LanguageServer/ProtocolUnitTests/Ordering/FailingMutatingRequestHandler.cs +++ b/src/Features/LanguageServer/ProtocolUnitTests/Ordering/FailingMutatingRequestHandler.cs @@ -8,7 +8,7 @@ using System.Threading.Tasks; using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.LanguageServer.Handler; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.UnitTests.RequestOrdering { diff --git a/src/Features/LanguageServer/ProtocolUnitTests/Ordering/FailingRequestHandler.cs b/src/Features/LanguageServer/ProtocolUnitTests/Ordering/FailingRequestHandler.cs index 3ae1219f938d7..8841d8d0c721d 100644 --- a/src/Features/LanguageServer/ProtocolUnitTests/Ordering/FailingRequestHandler.cs +++ b/src/Features/LanguageServer/ProtocolUnitTests/Ordering/FailingRequestHandler.cs @@ -8,7 +8,7 @@ using System.Threading.Tasks; using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.LanguageServer.Handler; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.UnitTests.RequestOrdering { diff --git a/src/Features/LanguageServer/ProtocolUnitTests/Ordering/LongRunningNonMutatingRequestHandler.cs b/src/Features/LanguageServer/ProtocolUnitTests/Ordering/LongRunningNonMutatingRequestHandler.cs index 0ef3ce29f1c11..7efbb2c1de428 100644 --- a/src/Features/LanguageServer/ProtocolUnitTests/Ordering/LongRunningNonMutatingRequestHandler.cs +++ b/src/Features/LanguageServer/ProtocolUnitTests/Ordering/LongRunningNonMutatingRequestHandler.cs @@ -8,7 +8,7 @@ using System.Threading.Tasks; using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.LanguageServer.Handler; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Xunit.Sdk; namespace Microsoft.CodeAnalysis.LanguageServer.UnitTests.RequestOrdering diff --git a/src/Features/LanguageServer/ProtocolUnitTests/Ordering/MutatingRequestHandler.cs b/src/Features/LanguageServer/ProtocolUnitTests/Ordering/MutatingRequestHandler.cs index 1492eddbdd29c..4d1e9c523b4f2 100644 --- a/src/Features/LanguageServer/ProtocolUnitTests/Ordering/MutatingRequestHandler.cs +++ b/src/Features/LanguageServer/ProtocolUnitTests/Ordering/MutatingRequestHandler.cs @@ -8,7 +8,7 @@ using System.Threading.Tasks; using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.LanguageServer.Handler; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.UnitTests.RequestOrdering { diff --git a/src/Features/LanguageServer/ProtocolUnitTests/Ordering/NonLSPSolutionRequestHandlerProvider.cs b/src/Features/LanguageServer/ProtocolUnitTests/Ordering/NonLSPSolutionRequestHandlerProvider.cs index 91ce841d967fd..71c430fce1a42 100644 --- a/src/Features/LanguageServer/ProtocolUnitTests/Ordering/NonLSPSolutionRequestHandlerProvider.cs +++ b/src/Features/LanguageServer/ProtocolUnitTests/Ordering/NonLSPSolutionRequestHandlerProvider.cs @@ -8,7 +8,7 @@ using System.Threading.Tasks; using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.LanguageServer.Handler; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Xunit; namespace Microsoft.CodeAnalysis.LanguageServer.UnitTests.RequestOrdering diff --git a/src/Features/LanguageServer/ProtocolUnitTests/Ordering/NonMutatingRequestHandler.cs b/src/Features/LanguageServer/ProtocolUnitTests/Ordering/NonMutatingRequestHandler.cs index 90167e66d8b6c..4a8d27209653e 100644 --- a/src/Features/LanguageServer/ProtocolUnitTests/Ordering/NonMutatingRequestHandler.cs +++ b/src/Features/LanguageServer/ProtocolUnitTests/Ordering/NonMutatingRequestHandler.cs @@ -8,7 +8,7 @@ using System.Threading.Tasks; using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.LanguageServer.Handler; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.UnitTests.RequestOrdering { diff --git a/src/Features/LanguageServer/ProtocolUnitTests/Ordering/RequestOrderingTests.cs b/src/Features/LanguageServer/ProtocolUnitTests/Ordering/RequestOrderingTests.cs index 8a3e3b82ac7d5..f9bf10d53f502 100644 --- a/src/Features/LanguageServer/ProtocolUnitTests/Ordering/RequestOrderingTests.cs +++ b/src/Features/LanguageServer/ProtocolUnitTests/Ordering/RequestOrderingTests.cs @@ -8,12 +8,12 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Test.Utilities; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Roslyn.Test.Utilities; using Roslyn.Utilities; using Xunit; using Xunit.Abstractions; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.UnitTests.RequestOrdering { diff --git a/src/Features/LanguageServer/ProtocolUnitTests/ProjectContext/GetTextDocumentWithContextHandlerTests.cs b/src/Features/LanguageServer/ProtocolUnitTests/ProjectContext/GetTextDocumentWithContextHandlerTests.cs index 445bd2fd2a3ac..44befe94053bb 100644 --- a/src/Features/LanguageServer/ProtocolUnitTests/ProjectContext/GetTextDocumentWithContextHandlerTests.cs +++ b/src/Features/LanguageServer/ProtocolUnitTests/ProjectContext/GetTextDocumentWithContextHandlerTests.cs @@ -9,7 +9,7 @@ using Roslyn.Test.Utilities; using Xunit; using Xunit.Abstractions; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.UnitTests.ProjectContext { diff --git a/src/Features/LanguageServer/ProtocolUnitTests/ProtocolConversionsTests.cs b/src/Features/LanguageServer/ProtocolUnitTests/ProtocolConversionsTests.cs index 9174454f9358b..8685d125fc2a5 100644 --- a/src/Features/LanguageServer/ProtocolUnitTests/ProtocolConversionsTests.cs +++ b/src/Features/LanguageServer/ProtocolUnitTests/ProtocolConversionsTests.cs @@ -6,11 +6,11 @@ using System.IO; using System.Linq; using Microsoft.CodeAnalysis.Text; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Roslyn.Test.Utilities; using Roslyn.Utilities; using Xunit; -using Range = Microsoft.VisualStudio.LanguageServer.Protocol.Range; +using Range = Roslyn.LanguageServer.Protocol.Range; namespace Microsoft.CodeAnalysis.LanguageServer.UnitTests { diff --git a/src/Features/LanguageServer/ProtocolUnitTests/References/FindAllReferencesHandlerFeaturesTests.cs b/src/Features/LanguageServer/ProtocolUnitTests/References/FindAllReferencesHandlerFeaturesTests.cs index 0f94a621190c9..145c8a4244930 100644 --- a/src/Features/LanguageServer/ProtocolUnitTests/References/FindAllReferencesHandlerFeaturesTests.cs +++ b/src/Features/LanguageServer/ProtocolUnitTests/References/FindAllReferencesHandlerFeaturesTests.cs @@ -13,7 +13,7 @@ using Roslyn.Test.Utilities; using Xunit; using Xunit.Abstractions; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.UnitTests.References; public class FindAllReferencesHandlerFeaturesTests : AbstractLanguageServerProtocolTests diff --git a/src/Features/LanguageServer/ProtocolUnitTests/References/FindAllReferencesHandlerTests.cs b/src/Features/LanguageServer/ProtocolUnitTests/References/FindAllReferencesHandlerTests.cs index de2ac649cabd8..8ce97f51eaf0e 100644 --- a/src/Features/LanguageServer/ProtocolUnitTests/References/FindAllReferencesHandlerTests.cs +++ b/src/Features/LanguageServer/ProtocolUnitTests/References/FindAllReferencesHandlerTests.cs @@ -11,22 +11,18 @@ using Microsoft.CodeAnalysis.Editor.ReferenceHighlighting; using Microsoft.CodeAnalysis.Editor.Shared.Extensions; using Microsoft.CodeAnalysis.LanguageServer.Handler; -using Microsoft.VisualStudio.Text.Adornments; using Newtonsoft.Json.Linq; using Roslyn.Test.Utilities; +using Roslyn.Text.Adornments; using Roslyn.Utilities; using Xunit; using Xunit.Abstractions; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.UnitTests.References { - public class FindAllReferencesHandlerTests : AbstractLanguageServerProtocolTests + public class FindAllReferencesHandlerTests(ITestOutputHelper testOutputHelper) : AbstractLanguageServerProtocolTests(testOutputHelper) { - public FindAllReferencesHandlerTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) - { - } - [Theory, CombinatorialData] public async Task TestFindAllReferencesAsync(bool mutatingLspWorkspace) { @@ -314,7 +310,8 @@ private static void AssertValidDefinitionProperties(LSP.VSInternalReferenceItem[ var definitionId = definition.DefinitionId; Assert.NotNull(definition.DefinitionText); - Assert.Equal(definitionGlyph.GetImageId(), definition.DefinitionIcon.ImageId); + Assert.Equal(definitionGlyph.GetImageId().Guid, definition.DefinitionIcon.ImageId.Guid); + Assert.Equal(definitionGlyph.GetImageId().Id, definition.DefinitionIcon.ImageId.Id); for (var i = 0; i < referenceItems.Length; i++) { diff --git a/src/Features/LanguageServer/ProtocolUnitTests/References/FindImplementationsTests.cs b/src/Features/LanguageServer/ProtocolUnitTests/References/FindImplementationsTests.cs index 619f5f8bca657..04757003522cc 100644 --- a/src/Features/LanguageServer/ProtocolUnitTests/References/FindImplementationsTests.cs +++ b/src/Features/LanguageServer/ProtocolUnitTests/References/FindImplementationsTests.cs @@ -12,7 +12,7 @@ using Roslyn.Test.Utilities; using Xunit; using Xunit.Abstractions; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.UnitTests.References { diff --git a/src/Features/LanguageServer/ProtocolUnitTests/Rename/PrepareRenameTests.cs b/src/Features/LanguageServer/ProtocolUnitTests/Rename/PrepareRenameTests.cs index 77bafa6ab2553..a7dc51a2878a2 100644 --- a/src/Features/LanguageServer/ProtocolUnitTests/Rename/PrepareRenameTests.cs +++ b/src/Features/LanguageServer/ProtocolUnitTests/Rename/PrepareRenameTests.cs @@ -8,7 +8,7 @@ using Roslyn.Test.Utilities; using Xunit; using Xunit.Abstractions; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.UnitTests.Rename; diff --git a/src/Features/LanguageServer/ProtocolUnitTests/Rename/RenameTests.cs b/src/Features/LanguageServer/ProtocolUnitTests/Rename/RenameTests.cs index a7e3acf1ceaf1..b245bb44a420c 100644 --- a/src/Features/LanguageServer/ProtocolUnitTests/Rename/RenameTests.cs +++ b/src/Features/LanguageServer/ProtocolUnitTests/Rename/RenameTests.cs @@ -9,11 +9,11 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Roslyn.Test.Utilities; using Xunit; using Xunit.Abstractions; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.UnitTests.Rename { diff --git a/src/Features/LanguageServer/ProtocolUnitTests/SemanticTokens/AbstractSemanticTokensTests.cs b/src/Features/LanguageServer/ProtocolUnitTests/SemanticTokens/AbstractSemanticTokensTests.cs index a48d678acbbba..41be32a276c6e 100644 --- a/src/Features/LanguageServer/ProtocolUnitTests/SemanticTokens/AbstractSemanticTokensTests.cs +++ b/src/Features/LanguageServer/ProtocolUnitTests/SemanticTokens/AbstractSemanticTokensTests.cs @@ -11,12 +11,12 @@ using Microsoft.CodeAnalysis.LanguageServer.ExternalAccess.Razor; using Microsoft.CodeAnalysis.LanguageServer.Handler.SemanticTokens; using Microsoft.CodeAnalysis.Text; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Roslyn.Test.Utilities; using Roslyn.Utilities; using Xunit; using Xunit.Abstractions; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.UnitTests.SemanticTokens { @@ -121,7 +121,7 @@ private protected static async Task VerifyBasicInvariantsAndNoMultiLineTokens(Te /// fail. This groups rows by five (so that way the diff can't desynced from the start of a new token), and also replaces the token index /// back with the string again. /// - protected static ImmutableArray ConvertToReadableFormat( + private protected static ImmutableArray ConvertToReadableFormat( ClientCapabilities capabilities, int[] data) { var convertedStringsBuilder = ImmutableArray.CreateBuilder(data.Length / 5); diff --git a/src/Features/LanguageServer/ProtocolUnitTests/SemanticTokens/SemanticTokensRangeTests.cs b/src/Features/LanguageServer/ProtocolUnitTests/SemanticTokens/SemanticTokensRangeTests.cs index 16bd29ab60575..26101d1f2de54 100644 --- a/src/Features/LanguageServer/ProtocolUnitTests/SemanticTokens/SemanticTokensRangeTests.cs +++ b/src/Features/LanguageServer/ProtocolUnitTests/SemanticTokens/SemanticTokensRangeTests.cs @@ -7,11 +7,11 @@ using System.Threading.Tasks; using Microsoft.CodeAnalysis.Classification; using Microsoft.CodeAnalysis.LanguageServer.Handler.SemanticTokens; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Roslyn.Test.Utilities; using Xunit; using Xunit.Abstractions; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; #pragma warning disable format // We want to force explicit column spacing within the collection literals in this file, so we disable formatting. diff --git a/src/Features/LanguageServer/ProtocolUnitTests/SemanticTokens/SemanticTokensRangesTests.cs b/src/Features/LanguageServer/ProtocolUnitTests/SemanticTokens/SemanticTokensRangesTests.cs index a4da27012775b..3b7b832625688 100644 --- a/src/Features/LanguageServer/ProtocolUnitTests/SemanticTokens/SemanticTokensRangesTests.cs +++ b/src/Features/LanguageServer/ProtocolUnitTests/SemanticTokens/SemanticTokensRangesTests.cs @@ -6,11 +6,11 @@ using System.Threading.Tasks; using Microsoft.CodeAnalysis.Classification; using Microsoft.CodeAnalysis.LanguageServer.Handler.SemanticTokens; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Roslyn.Test.Utilities; using Xunit; using Xunit.Abstractions; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.UnitTests.SemanticTokens { diff --git a/src/Features/LanguageServer/ProtocolUnitTests/SignatureHelp/SignatureHelpTests.cs b/src/Features/LanguageServer/ProtocolUnitTests/SignatureHelp/SignatureHelpTests.cs index aaf52c2a196f7..d654f0ff66553 100644 --- a/src/Features/LanguageServer/ProtocolUnitTests/SignatureHelp/SignatureHelpTests.cs +++ b/src/Features/LanguageServer/ProtocolUnitTests/SignatureHelp/SignatureHelpTests.cs @@ -8,7 +8,7 @@ using Roslyn.Test.Utilities; using Xunit; using Xunit.Abstractions; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.UnitTests.SignatureHelp { diff --git a/src/Features/LanguageServer/ProtocolUnitTests/SimplifyMethod/SimplifyMethodTests.cs b/src/Features/LanguageServer/ProtocolUnitTests/SimplifyMethod/SimplifyMethodTests.cs index df30cffdecbef..58bc84f9de14c 100644 --- a/src/Features/LanguageServer/ProtocolUnitTests/SimplifyMethod/SimplifyMethodTests.cs +++ b/src/Features/LanguageServer/ProtocolUnitTests/SimplifyMethod/SimplifyMethodTests.cs @@ -6,11 +6,11 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.LanguageServer.ExternalAccess.Razor; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Roslyn.Test.Utilities; using Xunit; using Xunit.Abstractions; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.UnitTests.SimplifyMethod { diff --git a/src/Features/LanguageServer/ProtocolUnitTests/SpellCheck/SpellCheckTests.cs b/src/Features/LanguageServer/ProtocolUnitTests/SpellCheck/SpellCheckTests.cs index edea38a93f87e..775d6669a6b43 100644 --- a/src/Features/LanguageServer/ProtocolUnitTests/SpellCheck/SpellCheckTests.cs +++ b/src/Features/LanguageServer/ProtocolUnitTests/SpellCheck/SpellCheckTests.cs @@ -10,7 +10,7 @@ using System.Threading.Tasks; using Microsoft.CodeAnalysis.LanguageServer.Handler; using Microsoft.CodeAnalysis.Text; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Roslyn.Test.Utilities; using Roslyn.Utilities; using Xunit; diff --git a/src/Features/LanguageServer/ProtocolUnitTests/Symbols/DocumentSymbolsTests.cs b/src/Features/LanguageServer/ProtocolUnitTests/Symbols/DocumentSymbolsTests.cs index e83bf0a27e495..4614695d0b830 100644 --- a/src/Features/LanguageServer/ProtocolUnitTests/Symbols/DocumentSymbolsTests.cs +++ b/src/Features/LanguageServer/ProtocolUnitTests/Symbols/DocumentSymbolsTests.cs @@ -11,7 +11,7 @@ using Roslyn.Test.Utilities; using Xunit; using Xunit.Abstractions; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.UnitTests.Symbols { diff --git a/src/Features/LanguageServer/ProtocolUnitTests/Symbols/WorkspaceSymbolsTests.cs b/src/Features/LanguageServer/ProtocolUnitTests/Symbols/WorkspaceSymbolsTests.cs index 0b4449767eefa..3b1225e6ba1db 100644 --- a/src/Features/LanguageServer/ProtocolUnitTests/Symbols/WorkspaceSymbolsTests.cs +++ b/src/Features/LanguageServer/ProtocolUnitTests/Symbols/WorkspaceSymbolsTests.cs @@ -13,7 +13,7 @@ using Roslyn.Test.Utilities; using Xunit; using Xunit.Abstractions; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.UnitTests.Symbols; diff --git a/src/Features/LanguageServer/ProtocolUnitTests/UriTests.cs b/src/Features/LanguageServer/ProtocolUnitTests/UriTests.cs index 9397048a659fa..863040cb99abe 100644 --- a/src/Features/LanguageServer/ProtocolUnitTests/UriTests.cs +++ b/src/Features/LanguageServer/ProtocolUnitTests/UriTests.cs @@ -11,7 +11,7 @@ using Roslyn.Test.Utilities; using Xunit; using Xunit.Abstractions; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.UnitTests; public class UriTests : AbstractLanguageServerProtocolTests diff --git a/src/Features/LanguageServer/ProtocolUnitTests/VSTypeScriptHandlerTests.cs b/src/Features/LanguageServer/ProtocolUnitTests/VSTypeScriptHandlerTests.cs index 3eab219e13982..816452481e3df 100644 --- a/src/Features/LanguageServer/ProtocolUnitTests/VSTypeScriptHandlerTests.cs +++ b/src/Features/LanguageServer/ProtocolUnitTests/VSTypeScriptHandlerTests.cs @@ -19,7 +19,7 @@ using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.Simplification; using Microsoft.CodeAnalysis.Test.Utilities; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Nerdbank.Streams; using Roslyn.Test.Utilities; using StreamJsonRpc; diff --git a/src/Features/LanguageServer/ProtocolUnitTests/ValidateBreakableRange/ValidateBreakableRangeTests.cs b/src/Features/LanguageServer/ProtocolUnitTests/ValidateBreakableRange/ValidateBreakableRangeTests.cs index 135c38254039d..740fc49e4cb53 100644 --- a/src/Features/LanguageServer/ProtocolUnitTests/ValidateBreakableRange/ValidateBreakableRangeTests.cs +++ b/src/Features/LanguageServer/ProtocolUnitTests/ValidateBreakableRange/ValidateBreakableRangeTests.cs @@ -8,7 +8,7 @@ using Roslyn.Test.Utilities; using Xunit; using Xunit.Abstractions; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.UnitTests.ValidateBreakableRange { diff --git a/src/Features/LanguageServer/ProtocolUnitTests/Workspaces/LspWorkspaceManagerTests.cs b/src/Features/LanguageServer/ProtocolUnitTests/Workspaces/LspWorkspaceManagerTests.cs index 8ee5c538f8e53..022f9ea21a797 100644 --- a/src/Features/LanguageServer/ProtocolUnitTests/Workspaces/LspWorkspaceManagerTests.cs +++ b/src/Features/LanguageServer/ProtocolUnitTests/Workspaces/LspWorkspaceManagerTests.cs @@ -15,7 +15,7 @@ using Roslyn.Test.Utilities; using Xunit; using Xunit.Abstractions; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.UnitTests.Workspaces; diff --git a/src/Features/Lsif/Generator/Generator.cs b/src/Features/Lsif/Generator/Generator.cs index 2c2cedfd29942..57dce53365a7b 100644 --- a/src/Features/Lsif/Generator/Generator.cs +++ b/src/Features/Lsif/Generator/Generator.cs @@ -20,10 +20,10 @@ using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.Text; using Microsoft.Extensions.Logging; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Roslyn.Utilities; -using LspProtocol = Microsoft.VisualStudio.LanguageServer.Protocol; -using Methods = Microsoft.VisualStudio.LanguageServer.Protocol.Methods; +using LspProtocol = Roslyn.LanguageServer.Protocol; +using Methods = Roslyn.LanguageServer.Protocol.Methods; namespace Microsoft.CodeAnalysis.LanguageServerIndexFormat.Generator { diff --git a/src/Features/Lsif/Generator/Graph/DefinitionRangeTag.cs b/src/Features/Lsif/Generator/Graph/DefinitionRangeTag.cs index 97cdaaa747cc7..34597d894776b 100644 --- a/src/Features/Lsif/Generator/Graph/DefinitionRangeTag.cs +++ b/src/Features/Lsif/Generator/Graph/DefinitionRangeTag.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServerIndexFormat.Generator.Graph; diff --git a/src/Features/Lsif/Generator/Graph/FoldingRangeResult.cs b/src/Features/Lsif/Generator/Graph/FoldingRangeResult.cs index cde2cdaca3597..de9c8ffb8558b 100644 --- a/src/Features/Lsif/Generator/Graph/FoldingRangeResult.cs +++ b/src/Features/Lsif/Generator/Graph/FoldingRangeResult.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Newtonsoft.Json; namespace Microsoft.CodeAnalysis.LanguageServerIndexFormat.Generator.Graph diff --git a/src/Features/Lsif/Generator/Graph/HoverResult.cs b/src/Features/Lsif/Generator/Graph/HoverResult.cs index 0a054dfceed7e..2dbd5246c5b2b 100644 --- a/src/Features/Lsif/Generator/Graph/HoverResult.cs +++ b/src/Features/Lsif/Generator/Graph/HoverResult.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Newtonsoft.Json; namespace Microsoft.CodeAnalysis.LanguageServerIndexFormat.Generator.Graph diff --git a/src/Features/Lsif/Generator/Graph/Range.cs b/src/Features/Lsif/Generator/Graph/Range.cs index 57bb63a695141..1affb5024a49f 100644 --- a/src/Features/Lsif/Generator/Graph/Range.cs +++ b/src/Features/Lsif/Generator/Graph/Range.cs @@ -3,7 +3,7 @@ // See the LICENSE file in the project root for more information. using Microsoft.CodeAnalysis.Text; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServerIndexFormat.Generator.Graph { diff --git a/src/Features/Lsif/Generator/Graph/SemanticTokensResult.cs b/src/Features/Lsif/Generator/Graph/SemanticTokensResult.cs index bc732d25edf54..7ff7ffdb6e3ff 100644 --- a/src/Features/Lsif/Generator/Graph/SemanticTokensResult.cs +++ b/src/Features/Lsif/Generator/Graph/SemanticTokensResult.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Newtonsoft.Json; namespace Microsoft.CodeAnalysis.LanguageServerIndexFormat.Generator.Graph diff --git a/src/Features/Lsif/Generator/ResultSetTracking/IResultSetTrackerExtensions.cs b/src/Features/Lsif/Generator/ResultSetTracking/IResultSetTrackerExtensions.cs index f2400eb5a8739..159848e0f3c35 100644 --- a/src/Features/Lsif/Generator/ResultSetTracking/IResultSetTrackerExtensions.cs +++ b/src/Features/Lsif/Generator/ResultSetTracking/IResultSetTrackerExtensions.cs @@ -8,7 +8,7 @@ using System.Text; using System.Threading.Tasks; using Microsoft.CodeAnalysis.LanguageServerIndexFormat.Generator.Graph; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServerIndexFormat.Generator.ResultSetTracking { diff --git a/src/Features/Lsif/GeneratorTest/DocumentSymbolTests.vb b/src/Features/Lsif/GeneratorTest/DocumentSymbolTests.vb index d4c8ebf1cb08a..06a05150c4d95 100644 --- a/src/Features/Lsif/GeneratorTest/DocumentSymbolTests.vb +++ b/src/Features/Lsif/GeneratorTest/DocumentSymbolTests.vb @@ -5,19 +5,20 @@ Imports Microsoft.CodeAnalysis.LanguageServerIndexFormat.Generator.Graph Imports Microsoft.CodeAnalysis.Test.Utilities Imports Roslyn.Test.Utilities -Imports LSP = Microsoft.VisualStudio.LanguageServer.Protocol +Imports LSP = Roslyn.LanguageServer.Protocol Namespace Microsoft.CodeAnalysis.LanguageServerIndexFormat.Generator.UnitTests Public Class DocumentSymbolTests - - - - - - - Public Async Function TestDefinition(code As String, expectedSymbolKind As LSP.SymbolKind, expectedText As String) As Task + + + + + + + Public Async Function TestDefinition(code As String, expectedSymbolKindInt As Integer, expectedText As String) As Task + Dim expectedSymbolKind = CType(expectedSymbolKindInt, LSP.SymbolKind) Dim lsif = Await TestLsifOutput.GenerateForWorkspaceAsync( diff --git a/src/Features/Lsif/GeneratorTest/FoldingRangeTests.vb b/src/Features/Lsif/GeneratorTest/FoldingRangeTests.vb index 42393c23a7363..14100027ef4c8 100644 --- a/src/Features/Lsif/GeneratorTest/FoldingRangeTests.vb +++ b/src/Features/Lsif/GeneratorTest/FoldingRangeTests.vb @@ -4,7 +4,7 @@ Imports Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces Imports Microsoft.CodeAnalysis.Test.Utilities -Imports Microsoft.VisualStudio.LanguageServer.Protocol +Imports Roslyn.LanguageServer.Protocol Imports Roslyn.Test.Utilities Imports Roslyn.Utilities diff --git a/src/Features/Lsif/GeneratorTest/HoverTests.vb b/src/Features/Lsif/GeneratorTest/HoverTests.vb index f47ac80a27087..108e3ff2ce181 100644 --- a/src/Features/Lsif/GeneratorTest/HoverTests.vb +++ b/src/Features/Lsif/GeneratorTest/HoverTests.vb @@ -4,7 +4,7 @@ Imports Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces Imports Microsoft.CodeAnalysis.Test.Utilities -Imports Microsoft.VisualStudio.LanguageServer.Protocol +Imports Roslyn.LanguageServer.Protocol Namespace Microsoft.CodeAnalysis.LanguageServerIndexFormat.Generator.UnitTests diff --git a/src/Features/Lsif/GeneratorTest/RangeResultSetTests.vb b/src/Features/Lsif/GeneratorTest/RangeResultSetTests.vb index c41fb236b127d..49cb55c5f5bf2 100644 --- a/src/Features/Lsif/GeneratorTest/RangeResultSetTests.vb +++ b/src/Features/Lsif/GeneratorTest/RangeResultSetTests.vb @@ -2,9 +2,8 @@ ' The .NET Foundation licenses this file to you under the MIT license. ' See the LICENSE file in the project root for more information. -Imports Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces Imports Microsoft.CodeAnalysis.Test.Utilities -Imports Microsoft.VisualStudio.LanguageServer.Protocol +Imports Roslyn.LanguageServer.Protocol Imports Roslyn.Test.Utilities Namespace Microsoft.CodeAnalysis.LanguageServerIndexFormat.Generator.UnitTests diff --git a/src/Features/Lsif/GeneratorTest/Utilities/TestLsifOutput.vb b/src/Features/Lsif/GeneratorTest/Utilities/TestLsifOutput.vb index 60360db7611a2..47643bc3eb9a6 100644 --- a/src/Features/Lsif/GeneratorTest/Utilities/TestLsifOutput.vb +++ b/src/Features/Lsif/GeneratorTest/Utilities/TestLsifOutput.vb @@ -14,7 +14,7 @@ Imports Microsoft.CodeAnalysis.Test.Utilities Imports Microsoft.CodeAnalysis.Text Imports Microsoft.Extensions.Logging Imports Roslyn.Utilities -Imports LSP = Microsoft.VisualStudio.LanguageServer.Protocol +Imports LSP = Roslyn.LanguageServer.Protocol Namespace Microsoft.CodeAnalysis.LanguageServerIndexFormat.Generator.UnitTests.Utilities Friend Class TestLsifOutput diff --git a/src/Tools/ExternalAccess/CompilerDeveloperSDK/Extensions/ProtocolConversions.cs b/src/Tools/ExternalAccess/CompilerDeveloperSDK/Extensions/ProtocolConversions.cs index a6816ca52bd1a..752672d37be51 100644 --- a/src/Tools/ExternalAccess/CompilerDeveloperSDK/Extensions/ProtocolConversions.cs +++ b/src/Tools/ExternalAccess/CompilerDeveloperSDK/Extensions/ProtocolConversions.cs @@ -1,9 +1,9 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using Microsoft.CodeAnalysis.Text; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; using PC = Microsoft.CodeAnalysis.LanguageServer.ProtocolConversions; namespace Microsoft.CodeAnalysis.ExternalAccess.CompilerDeveloperSdk; diff --git a/src/Tools/ExternalAccess/CompilerDeveloperSDK/Handler/AbstractCompilerDeveloperSdkLspServiceDocumentRequestHandler.cs b/src/Tools/ExternalAccess/CompilerDeveloperSDK/Handler/AbstractCompilerDeveloperSdkLspServiceDocumentRequestHandler.cs index f7d369881fc2f..dfe7937504bcd 100644 --- a/src/Tools/ExternalAccess/CompilerDeveloperSDK/Handler/AbstractCompilerDeveloperSdkLspServiceDocumentRequestHandler.cs +++ b/src/Tools/ExternalAccess/CompilerDeveloperSDK/Handler/AbstractCompilerDeveloperSdkLspServiceDocumentRequestHandler.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; using Microsoft.CodeAnalysis.LanguageServer.Handler; using Microsoft.CommonLanguageServerProtocol.Framework; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.ExternalAccess.CompilerDeveloperSdk; diff --git a/src/Tools/ExternalAccess/CompilerDeveloperSDK/InternalAPI.Unshipped.txt b/src/Tools/ExternalAccess/CompilerDeveloperSDK/InternalAPI.Unshipped.txt index 69dd5cb124846..6f4681aaa75dc 100644 --- a/src/Tools/ExternalAccess/CompilerDeveloperSDK/InternalAPI.Unshipped.txt +++ b/src/Tools/ExternalAccess/CompilerDeveloperSDK/InternalAPI.Unshipped.txt @@ -1,5 +1,5 @@ #nullable enable -abstract Microsoft.CodeAnalysis.ExternalAccess.CompilerDeveloperSdk.AbstractCompilerDeveloperSdkLspServiceDocumentRequestHandler.GetTextDocumentIdentifier(TRequest request) -> Microsoft.VisualStudio.LanguageServer.Protocol.TextDocumentIdentifier! +abstract Microsoft.CodeAnalysis.ExternalAccess.CompilerDeveloperSdk.AbstractCompilerDeveloperSdkLspServiceDocumentRequestHandler.GetTextDocumentIdentifier(TRequest request) -> Roslyn.LanguageServer.Protocol.TextDocumentIdentifier! abstract Microsoft.CodeAnalysis.ExternalAccess.CompilerDeveloperSdk.AbstractCompilerDeveloperSdkLspServiceDocumentRequestHandler.HandleRequestAsync(TRequest request, Microsoft.CodeAnalysis.ExternalAccess.CompilerDeveloperSdk.RequestContext context, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task! abstract Microsoft.CodeAnalysis.ExternalAccess.CompilerDeveloperSdk.AbstractCompilerDeveloperSdkLspServiceDocumentRequestHandler.MutatesSolutionState.get -> bool abstract Microsoft.CodeAnalysis.ExternalAccess.CompilerDeveloperSdk.AbstractCompilerDeveloperSdkLspServiceDocumentRequestHandler.RequiresLSPSolution.get -> bool @@ -35,9 +35,9 @@ Microsoft.CodeAnalysis.ExternalAccess.CompilerDeveloperSdk.RequestContext.Reques Microsoft.CodeAnalysis.ExternalAccess.CompilerDeveloperSdk.RequestContext.RequestContext(Microsoft.CodeAnalysis.LanguageServer.Handler.RequestContext context) -> void Microsoft.CodeAnalysis.ExternalAccess.CompilerDeveloperSdk.RequestContext.Solution.get -> Microsoft.CodeAnalysis.Solution? Microsoft.CodeAnalysis.ExternalAccess.CompilerDeveloperSdk.RequestContext.Workspace.get -> Microsoft.CodeAnalysis.Workspace? -static Microsoft.CodeAnalysis.ExternalAccess.CompilerDeveloperSdk.ProtocolConversions.LinePositionToPosition(Microsoft.CodeAnalysis.Text.LinePosition linePosition) -> Microsoft.VisualStudio.LanguageServer.Protocol.Position! -static Microsoft.CodeAnalysis.ExternalAccess.CompilerDeveloperSdk.ProtocolConversions.LinePositionToRange(Microsoft.CodeAnalysis.Text.LinePositionSpan linePositionSpan) -> Microsoft.VisualStudio.LanguageServer.Protocol.Range! -static Microsoft.CodeAnalysis.ExternalAccess.CompilerDeveloperSdk.ProtocolConversions.PositionToLinePosition(Microsoft.VisualStudio.LanguageServer.Protocol.Position! position) -> Microsoft.CodeAnalysis.Text.LinePosition -static Microsoft.CodeAnalysis.ExternalAccess.CompilerDeveloperSdk.ProtocolConversions.RangeToLinePositionSpan(Microsoft.VisualStudio.LanguageServer.Protocol.Range! range) -> Microsoft.CodeAnalysis.Text.LinePositionSpan -static Microsoft.CodeAnalysis.ExternalAccess.CompilerDeveloperSdk.ProtocolConversions.RangeToTextSpan(Microsoft.VisualStudio.LanguageServer.Protocol.Range! range, Microsoft.CodeAnalysis.Text.SourceText! text) -> Microsoft.CodeAnalysis.Text.TextSpan -static Microsoft.CodeAnalysis.ExternalAccess.CompilerDeveloperSdk.ProtocolConversions.TextSpanToRange(Microsoft.CodeAnalysis.Text.TextSpan textSpan, Microsoft.CodeAnalysis.Text.SourceText! text) -> Microsoft.VisualStudio.LanguageServer.Protocol.Range! +static Microsoft.CodeAnalysis.ExternalAccess.CompilerDeveloperSdk.ProtocolConversions.LinePositionToPosition(Microsoft.CodeAnalysis.Text.LinePosition linePosition) -> Roslyn.LanguageServer.Protocol.Position! +static Microsoft.CodeAnalysis.ExternalAccess.CompilerDeveloperSdk.ProtocolConversions.LinePositionToRange(Microsoft.CodeAnalysis.Text.LinePositionSpan linePositionSpan) -> Roslyn.LanguageServer.Protocol.Range! +static Microsoft.CodeAnalysis.ExternalAccess.CompilerDeveloperSdk.ProtocolConversions.PositionToLinePosition(Roslyn.LanguageServer.Protocol.Position! position) -> Microsoft.CodeAnalysis.Text.LinePosition +static Microsoft.CodeAnalysis.ExternalAccess.CompilerDeveloperSdk.ProtocolConversions.RangeToLinePositionSpan(Roslyn.LanguageServer.Protocol.Range! range) -> Microsoft.CodeAnalysis.Text.LinePositionSpan +static Microsoft.CodeAnalysis.ExternalAccess.CompilerDeveloperSdk.ProtocolConversions.RangeToTextSpan(Roslyn.LanguageServer.Protocol.Range! range, Microsoft.CodeAnalysis.Text.SourceText! text) -> Microsoft.CodeAnalysis.Text.TextSpan +static Microsoft.CodeAnalysis.ExternalAccess.CompilerDeveloperSdk.ProtocolConversions.TextSpanToRange(Microsoft.CodeAnalysis.Text.TextSpan textSpan, Microsoft.CodeAnalysis.Text.SourceText! text) -> Roslyn.LanguageServer.Protocol.Range! diff --git a/src/Tools/ExternalAccess/FSharp/VS/IFSharpWorkspaceProjectContextFactory.cs b/src/Tools/ExternalAccess/FSharp/VS/IFSharpWorkspaceProjectContextFactory.cs index 67c5294f273c8..31638ec5db697 100644 --- a/src/Tools/ExternalAccess/FSharp/VS/IFSharpWorkspaceProjectContextFactory.cs +++ b/src/Tools/ExternalAccess/FSharp/VS/IFSharpWorkspaceProjectContextFactory.cs @@ -7,12 +7,9 @@ using System.Collections.Immutable; using System.Composition; using System.Linq; -using System.Text; using System.Threading; -using System.Threading.Tasks; using Microsoft.CodeAnalysis.Editor.Shared.Utilities; using Microsoft.CodeAnalysis.Host.Mef; -using Microsoft.VisualStudio.LanguageServer.Protocol; using Microsoft.VisualStudio.LanguageServices.ProjectSystem; using Microsoft.VisualStudio.Shell.Interop; diff --git a/src/Tools/ExternalAccess/Razor/Cohost/AbstractRazorCohostDocumentRequestHandler.cs b/src/Tools/ExternalAccess/Razor/Cohost/AbstractRazorCohostDocumentRequestHandler.cs index e0fa705ee48b1..30fb43c5301d7 100644 --- a/src/Tools/ExternalAccess/Razor/Cohost/AbstractRazorCohostDocumentRequestHandler.cs +++ b/src/Tools/ExternalAccess/Razor/Cohost/AbstractRazorCohostDocumentRequestHandler.cs @@ -4,7 +4,7 @@ using System; using Microsoft.CommonLanguageServerProtocol.Framework; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.ExternalAccess.Razor.Cohost; diff --git a/src/Tools/ExternalAccess/Razor/Cohost/RazorCohostDidChangeEndpoint.cs b/src/Tools/ExternalAccess/Razor/Cohost/RazorCohostDidChangeEndpoint.cs index 1a7d0d17ca431..02b61da27d25f 100644 --- a/src/Tools/ExternalAccess/Razor/Cohost/RazorCohostDidChangeEndpoint.cs +++ b/src/Tools/ExternalAccess/Razor/Cohost/RazorCohostDidChangeEndpoint.cs @@ -11,7 +11,7 @@ using Microsoft.CodeAnalysis.LanguageServer.Handler; using Microsoft.CodeAnalysis.Text; using Microsoft.CommonLanguageServerProtocol.Framework; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.ExternalAccess.Razor.Cohost; diff --git a/src/Tools/ExternalAccess/Razor/Cohost/RazorCohostDidCloseEndpoint.cs b/src/Tools/ExternalAccess/Razor/Cohost/RazorCohostDidCloseEndpoint.cs index fccc2a100a2b5..ff93b7d39ddca 100644 --- a/src/Tools/ExternalAccess/Razor/Cohost/RazorCohostDidCloseEndpoint.cs +++ b/src/Tools/ExternalAccess/Razor/Cohost/RazorCohostDidCloseEndpoint.cs @@ -9,7 +9,7 @@ using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.LanguageServer.Handler; using Microsoft.CommonLanguageServerProtocol.Framework; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.ExternalAccess.Razor.Cohost; diff --git a/src/Tools/ExternalAccess/Razor/Cohost/RazorCohostDidOpenEndpoint.cs b/src/Tools/ExternalAccess/Razor/Cohost/RazorCohostDidOpenEndpoint.cs index cf04d3c08f08f..9a41609cb91c1 100644 --- a/src/Tools/ExternalAccess/Razor/Cohost/RazorCohostDidOpenEndpoint.cs +++ b/src/Tools/ExternalAccess/Razor/Cohost/RazorCohostDidOpenEndpoint.cs @@ -10,7 +10,7 @@ using Microsoft.CodeAnalysis.LanguageServer.Handler; using Microsoft.CodeAnalysis.Text; using Microsoft.CommonLanguageServerProtocol.Framework; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.ExternalAccess.Razor.Cohost; diff --git a/src/Tools/ExternalAccess/Razor/Cohost/RazorCohostLanguageClient.cs b/src/Tools/ExternalAccess/Razor/Cohost/RazorCohostLanguageClient.cs index 81149a07a2ea7..2e0c8a40e0a50 100644 --- a/src/Tools/ExternalAccess/Razor/Cohost/RazorCohostLanguageClient.cs +++ b/src/Tools/ExternalAccess/Razor/Cohost/RazorCohostLanguageClient.cs @@ -12,9 +12,9 @@ using Microsoft.CodeAnalysis.Options; using Microsoft.VisualStudio.Composition; using Microsoft.VisualStudio.LanguageServer.Client; -using Microsoft.VisualStudio.LanguageServer.Protocol; using Microsoft.VisualStudio.Utilities; using Newtonsoft.Json; +using Roslyn.LanguageServer.Protocol; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.ExternalAccess.Razor.Cohost; diff --git a/src/Tools/ExternalAccess/Razor/IRazorCapabilitiesProvider.cs b/src/Tools/ExternalAccess/Razor/IRazorCapabilitiesProvider.cs index 81463e63d70aa..ac26de8cbd80c 100644 --- a/src/Tools/ExternalAccess/Razor/IRazorCapabilitiesProvider.cs +++ b/src/Tools/ExternalAccess/Razor/IRazorCapabilitiesProvider.cs @@ -3,7 +3,7 @@ // See the LICENSE file in the project root for more information. using System; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.ExternalAccess.Razor { diff --git a/src/Tools/ExternalAccess/Razor/InternalAPI.Unshipped.txt b/src/Tools/ExternalAccess/Razor/InternalAPI.Unshipped.txt index 32ea52d163dd9..178794f55e1b2 100644 --- a/src/Tools/ExternalAccess/Razor/InternalAPI.Unshipped.txt +++ b/src/Tools/ExternalAccess/Razor/InternalAPI.Unshipped.txt @@ -56,7 +56,7 @@ Microsoft.CodeAnalysis.ExternalAccess.Razor.Cohost.RazorTextDocumentIdentifier.U Microsoft.CodeAnalysis.ExternalAccess.Razor.IRazorAsynchronousOperationListenerProviderAccessor Microsoft.CodeAnalysis.ExternalAccess.Razor.IRazorAsynchronousOperationListenerProviderAccessor.GetListener(string! featureName) -> Microsoft.CodeAnalysis.ExternalAccess.Razor.RazorAsynchronousOperationListenerWrapper Microsoft.CodeAnalysis.ExternalAccess.Razor.IRazorCapabilitiesProvider -Microsoft.CodeAnalysis.ExternalAccess.Razor.IRazorCapabilitiesProvider.GetCapabilities(Microsoft.VisualStudio.LanguageServer.Protocol.ClientCapabilities! clientCapabilities) -> Microsoft.VisualStudio.LanguageServer.Protocol.ServerCapabilities! +Microsoft.CodeAnalysis.ExternalAccess.Razor.IRazorCapabilitiesProvider.GetCapabilities(Roslyn.LanguageServer.Protocol.ClientCapabilities! clientCapabilities) -> Roslyn.LanguageServer.Protocol.ServerCapabilities! Microsoft.CodeAnalysis.ExternalAccess.Razor.IRazorCSharpInterceptionMiddleLayer Microsoft.CodeAnalysis.ExternalAccess.Razor.IRazorCSharpInterceptionMiddleLayer.CanHandle(string! methodName) -> bool Microsoft.CodeAnalysis.ExternalAccess.Razor.IRazorCSharpInterceptionMiddleLayer.HandleNotificationAsync(string! methodName, Newtonsoft.Json.Linq.JToken! methodParam, System.Func! sendNotification) -> System.Threading.Tasks.Task! @@ -474,7 +474,7 @@ static Microsoft.CodeAnalysis.ExternalAccess.Razor.RazorRemoteHostClient.TryGetC static Microsoft.CodeAnalysis.ExternalAccess.Razor.RazorRemoteServiceCallbackIdWrapper.implicit operator Microsoft.CodeAnalysis.ExternalAccess.Razor.RazorRemoteServiceCallbackIdWrapper(Microsoft.CodeAnalysis.Remote.RemoteServiceCallbackId id) -> Microsoft.CodeAnalysis.ExternalAccess.Razor.RazorRemoteServiceCallbackIdWrapper static Microsoft.CodeAnalysis.ExternalAccess.Razor.RazorSemanticTokensAccessor.GetTokenModifiers() -> string![]! static Microsoft.CodeAnalysis.ExternalAccess.Razor.RazorSemanticTokensAccessor.GetTokenTypes(bool clientSupportsVisualStudioExtensions) -> System.Collections.Immutable.ImmutableArray -static Microsoft.CodeAnalysis.ExternalAccess.Razor.RazorSemanticTokensAccessor.GetTokenTypes(Microsoft.VisualStudio.LanguageServer.Protocol.ClientCapabilities! capabilities) -> System.Collections.Immutable.ImmutableArray +static Microsoft.CodeAnalysis.ExternalAccess.Razor.RazorSemanticTokensAccessor.GetTokenTypes(Roslyn.LanguageServer.Protocol.ClientCapabilities! capabilities) -> System.Collections.Immutable.ImmutableArray static Microsoft.CodeAnalysis.ExternalAccess.Razor.RazorSemanticTokensAccessor.RoslynTokenTypes.get -> System.Collections.Immutable.ImmutableArray static Microsoft.CodeAnalysis.ExternalAccess.Razor.RazorTestAnalyzerLoader.CreateAnalyzerAssemblyLoader() -> Microsoft.CodeAnalysis.IAnalyzerAssemblyLoader! static Microsoft.CodeAnalysis.ExternalAccess.Razor.RazorUri.CreateAbsoluteUri(string! absolutePath) -> System.Uri! diff --git a/src/Tools/ExternalAccess/Razor/RazorLanguageServerFactoryWrapper.cs b/src/Tools/ExternalAccess/Razor/RazorLanguageServerFactoryWrapper.cs index 0b8878091b24e..8ca8896a66974 100644 --- a/src/Tools/ExternalAccess/Razor/RazorLanguageServerFactoryWrapper.cs +++ b/src/Tools/ExternalAccess/Razor/RazorLanguageServerFactoryWrapper.cs @@ -5,17 +5,13 @@ using System; using System.Collections.Generic; using System.Composition; -using System.Threading.Tasks; -using Microsoft.CommonLanguageServerProtocol.Framework; using Microsoft.CodeAnalysis.Host; using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.LanguageServer; -using Microsoft.CodeAnalysis.Text; -using Microsoft.VisualStudio.LanguageServer.Protocol; -using Newtonsoft.Json.Linq; -using StreamJsonRpc; using Microsoft.VisualStudio.Composition; using Newtonsoft.Json; +using Roslyn.LanguageServer.Protocol; +using StreamJsonRpc; namespace Microsoft.CodeAnalysis.ExternalAccess.Razor { diff --git a/src/Tools/ExternalAccess/Razor/RazorSemanticTokensAccessor.cs b/src/Tools/ExternalAccess/Razor/RazorSemanticTokensAccessor.cs index 500251f41e92e..db659296d92f7 100644 --- a/src/Tools/ExternalAccess/Razor/RazorSemanticTokensAccessor.cs +++ b/src/Tools/ExternalAccess/Razor/RazorSemanticTokensAccessor.cs @@ -5,7 +5,7 @@ using System; using System.Collections.Immutable; using Microsoft.CodeAnalysis.LanguageServer.Handler.SemanticTokens; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.ExternalAccess.Razor { diff --git a/src/Tools/ExternalAccess/RazorTest/Cohost/RazorCohostTests.cs b/src/Tools/ExternalAccess/RazorTest/Cohost/RazorCohostTests.cs index 9fafd66553e07..68c9bca5931b6 100644 --- a/src/Tools/ExternalAccess/RazorTest/Cohost/RazorCohostTests.cs +++ b/src/Tools/ExternalAccess/RazorTest/Cohost/RazorCohostTests.cs @@ -15,7 +15,7 @@ using Microsoft.CodeAnalysis.Test.Utilities; using Microsoft.CommonLanguageServerProtocol.Framework; using Microsoft.VisualStudio.LanguageServer.Client; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Roslyn.Test.Utilities; using StreamJsonRpc; using Xunit; @@ -134,7 +134,7 @@ public async Task TestDocumentSync() [ new TextDocumentContentChangeEvent { - Range = new VisualStudio.LanguageServer.Protocol.Range + Range = new Roslyn.LanguageServer.Protocol.Range { Start = new Position(0, 0), End = new Position(0, 0) diff --git a/src/Tools/IdeBenchmarks/Lsp/LspCompletionBenchmarks.cs b/src/Tools/IdeBenchmarks/Lsp/LspCompletionBenchmarks.cs index bdfbd15c88a9b..e35e9866681cb 100644 --- a/src/Tools/IdeBenchmarks/Lsp/LspCompletionBenchmarks.cs +++ b/src/Tools/IdeBenchmarks/Lsp/LspCompletionBenchmarks.cs @@ -10,7 +10,7 @@ using Microsoft.CodeAnalysis.Test.Utilities; using Roslyn.Test.Utilities; using Xunit; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace IdeBenchmarks.Lsp { diff --git a/src/Tools/IdeBenchmarks/Lsp/LspCompletionSerializationBenchmarks.cs b/src/Tools/IdeBenchmarks/Lsp/LspCompletionSerializationBenchmarks.cs index 6ee920469cd84..05e984071c481 100644 --- a/src/Tools/IdeBenchmarks/Lsp/LspCompletionSerializationBenchmarks.cs +++ b/src/Tools/IdeBenchmarks/Lsp/LspCompletionSerializationBenchmarks.cs @@ -4,21 +4,18 @@ using System.IO; using System.Linq; +using System.Threading; using System.Threading.Tasks; using BenchmarkDotNet.Attributes; +using Microsoft.CodeAnalysis.LanguageServer; using Microsoft.CodeAnalysis.LanguageServer.UnitTests.Completion; using Microsoft.CodeAnalysis.Options; +using Microsoft.CodeAnalysis.PooledObjects; using Microsoft.CodeAnalysis.Test.Utilities; -using Newtonsoft.Json.Converters; using Newtonsoft.Json; using Roslyn.Test.Utilities; using Xunit; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; -using static System.Windows.Forms.VisualStyles.VisualStyleElement.TextBox; -using static Roslyn.Test.Utilities.AbstractLanguageServerProtocolTests; -using System.Threading; -using Microsoft.CodeAnalysis.LanguageServer; -using Microsoft.CodeAnalysis.PooledObjects; +using LSP = Roslyn.LanguageServer.Protocol; namespace IdeBenchmarks.Lsp { diff --git a/src/VisualStudio/CSharp/Test/DocumentOutline/DocumentOutlineTests.cs b/src/VisualStudio/CSharp/Test/DocumentOutline/DocumentOutlineTests.cs index 8722e72fcefc4..187c6f2f057bf 100644 --- a/src/VisualStudio/CSharp/Test/DocumentOutline/DocumentOutlineTests.cs +++ b/src/VisualStudio/CSharp/Test/DocumentOutline/DocumentOutlineTests.cs @@ -59,7 +59,8 @@ public DocumentOutlineTests(ITestOutputHelper testOutputHelper) : base(testOutpu InitializeMocksAndDataModelAndUIItems(string testCode) { await using var mocks = await CreateMocksAsync(testCode); - var response = await DocumentOutlineViewModel.DocumentSymbolsRequestAsync(mocks.TextBuffer, mocks.LanguageServiceBroker, mocks.FilePath, CancellationToken.None); + var response = await DocumentOutlineViewModel.DocumentSymbolsRequestAsync( + mocks.TextBuffer, mocks.LanguageServiceBrokerCallback, mocks.FilePath, CancellationToken.None); AssertEx.NotNull(response.Value); var model = DocumentOutlineViewModel.CreateDocumentSymbolData(response.Value.response, response.Value.snapshot); diff --git a/src/VisualStudio/CSharp/Test/DocumentOutline/DocumentOutlineTestsBase.cs b/src/VisualStudio/CSharp/Test/DocumentOutline/DocumentOutlineTestsBase.cs index 524715e80fe22..7c28150185f8e 100644 --- a/src/VisualStudio/CSharp/Test/DocumentOutline/DocumentOutlineTestsBase.cs +++ b/src/VisualStudio/CSharp/Test/DocumentOutline/DocumentOutlineTestsBase.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -19,16 +20,15 @@ using Microsoft.CodeAnalysis.Test.Utilities; using Microsoft.CodeAnalysis.Text; using Microsoft.VisualStudio.LanguageServer.Client; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Microsoft.VisualStudio.LanguageServices.DocumentOutline; using Microsoft.VisualStudio.Text; using Microsoft.VisualStudio.Threading; using Moq; using Newtonsoft.Json.Linq; -using Roslyn.Test.Utilities; using Xunit.Abstractions; using static Roslyn.Test.Utilities.AbstractLanguageServerProtocolTests; using IAsyncDisposable = System.IAsyncDisposable; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Roslyn.VisualStudio.CSharp.UnitTests.DocumentOutline { @@ -49,19 +49,19 @@ protected class DocumentOutlineTestMocks : IAsyncDisposable private readonly IAsyncDisposable _disposable; internal DocumentOutlineTestMocks( - ILanguageServiceBroker2 languageServiceBroker, + LanguageServiceBrokerCallback languageServiceBrokerCallback, IThreadingContext threadingContext, TestWorkspace workspace, IAsyncDisposable disposable) { - LanguageServiceBroker = languageServiceBroker; + LanguageServiceBrokerCallback = languageServiceBrokerCallback; ThreadingContext = threadingContext; _workspace = workspace; _disposable = disposable; TextBuffer = workspace.Documents.Single().GetTextBuffer(); } - internal ILanguageServiceBroker2 LanguageServiceBroker { get; } + internal LanguageServiceBrokerCallback LanguageServiceBrokerCallback { get; } internal IThreadingContext ThreadingContext { get; } @@ -96,14 +96,8 @@ protected async Task CreateMocksAsync(string code) }; var testLspServer = await CreateTestLspServerAsync(workspace, new InitializationOptions { ClientCapabilities = clientCapabilities }); - var languageServiceBrokerMock = new Mock(MockBehavior.Strict); -#pragma warning disable CS0618 // Type or member is obsolete - languageServiceBrokerMock - .Setup(l => l.RequestAsync(It.IsAny(), It.IsAny>(), It.IsAny(), It.IsAny(), It.IsAny>(), It.IsAny())) - .Returns, string, string, Func, CancellationToken>(RequestAsync); -#pragma warning restore CS0618 // Type or member is obsolete - - var mocks = new DocumentOutlineTestMocks(languageServiceBrokerMock.Object, threadingContext, workspace, testLspServer); + + var mocks = new DocumentOutlineTestMocks(RequestAsync, threadingContext, workspace, testLspServer); return mocks; async Task RequestAsync(ITextBuffer textBuffer, Func capabilitiesFilter, string languageServerName, string method, Func parameterFactory, CancellationToken cancellationToken) diff --git a/src/VisualStudio/Core/Def/DocumentOutline/DocumentOutlineViewModel.DocumentOutlineViewState.cs b/src/VisualStudio/Core/Def/DocumentOutline/DocumentOutlineViewModel.DocumentOutlineViewState.cs index 0ef4067c52feb..9bcb1fec8243a 100644 --- a/src/VisualStudio/Core/Def/DocumentOutline/DocumentOutlineViewModel.DocumentOutlineViewState.cs +++ b/src/VisualStudio/Core/Def/DocumentOutline/DocumentOutlineViewModel.DocumentOutlineViewState.cs @@ -4,7 +4,6 @@ using System.Collections.Immutable; using Microsoft.CodeAnalysis.Shared.Collections; -using Microsoft.VisualStudio.LanguageServer.Protocol; using Microsoft.VisualStudio.Text; namespace Microsoft.VisualStudio.LanguageServices.DocumentOutline diff --git a/src/VisualStudio/Core/Def/DocumentOutline/DocumentOutlineViewModel.IntervalIntrospector.cs b/src/VisualStudio/Core/Def/DocumentOutline/DocumentOutlineViewModel.IntervalIntrospector.cs index 0fd9ee06eedde..fa25861453f12 100644 --- a/src/VisualStudio/Core/Def/DocumentOutline/DocumentOutlineViewModel.IntervalIntrospector.cs +++ b/src/VisualStudio/Core/Def/DocumentOutline/DocumentOutlineViewModel.IntervalIntrospector.cs @@ -3,8 +3,6 @@ // See the LICENSE file in the project root for more information. using Microsoft.CodeAnalysis.Shared.Collections; -using Microsoft.VisualStudio.LanguageServer.Protocol; -using Microsoft.VisualStudio.Text; namespace Microsoft.VisualStudio.LanguageServices.DocumentOutline { diff --git a/src/VisualStudio/Core/Def/DocumentOutline/DocumentOutlineViewModel.cs b/src/VisualStudio/Core/Def/DocumentOutline/DocumentOutlineViewModel.cs index 855995abe2337..ce9e5c9d50495 100644 --- a/src/VisualStudio/Core/Def/DocumentOutline/DocumentOutlineViewModel.cs +++ b/src/VisualStudio/Core/Def/DocumentOutline/DocumentOutlineViewModel.cs @@ -3,40 +3,31 @@ // See the LICENSE file in the project root for more information. using System; -using System.Collections.Generic; using System.Collections.Immutable; using System.ComponentModel; using System.Diagnostics; using System.Linq; -using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; using System.Windows; using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.Collections; using Microsoft.CodeAnalysis.Editor.Shared.Extensions; using Microsoft.CodeAnalysis.Editor.Shared.Tagging; using Microsoft.CodeAnalysis.Editor.Shared.Utilities; using Microsoft.CodeAnalysis.Editor.Tagging; using Microsoft.CodeAnalysis.PooledObjects; -using Microsoft.CodeAnalysis.SemanticModelReuse; using Microsoft.CodeAnalysis.Shared.Collections; using Microsoft.CodeAnalysis.Shared.TestHooks; using Microsoft.CodeAnalysis.Text; -using Microsoft.Internal.VisualStudio.Shell.Interop; using Microsoft.VisualStudio.LanguageServer.Client; -using Microsoft.VisualStudio.LanguageServer.Protocol; using Microsoft.VisualStudio.LanguageServices.Utilities; using Microsoft.VisualStudio.Text; -using Microsoft.VisualStudio.Text.Editor; using Microsoft.VisualStudio.Threading; +using Roslyn.LanguageServer.Protocol; using Roslyn.Utilities; -using VsWebSite; namespace Microsoft.VisualStudio.LanguageServices.DocumentOutline { - using LspDocumentSymbol = DocumentSymbol; - /// /// Responsible for updating data related to Document outline. It is expected that all public methods on this type /// do not need to be on the UI thread. Two properties: and are @@ -435,7 +426,7 @@ static void ApplyOldState( { // Obtain the LSP response and text snapshot used. var response = await DocumentSymbolsRequestAsync( - _textBuffer, _languageServiceBroker, filePath, cancellationToken).ConfigureAwait(false); + _textBuffer, _languageServiceBroker.RequestAsync, filePath, cancellationToken).ConfigureAwait(false); if (response != null) { var newTextSnapshot = response.Value.snapshot; diff --git a/src/VisualStudio/Core/Def/DocumentOutline/DocumentOutlineViewModel_Utilities.cs b/src/VisualStudio/Core/Def/DocumentOutline/DocumentOutlineViewModel_Utilities.cs index 4547719dea25f..420daca0dea7d 100644 --- a/src/VisualStudio/Core/Def/DocumentOutline/DocumentOutlineViewModel_Utilities.cs +++ b/src/VisualStudio/Core/Def/DocumentOutline/DocumentOutlineViewModel_Utilities.cs @@ -13,15 +13,18 @@ using Microsoft.CodeAnalysis.PatternMatching; using Microsoft.CodeAnalysis.PooledObjects; using Microsoft.VisualStudio.LanguageServer.Client; -using Microsoft.VisualStudio.LanguageServer.Protocol; using Microsoft.VisualStudio.Text; using Newtonsoft.Json.Linq; +using Roslyn.LanguageServer.Protocol; using Roslyn.Utilities; namespace Microsoft.VisualStudio.LanguageServices.DocumentOutline { using LspDocumentSymbol = DocumentSymbol; - using Range = LanguageServer.Protocol.Range; + using Range = Roslyn.LanguageServer.Protocol.Range; + + internal delegate Task LanguageServiceBrokerCallback( + ITextBuffer textBuffer, Func capabilitiesFilter, string languageServerName, string method, Func parameterFactory, CancellationToken cancellationToken); internal sealed partial class DocumentOutlineViewModel { @@ -31,7 +34,7 @@ internal sealed partial class DocumentOutlineViewModel /// public static async Task<(JToken response, ITextSnapshot snapshot)?> DocumentSymbolsRequestAsync( ITextBuffer textBuffer, - ILanguageServiceBroker2 languageServiceBroker, + LanguageServiceBrokerCallback callbackAsync, string textViewFilePath, CancellationToken cancellationToken) { @@ -49,7 +52,7 @@ JToken ParameterFunction(ITextSnapshot snapshot) }); } - var manualResponse = await languageServiceBroker.RequestAsync( + var manualResponse = await callbackAsync( textBuffer: textBuffer, method: Methods.TextDocumentDocumentSymbolName, capabilitiesFilter: _ => true, diff --git a/src/VisualStudio/Core/Def/DocumentOutline/DocumentSymbolData.cs b/src/VisualStudio/Core/Def/DocumentOutline/DocumentSymbolData.cs index d70e987de98a8..33eaeb495a510 100644 --- a/src/VisualStudio/Core/Def/DocumentOutline/DocumentSymbolData.cs +++ b/src/VisualStudio/Core/Def/DocumentOutline/DocumentSymbolData.cs @@ -8,7 +8,7 @@ namespace Microsoft.VisualStudio.LanguageServices.DocumentOutline { - using SymbolKind = LanguageServer.Protocol.SymbolKind; + using SymbolKind = Roslyn.LanguageServer.Protocol.SymbolKind; /// /// Represents the immutable symbol returned from the LSP request to get document symbols, but mapped into diff --git a/src/VisualStudio/Core/Def/DocumentOutline/DocumentSymbolDataViewModel.cs b/src/VisualStudio/Core/Def/DocumentOutline/DocumentSymbolDataViewModel.cs index ae6096a7da7b6..8da555fe33ecc 100644 --- a/src/VisualStudio/Core/Def/DocumentOutline/DocumentSymbolDataViewModel.cs +++ b/src/VisualStudio/Core/Def/DocumentOutline/DocumentSymbolDataViewModel.cs @@ -12,8 +12,6 @@ namespace Microsoft.VisualStudio.LanguageServices.DocumentOutline { - using SymbolKind = LanguageServer.Protocol.SymbolKind; - /// /// A ViewModel over . The only items that are mutable on this type are and . It is expected that these can be modified from any thread with diff --git a/src/VisualStudio/Core/Def/DocumentOutline/SortOption.cs b/src/VisualStudio/Core/Def/DocumentOutline/SortOption.cs index 44d549dce4c12..81bd336e4af2e 100644 --- a/src/VisualStudio/Core/Def/DocumentOutline/SortOption.cs +++ b/src/VisualStudio/Core/Def/DocumentOutline/SortOption.cs @@ -18,7 +18,7 @@ internal enum SortOption /// Location, /// - /// Sort by document symbol . + /// Sort by document symbol . /// /// /// At the moment, we order the symbols by the SymbolKind enum values. If this ordering turns out to be diff --git a/src/VisualStudio/Core/Def/Microsoft.VisualStudio.LanguageServices.csproj b/src/VisualStudio/Core/Def/Microsoft.VisualStudio.LanguageServices.csproj index be2c9006ce7fb..816639fe576e3 100644 --- a/src/VisualStudio/Core/Def/Microsoft.VisualStudio.LanguageServices.csproj +++ b/src/VisualStudio/Core/Def/Microsoft.VisualStudio.LanguageServices.csproj @@ -147,6 +147,7 @@ + diff --git a/src/VisualStudio/LiveShare/Impl/Client/RemoteLanguageServiceWorkspace.cs b/src/VisualStudio/LiveShare/Impl/Client/RemoteLanguageServiceWorkspace.cs index 1ab90b7d80964..9b2f4d5f7067a 100644 --- a/src/VisualStudio/LiveShare/Impl/Client/RemoteLanguageServiceWorkspace.cs +++ b/src/VisualStudio/LiveShare/Impl/Client/RemoteLanguageServiceWorkspace.cs @@ -13,7 +13,6 @@ using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.Editor.Shared.Utilities; using Microsoft.CodeAnalysis.ErrorReporting; -using Microsoft.CodeAnalysis.Host; using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.LanguageServer; using Microsoft.CodeAnalysis.Options; @@ -21,7 +20,6 @@ using Microsoft.CodeAnalysis.SolutionCrawler; using Microsoft.CodeAnalysis.Text; using Microsoft.VisualStudio.Composition; -using Microsoft.VisualStudio.Editor; using Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem; using Microsoft.VisualStudio.LanguageServices.LiveShare.Client.Projects; using Microsoft.VisualStudio.LiveShare; @@ -31,7 +29,7 @@ using Microsoft.VisualStudio.Text; using Microsoft.VisualStudio.Workspace.VSIntegration.Contracts; using Roslyn.Utilities; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; using Task = System.Threading.Tasks.Task; namespace Microsoft.VisualStudio.LanguageServices.LiveShare.Client diff --git a/src/VisualStudio/LiveShare/Impl/Client/RoslynLSPClientService.cs b/src/VisualStudio/LiveShare/Impl/Client/RoslynLSPClientService.cs index 88f8a4639269b..f2109adc0a3fd 100644 --- a/src/VisualStudio/LiveShare/Impl/Client/RoslynLSPClientService.cs +++ b/src/VisualStudio/LiveShare/Impl/Client/RoslynLSPClientService.cs @@ -9,12 +9,12 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.VisualStudio.LiveShare; using Newtonsoft.Json.Linq; -using Task = System.Threading.Tasks.Task; +using Roslyn.LanguageServer.Protocol; using LS = Microsoft.VisualStudio.LiveShare.LanguageServices; -using Microsoft.CodeAnalysis.Host.Mef; +using Task = System.Threading.Tasks.Task; namespace Microsoft.VisualStudio.LanguageServices.LiveShare.Client { diff --git a/src/VisualStudio/LiveShare/Impl/CustomProtocol/LspRequestExtensions.cs b/src/VisualStudio/LiveShare/Impl/CustomProtocol/LspRequestExtensions.cs index 306e6f3702157..e0296850b05e0 100644 --- a/src/VisualStudio/LiveShare/Impl/CustomProtocol/LspRequestExtensions.cs +++ b/src/VisualStudio/LiveShare/Impl/CustomProtocol/LspRequestExtensions.cs @@ -4,19 +4,17 @@ #nullable disable -using Microsoft.VisualStudio.LanguageServices.Implementation.LanguageService; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; using LS = Microsoft.VisualStudio.LiveShare.LanguageServices; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.VisualStudio.LanguageServices.LiveShare.Protocol { public static class LspRequestExtensions { - public static LS.LspRequest ToLSRequest(this LSP.LspRequest lspRequest) + internal static LS.LspRequest ToLSRequest(this LSP.LspRequest lspRequest) => new LS.LspRequest(lspRequest.Name); - public static LSP.ClientCapabilities GetClientCapabilities(this LS.RequestContext requestContext) + internal static LSP.ClientCapabilities GetClientCapabilities(this LS.RequestContext requestContext) => requestContext.ClientCapabilities?.ToObject() ?? new LSP.VSInternalClientCapabilities(); - } } diff --git a/src/VisualStudio/LiveShare/Impl/LSPSDKInitializeHandler.cs b/src/VisualStudio/LiveShare/Impl/LSPSDKInitializeHandler.cs index ce82fe8783b86..8ac57e2f4ed32 100644 --- a/src/VisualStudio/LiveShare/Impl/LSPSDKInitializeHandler.cs +++ b/src/VisualStudio/LiveShare/Impl/LSPSDKInitializeHandler.cs @@ -11,7 +11,7 @@ using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.VisualStudio.LiveShare.LanguageServices; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.VisualStudio.LanguageServices.LiveShare { diff --git a/src/VisualStudio/LiveShare/Impl/LiveShareInitializeHandler.cs b/src/VisualStudio/LiveShare/Impl/LiveShareInitializeHandler.cs index 432250a54f7d3..e92ede2990de7 100644 --- a/src/VisualStudio/LiveShare/Impl/LiveShareInitializeHandler.cs +++ b/src/VisualStudio/LiveShare/Impl/LiveShareInitializeHandler.cs @@ -8,9 +8,8 @@ using System.Threading.Tasks; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Host.Mef; -using Microsoft.VisualStudio.LanguageServer.Protocol; -using Microsoft.VisualStudio.LanguageServices.LiveShare.CustomProtocol; using Microsoft.VisualStudio.LiveShare.LanguageServices; +using Roslyn.LanguageServer.Protocol; namespace Microsoft.VisualStudio.LanguageServices.LiveShare.Shims { diff --git a/src/VisualStudio/LiveShare/Impl/Microsoft.VisualStudio.LanguageServices.LiveShare.csproj b/src/VisualStudio/LiveShare/Impl/Microsoft.VisualStudio.LanguageServices.LiveShare.csproj index 5c3d69616a343..72734c5360afb 100644 --- a/src/VisualStudio/LiveShare/Impl/Microsoft.VisualStudio.LanguageServices.LiveShare.csproj +++ b/src/VisualStudio/LiveShare/Impl/Microsoft.VisualStudio.LanguageServices.LiveShare.csproj @@ -28,7 +28,6 @@ - diff --git a/src/VisualStudio/LiveShare/Test/AbstractLiveShareRequestHandlerTests.cs b/src/VisualStudio/LiveShare/Test/AbstractLiveShareRequestHandlerTests.cs index eff2a8e380986..34b4d48c45763 100644 --- a/src/VisualStudio/LiveShare/Test/AbstractLiveShareRequestHandlerTests.cs +++ b/src/VisualStudio/LiveShare/Test/AbstractLiveShareRequestHandlerTests.cs @@ -11,9 +11,9 @@ using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces; using Microsoft.CodeAnalysis.Test.Utilities; -using Microsoft.VisualStudio.LanguageServer.Protocol; using Microsoft.VisualStudio.LiveShare.LanguageServices; using Newtonsoft.Json.Linq; +using Roslyn.LanguageServer.Protocol; using Roslyn.Test.Utilities; using Xunit.Abstractions; diff --git a/src/VisualStudio/Setup.Dependencies/Roslyn.VisualStudio.Setup.Dependencies.csproj b/src/VisualStudio/Setup.Dependencies/Roslyn.VisualStudio.Setup.Dependencies.csproj index 45475844c1cc8..3d4b1dd0d9019 100644 --- a/src/VisualStudio/Setup.Dependencies/Roslyn.VisualStudio.Setup.Dependencies.csproj +++ b/src/VisualStudio/Setup.Dependencies/Roslyn.VisualStudio.Setup.Dependencies.csproj @@ -87,9 +87,5 @@ - - - - \ No newline at end of file diff --git a/src/VisualStudio/Xaml/Impl/Implementation/LanguageClient/XamlCapabilities.cs b/src/VisualStudio/Xaml/Impl/Implementation/LanguageClient/XamlCapabilities.cs index 7aa30e5161830..bfec6905e8a67 100644 --- a/src/VisualStudio/Xaml/Impl/Implementation/LanguageClient/XamlCapabilities.cs +++ b/src/VisualStudio/Xaml/Impl/Implementation/LanguageClient/XamlCapabilities.cs @@ -4,7 +4,7 @@ using System.Linq; using Microsoft.CodeAnalysis.Editor.Xaml; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Microsoft.VisualStudio.LanguageServices.Xaml.LanguageServer.Handler; using RoslynCompletion = Microsoft.CodeAnalysis.Completion; diff --git a/src/VisualStudio/Xaml/Impl/Implementation/LanguageClient/XamlInProcLanguageClient.cs b/src/VisualStudio/Xaml/Impl/Implementation/LanguageClient/XamlInProcLanguageClient.cs index 26dd5bfee62da..a0bb55e42ff8f 100644 --- a/src/VisualStudio/Xaml/Impl/Implementation/LanguageClient/XamlInProcLanguageClient.cs +++ b/src/VisualStudio/Xaml/Impl/Implementation/LanguageClient/XamlInProcLanguageClient.cs @@ -19,7 +19,7 @@ using Microsoft.CommonLanguageServerProtocol.Framework; using Microsoft.VisualStudio.Composition; using Microsoft.VisualStudio.LanguageServer.Client; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Microsoft.VisualStudio.LanguageServices.Xaml.Implementation.LanguageServer; using Microsoft.VisualStudio.LanguageServices.Xaml.LanguageServer; using Microsoft.VisualStudio.LanguageServices.Xaml.Telemetry; diff --git a/src/VisualStudio/Xaml/Impl/Implementation/LanguageClient/XamlInProcLanguageClientDisableUX.cs b/src/VisualStudio/Xaml/Impl/Implementation/LanguageClient/XamlInProcLanguageClientDisableUX.cs index f67fa5f4d3396..2f81db24dc6fb 100644 --- a/src/VisualStudio/Xaml/Impl/Implementation/LanguageClient/XamlInProcLanguageClientDisableUX.cs +++ b/src/VisualStudio/Xaml/Impl/Implementation/LanguageClient/XamlInProcLanguageClientDisableUX.cs @@ -16,7 +16,7 @@ using Microsoft.CodeAnalysis.Shared.TestHooks; using Microsoft.VisualStudio.Composition; using Microsoft.VisualStudio.LanguageServer.Client; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Microsoft.VisualStudio.LanguageServices.Implementation.LanguageClient; using Microsoft.VisualStudio.LanguageServices.Xaml.LanguageServer; using Microsoft.VisualStudio.Utilities; diff --git a/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/CodeActions/CodeActionsHandlerProvider.cs b/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/CodeActions/CodeActionsHandlerProvider.cs index 4e03d0572ce69..7756d90e32088 100644 --- a/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/CodeActions/CodeActionsHandlerProvider.cs +++ b/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/CodeActions/CodeActionsHandlerProvider.cs @@ -7,8 +7,8 @@ using Microsoft.CodeAnalysis.CodeFixes; using Microsoft.CodeAnalysis.CodeRefactorings; using Microsoft.CodeAnalysis.Host.Mef; -using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.LanguageServer.Handler; +using Microsoft.CodeAnalysis.Options; namespace Microsoft.VisualStudio.LanguageServices.Xaml.LanguageServer.Handler { diff --git a/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/Commands/CreateEventCommandHandler.cs b/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/Commands/CreateEventCommandHandler.cs index 5115878bf4107..570bcc06d78bb 100644 --- a/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/Commands/CreateEventCommandHandler.cs +++ b/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/Commands/CreateEventCommandHandler.cs @@ -11,7 +11,7 @@ using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.LanguageServer.Handler; using Microsoft.CodeAnalysis.LanguageServer.Handler.Commands; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Microsoft.VisualStudio.LanguageServices.Xaml.Features.Commands; using Microsoft.VisualStudio.LanguageServices.Xaml.Features.Completion; using Microsoft.VisualStudio.LanguageServices.Xaml.LanguageServer; diff --git a/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/Completion/CompletionHandler.cs b/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/Completion/CompletionHandler.cs index 531433cc73ab1..bd452e515bae3 100644 --- a/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/Completion/CompletionHandler.cs +++ b/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/Completion/CompletionHandler.cs @@ -16,8 +16,9 @@ using Microsoft.CodeAnalysis.LanguageServer; using Microsoft.CodeAnalysis.LanguageServer.Handler; using Microsoft.CodeAnalysis.Text; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Microsoft.VisualStudio.LanguageServices.Xaml.Features.Completion; +using Microsoft.CodeAnalysis.Extensions; namespace Microsoft.VisualStudio.LanguageServices.Xaml.LanguageServer.Handler { @@ -90,8 +91,8 @@ private static CompletionItem CreateCompletionItem(XamlCompletionItem xamlComple SortText = xamlCompletion.SortText, FilterText = xamlCompletion.FilterText, Kind = GetItemKind(xamlCompletion.Kind), - Description = xamlCompletion.Description, - Icon = xamlCompletion.Icon, + Description = xamlCompletion.Description.ToLSPElement(), + Icon = xamlCompletion.Icon.ToLSPImageElement(), InsertTextFormat = xamlCompletion.IsSnippet ? InsertTextFormat.Snippet : InsertTextFormat.Plaintext, Data = new CompletionResolveData { ProjectGuid = documentId.ProjectId.Id, DocumentGuid = documentId.Id, Position = position, DisplayText = xamlCompletion.DisplayText } }; diff --git a/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/Completion/CompletionResolveData.cs b/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/Completion/CompletionResolveData.cs index 28a67913f142f..663b1c9562dff 100644 --- a/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/Completion/CompletionResolveData.cs +++ b/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/Completion/CompletionResolveData.cs @@ -5,7 +5,7 @@ #nullable disable using System; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; namespace Microsoft.VisualStudio.LanguageServices.Xaml.LanguageServer.Handler { diff --git a/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/Completion/CompletionResolveHandler.cs b/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/Completion/CompletionResolveHandler.cs index 15b83489ef506..3b1b10ba43021 100644 --- a/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/Completion/CompletionResolveHandler.cs +++ b/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/Completion/CompletionResolveHandler.cs @@ -8,19 +8,18 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.Editor.Xaml; using Microsoft.CodeAnalysis.Host.Mef; -using Microsoft.CodeAnalysis.Options; -using Microsoft.CodeAnalysis.LanguageService; using Microsoft.CodeAnalysis.LanguageServer; using Microsoft.CodeAnalysis.LanguageServer.Handler; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Microsoft.CodeAnalysis.LanguageService; +using Microsoft.CodeAnalysis.Options; using Microsoft.VisualStudio.LanguageServices.Xaml.Features.Completion; using Microsoft.VisualStudio.LanguageServices.Xaml.Implementation.LanguageServer.Extensions; -using Microsoft.VisualStudio.Text.Adornments; using Newtonsoft.Json.Linq; +using Roslyn.LanguageServer.Protocol; +using Roslyn.Text.Adornments; using Roslyn.Utilities; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.VisualStudio.LanguageServices.Xaml.LanguageServer.Handler { diff --git a/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/Definitions/GoToDefinitionHandler.cs b/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/Definitions/GoToDefinitionHandler.cs index bcedca6838a98..e7c14eb07a3eb 100644 --- a/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/Definitions/GoToDefinitionHandler.cs +++ b/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/Definitions/GoToDefinitionHandler.cs @@ -19,11 +19,11 @@ using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.PooledObjects; using Microsoft.CodeAnalysis.Text; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Microsoft.VisualStudio.LanguageServices.Xaml.Features.Definitions; using Microsoft.VisualStudio.LanguageServices.Xaml.LanguageServer; using Roslyn.Utilities; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.VisualStudio.LanguageServices.Xaml.Implementation.LanguageServer.Handler.Definitions { diff --git a/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/Diagnostics/AbstractPullDiagnosticHandler.cs b/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/Diagnostics/AbstractPullDiagnosticHandler.cs index 24bd20a0375a4..41c1810ca2b94 100644 --- a/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/Diagnostics/AbstractPullDiagnosticHandler.cs +++ b/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/Diagnostics/AbstractPullDiagnosticHandler.cs @@ -15,10 +15,10 @@ using Microsoft.CodeAnalysis.PooledObjects; using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.Text; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Microsoft.VisualStudio.LanguageServices.Xaml.Features.Diagnostics; using Roslyn.Utilities; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.VisualStudio.LanguageServices.Xaml.Implementation.LanguageServer.Handler.Diagnostics { diff --git a/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/Diagnostics/DocumentPullDiagnosticHandler.cs b/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/Diagnostics/DocumentPullDiagnosticHandler.cs index ff110d15f05e4..28d0218dcbe07 100644 --- a/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/Diagnostics/DocumentPullDiagnosticHandler.cs +++ b/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/Diagnostics/DocumentPullDiagnosticHandler.cs @@ -10,7 +10,7 @@ using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.LanguageServer.Handler; using Microsoft.CommonLanguageServerProtocol.Framework; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Microsoft.VisualStudio.LanguageServices.Xaml.Features.Diagnostics; using Microsoft.VisualStudio.LanguageServices.Xaml.LanguageServer; diff --git a/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/Diagnostics/WorkspacePullDiagnosticHandler.cs b/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/Diagnostics/WorkspacePullDiagnosticHandler.cs index 65da76a99fc8c..96ebf40f389ba 100644 --- a/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/Diagnostics/WorkspacePullDiagnosticHandler.cs +++ b/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/Diagnostics/WorkspacePullDiagnosticHandler.cs @@ -11,7 +11,7 @@ using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.LanguageServer.Handler; using Microsoft.CodeAnalysis.PooledObjects; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Microsoft.VisualStudio.LanguageServices.Xaml.Features.Diagnostics; using Microsoft.VisualStudio.LanguageServices.Xaml.Implementation.LanguageServer.Extensions; using Microsoft.VisualStudio.LanguageServices.Xaml.LanguageServer; diff --git a/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/FoldingRanges/FoldingRangesHandler.cs b/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/FoldingRanges/FoldingRangesHandler.cs index b5ade7d53dea6..559f295df4012 100644 --- a/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/FoldingRanges/FoldingRangesHandler.cs +++ b/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/FoldingRanges/FoldingRangesHandler.cs @@ -11,7 +11,7 @@ using Microsoft.CodeAnalysis.LanguageServer; using Microsoft.CodeAnalysis.LanguageServer.Handler; using Microsoft.CodeAnalysis.PooledObjects; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Microsoft.VisualStudio.LanguageServices.Xaml.Features.Structure; namespace Microsoft.VisualStudio.LanguageServices.Xaml.LanguageServer.Handler diff --git a/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/Formatting/AbstractFormatDocumentHandlerBase.cs b/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/Formatting/AbstractFormatDocumentHandlerBase.cs index 45325683e2798..a48c4037b998a 100644 --- a/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/Formatting/AbstractFormatDocumentHandlerBase.cs +++ b/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/Formatting/AbstractFormatDocumentHandlerBase.cs @@ -10,9 +10,9 @@ using Microsoft.CodeAnalysis.LanguageServer.Handler; using Microsoft.CodeAnalysis.PooledObjects; using Microsoft.CodeAnalysis.Text; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Microsoft.VisualStudio.LanguageServices.Xaml.Features.Formatting; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.VisualStudio.LanguageServices.Xaml.LanguageServer.Handler { diff --git a/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/Formatting/FormatDocumentHandler.cs b/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/Formatting/FormatDocumentHandler.cs index 4e7738babafad..95b779c218cd4 100644 --- a/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/Formatting/FormatDocumentHandler.cs +++ b/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/Formatting/FormatDocumentHandler.cs @@ -9,7 +9,7 @@ using Microsoft.CodeAnalysis.Editor.Xaml; using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.LanguageServer.Handler; -using LSP = Microsoft.VisualStudio.LanguageServer.Protocol; +using LSP = Roslyn.LanguageServer.Protocol; namespace Microsoft.VisualStudio.LanguageServices.Xaml.LanguageServer.Handler { diff --git a/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/Formatting/FormatDocumentOnTypeHandler.cs b/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/Formatting/FormatDocumentOnTypeHandler.cs index 27072826f883c..feb2ef0feb285 100644 --- a/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/Formatting/FormatDocumentOnTypeHandler.cs +++ b/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/Formatting/FormatDocumentOnTypeHandler.cs @@ -14,7 +14,7 @@ using Microsoft.CodeAnalysis.LanguageServer.Handler; using Microsoft.CodeAnalysis.PooledObjects; using Microsoft.CodeAnalysis.Text; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Microsoft.VisualStudio.LanguageServices.Xaml.Features.Formatting; namespace Microsoft.VisualStudio.LanguageServices.Xaml.LanguageServer.Handler diff --git a/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/Formatting/FormatDocumentRangeHandler.cs b/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/Formatting/FormatDocumentRangeHandler.cs index 758db2c77e47c..1b857b2c11e3f 100644 --- a/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/Formatting/FormatDocumentRangeHandler.cs +++ b/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/Formatting/FormatDocumentRangeHandler.cs @@ -9,7 +9,7 @@ using Microsoft.CodeAnalysis.Editor.Xaml; using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.LanguageServer.Handler; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; namespace Microsoft.VisualStudio.LanguageServices.Xaml.LanguageServer.Handler { diff --git a/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/Hover/HoverHandler.cs b/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/Hover/HoverHandler.cs index 12d1e3a3d34a7..c598896a9291a 100644 --- a/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/Hover/HoverHandler.cs +++ b/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/Hover/HoverHandler.cs @@ -16,7 +16,7 @@ using Microsoft.CodeAnalysis.LanguageServer.Handler; using Microsoft.CodeAnalysis.Options; using Microsoft.CodeAnalysis.Shared.Extensions; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Microsoft.VisualStudio.LanguageServices.Xaml.Features.QuickInfo; using Microsoft.VisualStudio.LanguageServices.Xaml.Implementation.LanguageServer.Extensions; using Microsoft.VisualStudio.Text.Adornments; diff --git a/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/OnAutoInsert/OnAutoInsertHandler.cs b/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/OnAutoInsert/OnAutoInsertHandler.cs index 44692ed0a3a85..f24b2a2d81c33 100644 --- a/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/OnAutoInsert/OnAutoInsertHandler.cs +++ b/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/OnAutoInsert/OnAutoInsertHandler.cs @@ -10,7 +10,7 @@ using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.LanguageServer; using Microsoft.CodeAnalysis.LanguageServer.Handler; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Microsoft.VisualStudio.LanguageServices.Xaml.Features.AutoInsert; using Roslyn.Utilities; diff --git a/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/OnTypeRename/OnTypeRenameHandler.cs b/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/OnTypeRename/OnTypeRenameHandler.cs index e794398acf0b7..9678f9a2a12ed 100644 --- a/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/OnTypeRename/OnTypeRenameHandler.cs +++ b/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/Handler/OnTypeRename/OnTypeRenameHandler.cs @@ -11,7 +11,7 @@ using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.LanguageServer; using Microsoft.CodeAnalysis.LanguageServer.Handler; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Microsoft.VisualStudio.LanguageServices.Xaml.Features.TypeRename; using Roslyn.Utilities; diff --git a/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/XamlRequestExecutionQueue.cs b/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/XamlRequestExecutionQueue.cs index e040d8f6aca8c..7aed553e37112 100644 --- a/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/XamlRequestExecutionQueue.cs +++ b/src/VisualStudio/Xaml/Impl/Implementation/LanguageServer/XamlRequestExecutionQueue.cs @@ -14,7 +14,7 @@ using Microsoft.CodeAnalysis.LanguageServer; using Microsoft.CodeAnalysis.LanguageServer.Handler; using Microsoft.CommonLanguageServerProtocol.Framework; -using Microsoft.VisualStudio.LanguageServer.Protocol; +using Roslyn.LanguageServer.Protocol; using Microsoft.VisualStudio.LanguageServices.Xaml.Telemetry; namespace Microsoft.VisualStudio.LanguageServices.Xaml.LanguageServer