Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update LSP Protocol Types #73911

Merged
merged 50 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
15025cf
LSP Protocol: Implement WorkDoneProgress types
mhutch Jun 6, 2024
b3c3459
LSP Protocol: Use spec ordering in capabilities types
mhutch Jun 9, 2024
d1fdfed
LSP Protocol: Add window/general client capabilities
mhutch Jun 5, 2024
4a62b71
LSP Protocol: Update lifecycle messages
mhutch Jun 5, 2024
6bf6885
LSP Protocol: Update document sync messages
mhutch Jun 5, 2024
eccb029
LSP Protocol: Add notebook types/methods
mhutch Jun 6, 2024
ceafc11
LSP Protocol: Update navigation methods/types
mhutch Jun 6, 2024
6dceb2e
LSP Protocol: Update documentLink & documentHighlight
mhutch Jun 6, 2024
71dfa3c
LSP Protocol: Update Hover & CodeLens
mhutch Jun 8, 2024
1e09482
LSP Protocol: Update FoldingRange, add SelectionRange
mhutch Jun 8, 2024
11cf351
LSP Protocol: Update DocumentSymbol classes
mhutch Jun 8, 2024
a320492
LSP Protocol: Update semantic token types
mhutch Jun 8, 2024
5c451b5
LSP Protocol: Update Inlay Hint types
mhutch Jun 8, 2024
71d1108
LSP Protocol: Add Inline Value types/methods
mhutch Jun 8, 2024
f13f458
LSP Protocol: Add Moniker types
mhutch Jun 8, 2024
a466e02
LSP Protocol: Update completion types
mhutch Jun 5, 2024
ccd8d17
LSP Protocol: Update Diagnostic types/methods
mhutch Jun 9, 2024
e611615
LSP Protocol: Update Signature Help types
mhutch Jun 9, 2024
d489f14
LSP Protocol: Update CodeAction types
mhutch Jun 5, 2024
6393717
LSP Protocol: Update DocumentColor types/methods
mhutch Jun 9, 2024
7b7b3f8
LSP Protocol: Update formatting types/methods
mhutch Jun 9, 2024
8a46f2c
LSP Protocol: Update rename types/methods
mhutch Jun 9, 2024
c5a1e56
LSP Protocol: Update TextDocumentEdit/WorkspaceEdit
mhutch Jun 9, 2024
edd5648
LSP Protocol: Update Linked Editing Range types
mhutch Jun 9, 2024
b9b589b
LSP Protocol: Update workspace symbol types
mhutch Jun 9, 2024
f92eea2
LSP Protocol: Update Configuration types
mhutch Jun 9, 2024
415a2c9
LSP Protocol: Add/update file operations types
mhutch Jun 9, 2024
79fcd94
LSP Protocol: Update Workspace Execute/Apply methods
mhutch Jun 9, 2024
fbd8053
LSP Protocol: Update window messages/types
mhutch Jun 9, 2024
c3792dd
LSP Protocol: Update several interface types
mhutch Jun 9, 2024
4514769
LSP Protocol: Add note re. JSON attributes
mhutch Jun 17, 2024
7dd8c0f
LSP Protocol: Suppress obsoletion propagation
mhutch Jun 17, 2024
f349a25
LanguageServer: Suppress SymbolInformation obsoletion warnings
mhutch Jun 17, 2024
c74acb2
LSP Protocol: Fix issues discovered during usage
mhutch Jul 30, 2024
3a063e0
Merge remote-tracking branch 'origin/main' into lsp-protocol-types
mhutch Jul 30, 2024
9f04166
LSP Protocol: Track protocol changes in language server
mhutch Jul 31, 2024
2c5e86d
LSP Protocol: Track changes in Tests/LSIF/XAML
mhutch Aug 14, 2024
b0eb55d
LSP Protocol: Better obsoletion handling
mhutch Aug 14, 2024
ef123cc
Update VS Code config
mhutch Aug 14, 2024
016423d
Merge remote-tracking branch 'origin/main' into lsp-protocol-types
mhutch Aug 14, 2024
8132966
Fix formatting warnings that only appear on CI
mhutch Aug 14, 2024
e68ff75
Fix a couple more issues from CI
mhutch Aug 14, 2024
f165938
LSP Protocol: fix FormattingOptions.OtherOptions serialization
mhutch Aug 15, 2024
3adb76d
LSP Protocol: Fix some serialization errors
mhutch Aug 15, 2024
9829e8a
Merge remote-tracking branch 'origin' into lsp-protocol-types
mhutch Aug 16, 2024
1b59c82
LSP Protocol: fix more CI failures
mhutch Aug 16, 2024
1f80181
LSP Protocol: Fix another couple serialization errors
mhutch Aug 17, 2024
2e3dc5f
Merge remote-tracking branch 'origin' into lsp-protocol-types
mhutch Aug 19, 2024
e89c402
LSP Protocol: Support Uri in SumType
mhutch Aug 19, 2024
3320e83
LSP Protocol: Fix another CI failure
mhutch Aug 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
9 changes: 8 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,12 @@
"dotnet.defaultSolution": "Roslyn.sln",
"dotnet.completion.showCompletionItemsFromUnimportedNamespaces": true,
"dotnet.testWindow.disableAutoDiscovery": true,
"dotnet.testWindow.disableBuildOnRefresh": true
"dotnet.testWindow.disableBuildOnRefresh": true,
"cSpell.words": [
"Nerdbank",
"NETCOREAPP",
"Unregistration",
"Unregistrations",
"Xunit"
]
}
2 changes: 1 addition & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
"build",
"-c",
"Debug",
"src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/Microsoft.CodeAnalysis.LanguageServer.csproj"
"src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/Microsoft.CodeAnalysis.LanguageServer.csproj"
],
"problemMatcher": "$msCompile",
"group": "build"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ public override ServerCapabilities GetCapabilities(ClientCapabilities clientCapa

serverCapabilities.SupportsDiagnosticRequests = true;

serverCapabilities.DiagnosticOptions ??= new();
serverCapabilities.DiagnosticOptions.WorkspaceDiagnostics = true;
var diagnosticOptions = (serverCapabilities.DiagnosticOptions ??= new DiagnosticOptions());
diagnosticOptions.Unify().WorkspaceDiagnostics = true;

serverCapabilities.DiagnosticProvider ??= new();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public EditorLspSymbolInformationCreationService()
public SymbolInformation Create(string name, string? containerName, LSP.SymbolKind kind, LSP.Location location, Glyph glyph)
{
var imageId = glyph.GetImageId();
#pragma warning disable CS0618 // SymbolInformation is obsolete, need to switch to DocumentSymbol/WorkspaceSymbol
return new VSSymbolInformation
{
Name = name,
Expand All @@ -32,5 +33,6 @@ public SymbolInformation Create(string name, string? containerName, LSP.SymbolKi
Location = location,
Icon = new VSImageId { Guid = imageId.Guid, Id = imageId.Id },
};
#pragma warning restore CS0618
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ internal static LSP.SymbolInformation CreateSymbolInformation(LSP.SymbolKind kin
{
var imageId = glyph.GetImageId();

#pragma warning disable CS0618 // SymbolInformation is obsolete, need to switch to DocumentSymbol/WorkspaceSymbol
var info = new LSP.VSSymbolInformation()
{
Kind = kind,
Expand All @@ -191,6 +192,7 @@ internal static LSP.SymbolInformation CreateSymbolInformation(LSP.SymbolKind kin

if (containerName != null)
info.ContainerName = containerName;
#pragma warning restore CS0618

return info;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

using Microsoft.CodeAnalysis.LanguageServerIndexFormat.Generator.Graph;
using Roslyn.LanguageServer.Protocol;
using Moniker = Microsoft.CodeAnalysis.LanguageServerIndexFormat.Generator.Graph.Moniker;

namespace Microsoft.CodeAnalysis.LanguageServerIndexFormat.Generator.ResultSetTracking
{
Expand Down
6 changes: 3 additions & 3 deletions src/Features/Lsif/GeneratorTest/HoverTests.vb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class C
Dim rangeVertex = Await lsif.GetSelectedRangeAsync()
Dim resultSetVertex = lsif.GetLinkedVertices(Of Graph.ResultSet)(rangeVertex, "next").Single()
Dim hoverVertex = lsif.GetLinkedVertices(Of Graph.HoverResult)(resultSetVertex, Methods.TextDocumentHoverName).SingleOrDefault()
Dim hoverMarkupContent = DirectCast(hoverVertex.Result.Contents.Value.Fourth, MarkupContent)
Dim hoverMarkupContent = DirectCast(hoverVertex.Result.Contents.Fourth, MarkupContent)

Dim expectedHoverContents As String
Select Case code
Expand Down Expand Up @@ -110,7 +110,7 @@ class C
Dim rangeVertex = Await lsif.GetSelectedRangeAsync()
Dim resultSetVertex = lsif.GetLinkedVertices(Of Graph.ResultSet)(rangeVertex, "next").Single()
Dim hoverVertex = lsif.GetLinkedVertices(Of Graph.HoverResult)(resultSetVertex, Methods.TextDocumentHoverName).SingleOrDefault()
Dim hoverMarkupContent = DirectCast(hoverVertex.Result.Contents.Value.Fourth, MarkupContent)
Dim hoverMarkupContent = DirectCast(hoverVertex.Result.Contents.Fourth, MarkupContent)

Dim expectedHoverContents As String
Select Case code
Expand Down Expand Up @@ -196,7 +196,7 @@ void C.M()
End If
Next

Dim hoverMarkupContent = DirectCast(hoverVertex.Result.Contents.Value.Fourth, MarkupContent)
Dim hoverMarkupContent = DirectCast(hoverVertex.Result.Contents.Fourth, MarkupContent)
Assert.Equal(MarkupKind.Markdown, hoverMarkupContent.Kind)
Assert.Equal("```csharp
class System.String
Expand Down
3 changes: 2 additions & 1 deletion src/Features/Lsif/GeneratorTest/OutputFormatTests.vb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Namespace Microsoft.CodeAnalysis.LanguageServerIndexFormat.Generator.UnitTests
</Workspace>, openDocuments:=False, composition:=TestLsifOutput.TestComposition), jsonWriter)

AssertEx.EqualOrDiff(
"{""hoverProvider"":true,""declarationProvider"":false,""definitionProvider"":true,""referencesProvider"":true,""typeDefinitionProvider"":false,""documentSymbolProvider"":true,""foldingRangeProvider"":true,""diagnosticProvider"":false,""semanticTokensProvider"":{""tokenTypes"":[""namespace"",""type"",""class"",""enum"",""interface"",""struct"",""typeParameter"",""parameter"",""variable"",""property"",""enumMember"",""event"",""function"",""method"",""macro"",""keyword"",""modifier"",""comment"",""string"",""number"",""regexp"",""operator"",""class name"",""constant name"",""delegate name"",""enum member name"",""enum name"",""event name"",""excluded code"",""extension method name"",""field name"",""interface name"",""json - array"",""json - comment"",""json - constructor name"",""json - keyword"",""json - number"",""json - object"",""json - operator"",""json - property name"",""json - punctuation"",""json - string"",""json - text"",""keyword - control"",""label name"",""local name"",""method name"",""module name"",""namespace name"",""operator - overloaded"",""parameter name"",""preprocessor keyword"",""preprocessor text"",""property name"",""punctuation"",""record class name"",""record struct name"",""regex - alternation"",""regex - anchor"",""regex - character class"",""regex - comment"",""regex - grouping"",""regex - other escape"",""regex - quantifier"",""regex - self escaped character"",""regex - text"",""roslyn test code markdown"",""string - escape character"",""string - verbatim"",""struct name"",""text"",""type parameter name"",""whitespace"",""xml doc comment - attribute name"",""xml doc comment - attribute quotes"",""xml doc comment - attribute value"",""xml doc comment - cdata section"",""xml doc comment - comment"",""xml doc comment - delimiter"",""xml doc comment - entity reference"",""xml doc comment - name"",""xml doc comment - processing instruction"",""xml doc comment - text"",""xml literal - attribute name"",""xml literal - attribute quotes"",""xml literal - attribute value"",""xml literal - cdata section"",""xml literal - comment"",""xml literal - delimiter"",""xml literal - embedded expression"",""xml literal - entity reference"",""xml literal - name"",""xml literal - processing instruction"",""xml literal - text""],""tokenModifiers"":[""static"",""deprecated""]},""id"":1,""type"":""vertex"",""label"":""capabilities""}
"{""hoverProvider"":true,""declarationProvider"":false,""definitionProvider"":true,""referencesProvider"":true,""typeDefinitionProvider"":false,""documentSymbolProvider"":true,""foldingRangeProvider"":true,""diagnosticProvider"":false,""semanticTokensProvider"":{""tokenTypes"":[""namespace"",""type"",""class"",""enum"",""interface"",""struct"",""typeParameter"",""parameter"",""variable"",""property"",""enumMember"",""event"",""function"",""method"",""macro"",""keyword"",""modifier"",""comment"",""string"",""number"",""regexp"",""operator"",""decorator"",""class name"",""constant name"",""delegate name"",""enum member name"",""enum name"",""event name"",""excluded code"",""extension method name"",""field name"",""interface name"",""json - array"",""json - comment"",""json - constructor name"",""json - keyword"",""json - number"",""json - object"",""json - operator"",""json - property name"",""json - punctuation"",""json - string"",""json - text"",""keyword - control"",""label name"",""local name"",""method name"",""module name"",""namespace name"",""operator - overloaded"",""parameter name"",""preprocessor keyword"",""preprocessor text"",""property name"",""punctuation"",""record class name"",""record struct name"",""regex - alternation"",""regex - anchor"",""regex - character class"",""regex - comment"",""regex - grouping"",""regex - other escape"",""regex - quantifier"",""regex - self escaped character"",""regex - text"",""roslyn test code markdown"",""string - escape character"",""string - verbatim"",""struct name"",""text"",""type parameter name"",""whitespace"",""xml doc comment - attribute name"",""xml doc comment - attribute quotes"",""xml doc comment - attribute value"",""xml doc comment - cdata section"",""xml doc comment - comment"",""xml doc comment - delimiter"",""xml doc comment - entity reference"",""xml doc comment - name"",""xml doc comment - processing instruction"",""xml doc comment - text"",""xml literal - attribute name"",""xml literal - attribute quotes"",""xml literal - attribute value"",""xml literal - cdata section"",""xml literal - comment"",""xml literal - delimiter"",""xml literal - embedded expression"",""xml literal - entity reference"",""xml literal - name"",""xml literal - processing instruction"",""xml literal - text""],""tokenModifiers"":[""static"",""deprecated""]},""id"":1,""type"":""vertex"",""label"":""capabilities""}
{""kind"":""csharp"",""resource"":""file:///Z:/%EE%89%9B/TestProject.csproj"",""name"":""TestProject"",""id"":2,""type"":""vertex"",""label"":""project""}
{""kind"":""begin"",""scope"":""project"",""data"":2,""id"":3,""type"":""vertex"",""label"":""$event""}
{""uri"":""file:///Z:/%EE%89%9B/a.cs"",""languageId"":""csharp"",""id"":4,""type"":""vertex"",""label"":""document""}
Expand Down Expand Up @@ -94,6 +94,7 @@ Namespace Microsoft.CodeAnalysis.LanguageServerIndexFormat.Generator.UnitTests
""number"",
""regexp"",
""operator"",
""decorator"",
""class name"",
""constant name"",
""delegate name"",
Expand Down
6 changes: 3 additions & 3 deletions src/Features/Lsif/GeneratorTest/SemanticTokensTests.vb
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ Namespace Microsoft.CodeAnalysis.LanguageServerIndexFormat.Generator.UnitTests

<Theory>
<InlineData("", "{""data"":[]}")>
<InlineData("namespace Foo;", "{""data"":[0,0,9,15,0,0,10,3,48,0,0,3,1,54,0]}")>
<InlineData("namespace " & vbCrLf & " Foo {}", "{""data"":[0,0,9,15,0,2,1,3,48,0,0,4,1,54,0,0,1,1,54,0]}")>
<InlineData("public class Foo { System.Collections.IList FooList { get; set; } int FooMethod() { int x = 0; return x; } }", "{""data"":[0,0,6,15,0,0,7,5,15,0,0,6,3,22,0,0,4,1,54,0,0,2,6,48,0,0,6,1,21,0,0,1,11,48,0,0,11,1,21,0,0,1,5,31,0,0,6,7,53,0,0,8,1,54,0,0,2,3,15,0,0,3,1,54,0,0,2,3,15,0,0,3,1,54,0,0,2,1,54,0,0,2,3,15,0,0,4,9,46,0,0,9,1,54,0,0,1,1,54,0,0,2,1,54,0,0,2,3,15,0,0,4,1,45,0,0,2,1,21,0,0,2,1,19,0,0,1,1,54,0,0,2,6,43,0,0,7,1,45,0,0,1,1,54,0,0,2,1,54,0,0,2,1,54,0]}")>
<InlineData("namespace Foo;", "{""data"":[0,0,9,15,0,0,10,3,49,0,0,3,1,55,0]}")>
<InlineData("namespace " & vbCrLf & " Foo {}", "{""data"":[0,0,9,15,0,2,1,3,49,0,0,4,1,55,0,0,1,1,55,0]}")>
<InlineData("public class Foo { System.Collections.IList FooList { get; set; } int FooMethod() { int x = 0; return x; } }", "{""data"":[0,0,6,15,0,0,7,5,15,0,0,6,3,23,0,0,4,1,55,0,0,2,6,49,0,0,6,1,21,0,0,1,11,49,0,0,11,1,21,0,0,1,5,32,0,0,6,7,54,0,0,8,1,55,0,0,2,3,15,0,0,3,1,55,0,0,2,3,15,0,0,3,1,55,0,0,2,1,55,0,0,2,3,15,0,0,4,9,47,0,0,9,1,55,0,0,1,1,55,0,0,2,1,55,0,0,2,3,15,0,0,4,1,46,0,0,2,1,21,0,0,2,1,19,0,0,1,1,55,0,0,2,6,44,0,0,7,1,46,0,0,1,1,55,0,0,2,1,55,0,0,2,1,55,0]}")>
Public Async Function TestSemanticTokensData(code As String, expectedTokens As String) As Task
' This test performs LSIF specific validation of the semantic tokens output. As of this writing
' this feature is based on the same code path used to generate semantic tokens information in LSP
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class LspFileChangeWatcherTests : AbstractLanguageServerHostTests
{
Workspace = new WorkspaceClientCapabilities
{
DidChangeWatchedFiles = new DynamicRegistrationSetting { DynamicRegistration = true }
DidChangeWatchedFiles = new DidChangeWatchedFilesClientCapabilities { DynamicRegistration = true }
}
};

Expand Down Expand Up @@ -66,8 +66,8 @@ public async Task CreatingDirectoryWatchRequestsDirectoryWatch()

var watcher = GetSingleFileWatcher(dynamicCapabilitiesRpcTarget);

Assert.Equal(tempDirectory.Path, watcher.GlobPattern.BaseUri.LocalPath);
Assert.Equal("**/*", watcher.GlobPattern.Pattern);
Assert.Equal(tempDirectory.Path, watcher.GlobPattern.Second.BaseUri.Second.LocalPath);
Assert.Equal("**/*", watcher.GlobPattern.Second.Pattern);

// Get rid of the registration and it should be gone again
context.Dispose();
Expand Down Expand Up @@ -98,8 +98,8 @@ public async Task CreatingFileWatchRequestsFileWatch()

var watcher = GetSingleFileWatcher(dynamicCapabilitiesRpcTarget);

Assert.Equal("Z:\\", watcher.GlobPattern.BaseUri.LocalPath);
Assert.Equal("SingleFile.txt", watcher.GlobPattern.Pattern);
Assert.Equal("Z:\\", watcher.GlobPattern.Second.BaseUri.Second.LocalPath);
Assert.Equal("SingleFile.txt", watcher.GlobPattern.Second.Pattern);

// Get rid of the registration and it should be gone again
watchedFile.Dispose();
Expand Down Expand Up @@ -134,7 +134,7 @@ public Task RegisterCapabilityAsync(RegistrationParams registrationParams, Cance
}

[JsonRpcMethod("client/unregisterCapability", UseSingleObjectParameterDeserialization = true)]
public Task UnregisterCapabilityAsync(UnregistrationParamsWithMisspelling unregistrationParams, CancellationToken _)
public Task UnregisterCapabilityAsync(UnregistrationParams unregistrationParams, CancellationToken _)
{
foreach (var unregistration in unregistrationParams.Unregistrations)
Assert.True(Registrations.TryRemove(unregistration.Id, out var _));
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ public void Dispose()

_registrationTask.ContinueWith(async _ =>
{
var unregistrationParams = new UnregistrationParamsWithMisspelling()
var unregistrationParams = new UnregistrationParams()
{
Unregistrations =
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public async Task InitializeServer_SerializesCorrectly()
var server = TestExampleLanguageServer.CreateLanguageServer(logger);

var result = await server.InitializeServerAsync();
Assert.True(result.Capabilities.SemanticTokensOptions!.Range!.Value.First);
Assert.True(result.Capabilities.SemanticTokensOptions!.Value.Unify().Range!.Value.First);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ public static LSP.Range TextSpanToRange(TextSpan textSpan, SourceText text)
}
}

var documentEdits = uriToTextEdits.GroupBy(uriAndEdit => uriAndEdit.Uri, uriAndEdit => uriAndEdit.TextEdit, (uri, edits) => new LSP.TextDocumentEdit
var documentEdits = uriToTextEdits.GroupBy(uriAndEdit => uriAndEdit.Uri, uriAndEdit => new LSP.SumType<LSP.TextEdit, LSP.AnnotatedTextEdit>(uriAndEdit.TextEdit), (uri, edits) => new LSP.TextDocumentEdit
{
TextDocument = new LSP.OptionalVersionedTextDocumentIdentifier { Uri = uri },
Edits = edits.ToArray(),
Expand Down
12 changes: 12 additions & 0 deletions src/LanguageServer/Protocol/Handler/BufferedProgress.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System;
using System.Linq;
using Microsoft.CodeAnalysis.PooledObjects;
using Roslyn.LanguageServer.Protocol;
using Roslyn.Utilities;

namespace Microsoft.CodeAnalysis.LanguageServer.Handler
Expand Down Expand Up @@ -69,6 +70,12 @@ internal static class BufferedProgress
public static BufferedProgress<T> Create<T>(IProgress<T>? progress)
=> new BufferedProgress<T>(progress);

public static BufferedProgress<TIn> Create<TIn, TOut>(IProgress<TOut>? progress, Func<TIn, TOut> transform)
=> Create(progress?.Transform(transform));

static IProgress<TIn> Transform<TIn, TOut>(this IProgress<TOut> progress, Func<TIn, TOut> transform)
=> new ProgressTransformer<TIn, TOut>(progress, transform);

public static void Report<T>(this BufferedProgress<T[]> progress, T item)
{
progress.Report([item]);
Expand All @@ -78,5 +85,10 @@ public static void Report<T>(this BufferedProgress<T[]> progress, T item)
{
return progress.GetValues()?.Flatten().ToArray();
}

class ProgressTransformer<TIn, TOut>(IProgress<TOut> inner, Func<TIn, TOut> transform) : IProgress<TIn>
{
public void Report(TIn value) => inner.Report(transform(value));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ async Task AddTextDocumentEditsAsync<TTextDocument>(
textChanges = newText.GetTextChanges(oldText);
}

var edits = textChanges.Select(tc => ProtocolConversions.TextChangeToTextEdit(tc, oldText)).ToArray();
var edits = textChanges.Select(tc => new LSP.SumType<LSP.TextEdit, LSP.AnnotatedTextEdit>(ProtocolConversions.TextChangeToTextEdit(tc, oldText))).ToArray();

if (edits.Length > 0)
{
Expand Down
Loading
Loading