diff --git a/internal/fourslash/baselineutil.go b/internal/fourslash/baselineutil.go index 888c737949..550ffd53ea 100644 --- a/internal/fourslash/baselineutil.go +++ b/internal/fourslash/baselineutil.go @@ -49,11 +49,11 @@ type baselineFourslashLocationsOptions struct { additionalSpan *lsproto.Location } -func (f *FourslashTest) getBaselineForLocationsWithFileContents(spans []*lsproto.Location, options baselineFourslashLocationsOptions) string { - return f.getBaselineForGroupedLocationsWithFileContents(collections.GroupBy(spans, func(span *lsproto.Location) lsproto.DocumentUri { return span.Uri }), options) +func (f *FourslashTest) getBaselineForLocationsWithFileContents(spans []lsproto.Location, options baselineFourslashLocationsOptions) string { + return f.getBaselineForGroupedLocationsWithFileContents(collections.GroupBy(spans, func(span lsproto.Location) lsproto.DocumentUri { return span.Uri }), options) } -func (f *FourslashTest) getBaselineForGroupedLocationsWithFileContents(groupedLocations *collections.MultiMap[lsproto.DocumentUri, *lsproto.Location], options baselineFourslashLocationsOptions) string { +func (f *FourslashTest) getBaselineForGroupedLocationsWithFileContents(groupedLocations *collections.MultiMap[lsproto.DocumentUri, lsproto.Location], options baselineFourslashLocationsOptions) string { // We must always print the file containing the marker, // but don't want to print it twice at the end if it already // found in a file with ranges. @@ -85,9 +85,9 @@ func (f *FourslashTest) getBaselineForGroupedLocationsWithFileContents(groupedLo foundMarker = true } - documentSpans := core.Map(locations, func(location *lsproto.Location) *documentSpan { + documentSpans := core.Map(locations, func(location lsproto.Location) *documentSpan { return &documentSpan{ - Location: *location, + Location: location, } }) baselineEntries = append(baselineEntries, f.getBaselineContentForFile(path, content, documentSpans, nil, options)) diff --git a/internal/fourslash/fourslash.go b/internal/fourslash/fourslash.go index 7b41cf5539..e1d44fd69e 100644 --- a/internal/fourslash/fourslash.go +++ b/internal/fourslash/fourslash.go @@ -230,8 +230,8 @@ func (f *FourslashTest) initialize(t *testing.T, capabilities *lsproto.ClientCap params := &lsproto.InitializeParams{} params.Capabilities = getCapabilitiesWithDefaults(capabilities) // !!! check for errors? - f.sendRequest(t, lsproto.MethodInitialize, params) - f.sendNotification(t, lsproto.MethodInitialized, &lsproto.InitializedParams{}) + sendRequest(t, f, lsproto.InitializeInfo, params) + sendNotification(t, f, lsproto.InitializedInfo, &lsproto.InitializedParams{}) } var ( @@ -267,20 +267,25 @@ func getCapabilitiesWithDefaults(capabilities *lsproto.ClientCapabilities) *lspr return &capabilitiesWithDefaults } -func (f *FourslashTest) sendRequest(t *testing.T, method lsproto.Method, params any) *lsproto.Message { +func sendRequest[Params, Resp any](t *testing.T, f *FourslashTest, info lsproto.RequestInfo[Params, Resp], params Params) (*lsproto.Message, Resp, bool) { id := f.nextID() req := lsproto.NewRequestMessage( - method, + info.Method, lsproto.NewID(lsproto.IntegerOrString{Integer: &id}), params, ) f.writeMsg(t, req.Message()) - return f.readMsg(t) + resp := f.readMsg(t) + if resp == nil { + return nil, *new(Resp), false + } + result, ok := resp.AsResponse().Result.(Resp) + return resp, result, ok } -func (f *FourslashTest) sendNotification(t *testing.T, method lsproto.Method, params any) { +func sendNotification[Params any](t *testing.T, f *FourslashTest, info lsproto.NotificationInfo[Params], params Params) { notification := lsproto.NewNotificationMessage( - method, + info.Method, params, ) f.writeMsg(t, notification.Message()) @@ -430,7 +435,7 @@ func (f *FourslashTest) openFile(t *testing.T, filename string) { t.Fatalf("File %s not found in test data", filename) } f.activeFilename = filename - f.sendNotification(t, lsproto.MethodTextDocumentDidOpen, &lsproto.DidOpenTextDocumentParams{ + sendNotification(t, f, lsproto.TextDocumentDidOpenInfo, &lsproto.DidOpenTextDocumentParams{ TextDocument: &lsproto.TextDocumentItem{ Uri: ls.FileNameToDocumentURI(filename), LanguageId: getLanguageKind(filename), @@ -544,17 +549,14 @@ func (f *FourslashTest) verifyCompletionsWorker(t *testing.T, expected *Completi TextDocumentPositionParams: f.currentTextDocumentPositionParams(), Context: &lsproto.CompletionContext{}, } - resMsg := f.sendRequest(t, lsproto.MethodTextDocumentCompletion, params) + resMsg, result, resultOk := sendRequest(t, f, lsproto.TextDocumentCompletionInfo, params) if resMsg == nil { t.Fatalf(prefix+"Nil response received for completion request", f.lastKnownMarkerName) } - result := resMsg.AsResponse().Result - switch result := result.(type) { - case *lsproto.CompletionList: - f.verifyCompletionsResult(t, f.currentCaretPosition, result, expected, prefix) - default: - t.Fatalf(prefix+"Unexpected response type for completion request: %v", result) + if !resultOk { + t.Fatalf(prefix+"Unexpected response type for completion request: %T", resMsg.AsResponse().Result) } + f.verifyCompletionsResult(t, f.currentCaretPosition, result.List, expected, prefix) } func (f *FourslashTest) verifyCompletionsResult( @@ -732,15 +734,14 @@ var completionIgnoreOpts = cmp.FilterPath( func (f *FourslashTest) verifyCompletionItem(t *testing.T, prefix string, actual *lsproto.CompletionItem, expected *lsproto.CompletionItem) { if expected.Detail != nil || expected.Documentation != nil { - response := f.sendRequest(t, lsproto.MethodCompletionItemResolve, actual) - if response == nil { + resMsg, result, resultOk := sendRequest(t, f, lsproto.CompletionItemResolveInfo, actual) + if resMsg == nil { t.Fatal(prefix + "Expected non-nil response for completion item resolve, got nil") } - resolvedItem, ok := response.AsResponse().Result.(*lsproto.CompletionItem) - if !ok { - t.Fatalf(prefix+"Expected response to be *lsproto.CompletionItem, got %T", response.AsResponse().Result) + if !resultOk { + t.Fatalf(prefix+"Unexpected response type for completion item resolve: %T", resMsg.AsResponse().Result) } - actual = resolvedItem + actual = result } assertDeepEqual(t, actual, expected, prefix, completionIgnoreOpts) if expected.Kind != nil { @@ -799,7 +800,7 @@ func (f *FourslashTest) VerifyBaselineFindAllReferences( TextDocumentPositionParams: f.currentTextDocumentPositionParams(), Context: &lsproto.ReferenceContext{}, } - resMsg := f.sendRequest(t, lsproto.MethodTextDocumentReferences, params) + resMsg, result, resultOk := sendRequest(t, f, lsproto.TextDocumentReferencesInfo, params) if resMsg == nil { if f.lastKnownMarkerName == nil { t.Fatalf("Nil response received for references request at pos %v", f.currentCaretPosition) @@ -807,20 +808,19 @@ func (f *FourslashTest) VerifyBaselineFindAllReferences( t.Fatalf("Nil response received for references request at marker '%s'", *f.lastKnownMarkerName) } } - - result := resMsg.AsResponse().Result - if resultAsLocation, ok := result.([]*lsproto.Location); ok { - f.baseline.addResult("findAllReferences", f.getBaselineForLocationsWithFileContents(resultAsLocation, baselineFourslashLocationsOptions{ - marker: markerOrRange.GetMarker(), - markerName: "/*FIND ALL REFS*/", - })) - } else { + if !resultOk { if f.lastKnownMarkerName == nil { - t.Fatalf("Unexpected references response type at pos %v: %T", f.currentCaretPosition, result) + t.Fatalf("Unexpected references response type at pos %v: %T", f.currentCaretPosition, resMsg.AsResponse().Result) } else { - t.Fatalf("Unexpected references response type at marker '%s': %T", *f.lastKnownMarkerName, result) + t.Fatalf("Unexpected references response type at marker '%s': %T", *f.lastKnownMarkerName, resMsg.AsResponse().Result) } } + + f.baseline.addResult("findAllReferences", f.getBaselineForLocationsWithFileContents(*result, baselineFourslashLocationsOptions{ + marker: markerOrRange.GetMarker(), + markerName: "/*FIND ALL REFS*/", + })) + } baseline.Run(t, f.baseline.getBaselineFileName(), f.baseline.content.String(), baseline.Options{}) @@ -854,7 +854,8 @@ func (f *FourslashTest) VerifyBaselineGoToDefinition( params := &lsproto.DefinitionParams{ TextDocumentPositionParams: f.currentTextDocumentPositionParams(), } - resMsg := f.sendRequest(t, lsproto.MethodTextDocumentDefinition, params) + + resMsg, result, resultOk := sendRequest(t, f, lsproto.TextDocumentDefinitionInfo, params) if resMsg == nil { if f.lastKnownMarkerName == nil { t.Fatalf("Nil response received for definition request at pos %v", f.currentCaretPosition) @@ -862,31 +863,29 @@ func (f *FourslashTest) VerifyBaselineGoToDefinition( t.Fatalf("Nil response received for definition request at marker '%s'", *f.lastKnownMarkerName) } } - - result := resMsg.AsResponse().Result - if resultAsLocOrLocations, ok := result.(*lsproto.LocationOrLocations); ok { - var resultAsLocations []*lsproto.Location - if resultAsLocOrLocations != nil { - if resultAsLocOrLocations.Locations != nil { - resultAsLocations = core.Map(*resultAsLocOrLocations.Locations, func(loc lsproto.Location) *lsproto.Location { - return &loc - }) - } else { - resultAsLocations = []*lsproto.Location{resultAsLocOrLocations.Location} - } + if !resultOk { + if f.lastKnownMarkerName == nil { + t.Fatalf("Unexpected definition response type at pos %v: %T", f.currentCaretPosition, resMsg.AsResponse().Result) + } else { + t.Fatalf("Unexpected definition response type at marker '%s': %T", *f.lastKnownMarkerName, resMsg.AsResponse().Result) } + } - f.baseline.addResult("goToDefinition", f.getBaselineForLocationsWithFileContents(resultAsLocations, baselineFourslashLocationsOptions{ - marker: markerOrRange.GetMarker(), - markerName: "/*GO TO DEFINITION*/", - })) - } else { - if f.lastKnownMarkerName == nil { - t.Fatalf("Unexpected definition response type at pos %v: %T", f.currentCaretPosition, result) + var resultAsLocations []lsproto.Location + if result != nil { + if result.Locations != nil { + resultAsLocations = *result.Locations + } else if result.Location != nil { + resultAsLocations = []lsproto.Location{*result.Location} } else { - t.Fatalf("Unexpected definition response type at marker '%s': %T", *f.lastKnownMarkerName, result) + t.Fatalf("Unexpected definition response type at marker '%s': %T", *f.lastKnownMarkerName, result.DefinitionLinks) } } + + f.baseline.addResult("goToDefinition", f.getBaselineForLocationsWithFileContents(resultAsLocations, baselineFourslashLocationsOptions{ + marker: markerOrRange.GetMarker(), + markerName: "/*GO TO DEFINITION*/", + })) } baseline.Run(t, f.baseline.getBaselineFileName(), f.baseline.content.String(), baseline.Options{}) @@ -1060,16 +1059,16 @@ func (f *FourslashTest) editScript(t *testing.T, fileName string, start int, end if err != nil { panic(fmt.Sprintf("Failed to write file %s: %v", fileName, err)) } - f.sendNotification(t, lsproto.MethodTextDocumentDidChange, &lsproto.DidChangeTextDocumentParams{ + sendNotification(t, f, lsproto.TextDocumentDidChangeInfo, &lsproto.DidChangeTextDocumentParams{ TextDocument: lsproto.VersionedTextDocumentIdentifier{ TextDocumentIdentifier: lsproto.TextDocumentIdentifier{ Uri: ls.FileNameToDocumentURI(fileName), }, Version: script.version, }, - ContentChanges: []lsproto.TextDocumentContentChangeEvent{ + ContentChanges: []lsproto.TextDocumentContentChangePartialOrWholeDocument{ { - TextDocumentContentChangePartial: &lsproto.TextDocumentContentChangePartial{ + Partial: &lsproto.TextDocumentContentChangePartial{ Range: changeRange, Text: newText, }, diff --git a/internal/ls/definition.go b/internal/ls/definition.go index 8fffa2d628..e47bc15ea9 100644 --- a/internal/ls/definition.go +++ b/internal/ls/definition.go @@ -11,7 +11,7 @@ import ( "github.com/microsoft/typescript-go/internal/scanner" ) -func (l *LanguageService) ProvideDefinition(ctx context.Context, documentURI lsproto.DocumentUri, position lsproto.Position) (*lsproto.Definition, error) { +func (l *LanguageService) ProvideDefinition(ctx context.Context, documentURI lsproto.DocumentUri, position lsproto.Position) (lsproto.DefinitionResponse, error) { program, file := l.getProgramAndFile(documentURI) node := astnav.GetTouchingPropertyName(file, int(l.converters.LineAndCharacterToPosition(file, position))) if node.Kind == ast.KindSourceFile { @@ -84,7 +84,7 @@ func (l *LanguageService) ProvideDefinition(ctx context.Context, documentURI lsp return nil, nil } -func (l *LanguageService) ProvideTypeDefinition(ctx context.Context, documentURI lsproto.DocumentUri, position lsproto.Position) (*lsproto.Definition, error) { +func (l *LanguageService) ProvideTypeDefinition(ctx context.Context, documentURI lsproto.DocumentUri, position lsproto.Position) (lsproto.DefinitionResponse, error) { program, file := l.getProgramAndFile(documentURI) node := astnav.GetTouchingPropertyName(file, int(l.converters.LineAndCharacterToPosition(file, position))) if node.Kind == ast.KindSourceFile { @@ -126,7 +126,7 @@ func getDeclarationNameForKeyword(node *ast.Node) *ast.Node { return node } -func (l *LanguageService) createLocationsFromDeclarations(declarations []*ast.Node) *lsproto.Definition { +func (l *LanguageService) createLocationsFromDeclarations(declarations []*ast.Node) lsproto.DefinitionResponse { someHaveBody := core.Some(declarations, func(node *ast.Node) bool { return node.Body() != nil }) locations := make([]lsproto.Location, 0, len(declarations)) for _, decl := range declarations { @@ -139,11 +139,11 @@ func (l *LanguageService) createLocationsFromDeclarations(declarations []*ast.No }) } } - return &lsproto.Definition{Locations: &locations} + return &lsproto.LocationOrLocationsOrDefinitionLinks{Locations: &locations} } -func (l *LanguageService) createLocationFromFileAndRange(file *ast.SourceFile, textRange core.TextRange) *lsproto.Definition { - return &lsproto.Definition{ +func (l *LanguageService) createLocationFromFileAndRange(file *ast.SourceFile, textRange core.TextRange) lsproto.DefinitionResponse { + return &lsproto.LocationOrLocationsOrDefinitionLinks{ Location: &lsproto.Location{ Uri: FileNameToDocumentURI(file.FileName()), Range: *l.createLspRangeFromBounds(textRange.Pos(), textRange.End(), file), diff --git a/internal/ls/definition_test.go b/internal/ls/definition_test.go index 29cc6aa134..6c424aa301 100644 --- a/internal/ls/definition_test.go +++ b/internal/ls/definition_test.go @@ -22,7 +22,7 @@ func TestDefinition(t *testing.T) { testCases := []struct { title string input string - expected map[string]lsproto.Definition + expected map[string]lsproto.DefinitionResponse }{ { title: "localFunction", @@ -30,7 +30,7 @@ func TestDefinition(t *testing.T) { // @filename: index.ts function localFunction() { } /*localFunction*/localFunction();`, - expected: map[string]lsproto.Definition{ + expected: map[string]lsproto.DefinitionResponse{ "localFunction": { Locations: &[]lsproto.Location{{ Uri: ls.FileNameToDocumentURI("/index.ts"), @@ -49,7 +49,7 @@ function localFunction() { } } } -func runDefinitionTest(t *testing.T, input string, expected map[string]lsproto.Definition) { +func runDefinitionTest(t *testing.T, input string, expected map[string]lsproto.DefinitionResponse) { testData := fourslash.ParseTestData(t, input, "/mainFile.ts") file := testData.Files[0].FileName() markerPositions := testData.MarkerPositions @@ -69,6 +69,6 @@ func runDefinitionTest(t *testing.T, input string, expected map[string]lsproto.D ls.FileNameToDocumentURI(file), marker.LSPosition) assert.NilError(t, err) - assert.DeepEqual(t, *locations, expectedResult) + assert.DeepEqual(t, locations, expectedResult) } } diff --git a/internal/ls/diagnostics.go b/internal/ls/diagnostics.go index bf59fee2ad..450260deed 100644 --- a/internal/ls/diagnostics.go +++ b/internal/ls/diagnostics.go @@ -10,8 +10,8 @@ import ( "github.com/microsoft/typescript-go/internal/lsp/lsproto" ) -func (l *LanguageService) GetDocumentDiagnostics(ctx context.Context, documentURI lsproto.DocumentUri) (*lsproto.DocumentDiagnosticReport, error) { - program, file := l.getProgramAndFile(documentURI) +func (l *LanguageService) ProvideDiagnostics(ctx context.Context, uri lsproto.DocumentUri) (lsproto.DocumentDiagnosticResponse, error) { + program, file := l.getProgramAndFile(uri) diagnostics := make([][]*ast.Diagnostic, 0, 3) if syntaxDiagnostics := program.GetSyntacticDiagnostics(ctx, file); len(syntaxDiagnostics) != 0 { @@ -26,8 +26,8 @@ func (l *LanguageService) GetDocumentDiagnostics(ctx context.Context, documentUR } } - return &lsproto.DocumentDiagnosticReport{ - RelatedFullDocumentDiagnosticReport: &lsproto.RelatedFullDocumentDiagnosticReport{ + return lsproto.RelatedFullDocumentDiagnosticReportOrUnchangedDocumentDiagnosticReport{ + FullDocumentDiagnosticReport: &lsproto.RelatedFullDocumentDiagnosticReport{ FullDocumentDiagnosticReport: lsproto.FullDocumentDiagnosticReport{ Items: toLSPDiagnostics(l.converters, diagnostics...), }, diff --git a/internal/ls/findallreferences.go b/internal/ls/findallreferences.go index fb464b3f93..1763598d4c 100644 --- a/internal/ls/findallreferences.go +++ b/internal/ls/findallreferences.go @@ -396,7 +396,7 @@ func getSymbolScope(symbol *ast.Symbol) *ast.Node { // === functions on (*ls) === -func (l *LanguageService) ProvideReferences(params *lsproto.ReferenceParams) []*lsproto.Location { +func (l *LanguageService) ProvideReferences(params *lsproto.ReferenceParams) []lsproto.Location { // `findReferencedSymbols` except only computes the information needed to return reference locations program, sourceFile := l.getProgramAndFile(params.TextDocument.Uri) position := int(l.converters.LineAndCharacterToPosition(sourceFile, params.Position)) @@ -409,7 +409,7 @@ func (l *LanguageService) ProvideReferences(params *lsproto.ReferenceParams) []* return core.FlatMap(symbolsAndEntries, l.convertSymbolAndEntriesToLocations) } -func (l *LanguageService) ProvideImplementations(params *lsproto.ImplementationParams) []*lsproto.Location { +func (l *LanguageService) ProvideImplementations(params *lsproto.ImplementationParams) []lsproto.Location { program, sourceFile := l.getProgramAndFile(params.TextDocument.Uri) position := int(l.converters.LineAndCharacterToPosition(sourceFile, params.Position)) node := astnav.GetTouchingPropertyName(sourceFile, position) @@ -437,19 +437,19 @@ func (l *LanguageService) getImplementationReferenceEntries(program *compiler.Pr } // == functions for conversions == -func (l *LanguageService) convertSymbolAndEntriesToLocations(s *SymbolAndEntries) []*lsproto.Location { +func (l *LanguageService) convertSymbolAndEntriesToLocations(s *SymbolAndEntries) []lsproto.Location { return l.convertEntriesToLocations(s.references) } -func (l *LanguageService) convertEntriesToLocations(entries []*referenceEntry) []*lsproto.Location { - locations := make([]*lsproto.Location, len(entries)) +func (l *LanguageService) convertEntriesToLocations(entries []*referenceEntry) []lsproto.Location { + locations := make([]lsproto.Location, len(entries)) for i, entry := range entries { if entry.textRange == nil { sourceFile := ast.GetSourceFileOfNode(entry.node) entry.textRange = l.getRangeOfNode(entry.node, sourceFile, nil /*endNode*/) entry.fileName = sourceFile.FileName() } - locations[i] = &lsproto.Location{ + locations[i] = lsproto.Location{ Uri: FileNameToDocumentURI(entry.fileName), Range: *entry.textRange, } diff --git a/internal/ls/findallreferences_test.go b/internal/ls/findallreferences_test.go index bfe5c43315..94e1c5f080 100644 --- a/internal/ls/findallreferences_test.go +++ b/internal/ls/findallreferences_test.go @@ -36,7 +36,7 @@ func runFindReferencesTest(t *testing.T, input string, expectedLocations map[str libReference := 0 for _, loc := range referencesResult { - if name, ok := allExpectedLocations[*loc]; ok { + if name, ok := allExpectedLocations[loc]; ok { // check if returned ref location is in this request's expected set assert.Assert(t, expectedSet.Has(name), "Reference to '%s' not expected when find all references requested at %s", name, requestMarkerName) } else if strings.Contains(string(loc.Uri), "//bundled") && strings.Contains(string(loc.Uri), "//libs") { diff --git a/internal/ls/findallreferencesexport_test.go b/internal/ls/findallreferencesexport_test.go index 9fe040197c..a30a058c1b 100644 --- a/internal/ls/findallreferencesexport_test.go +++ b/internal/ls/findallreferencesexport_test.go @@ -17,7 +17,7 @@ func (l *LanguageService) GetExpectedReferenceFromMarker(fileName string, pos in } } -func (l *LanguageService) TestProvideReferences(fileName string, pos int) []*lsproto.Location { +func (l *LanguageService) TestProvideReferences(fileName string, pos int) []lsproto.Location { _, sourceFile := l.tryGetProgramAndFile(fileName) lsPos := l.converters.PositionToLineAndCharacter(sourceFile, core.TextPos(pos)) return l.ProvideReferences(&lsproto.ReferenceParams{ diff --git a/internal/ls/hover.go b/internal/ls/hover.go index 5fa53d06e8..41c53756c1 100644 --- a/internal/ls/hover.go +++ b/internal/ls/hover.go @@ -30,7 +30,7 @@ func (l *LanguageService) ProvideHover(ctx context.Context, documentURI lsproto. quickInfo, documentation := getQuickInfoAndDocumentation(c, node) if quickInfo != "" { return &lsproto.Hover{ - Contents: lsproto.MarkupContentOrMarkedStringOrMarkedStrings{ + Contents: lsproto.MarkupContentOrStringOrMarkedStringWithLanguageOrMarkedStrings{ MarkupContent: &lsproto.MarkupContent{ Kind: lsproto.MarkupKindMarkdown, Value: formatQuickInfo(quickInfo) + documentation, diff --git a/internal/ls/hover_test.go b/internal/ls/hover_test.go index 71f99ccf57..ff097cd078 100644 --- a/internal/ls/hover_test.go +++ b/internal/ls/hover_test.go @@ -41,7 +41,7 @@ function myFunction() { /*marker*/myFunction();`, expected: map[string]*lsproto.Hover{ "marker": { - Contents: lsproto.MarkupContentOrMarkedStringOrMarkedStrings{ + Contents: lsproto.MarkupContentOrStringOrMarkedStringWithLanguageOrMarkedStrings{ MarkupContent: &lsproto.MarkupContent{ Kind: lsproto.MarkupKindMarkdown, Value: "```tsx\nfunction myFunction(): string\n```\nA function with JSDoc links that previously caused panic\n`console.log` and `Array.from` and `Object.keys`", @@ -64,7 +64,7 @@ function /*marker*/myFunction(param) { myFunction();`, expected: map[string]*lsproto.Hover{ "marker": { - Contents: lsproto.MarkupContentOrMarkedStringOrMarkedStrings{ + Contents: lsproto.MarkupContentOrStringOrMarkedStringWithLanguageOrMarkedStrings{ MarkupContent: &lsproto.MarkupContent{ Kind: lsproto.MarkupKindMarkdown, Value: "```tsx\nfunction myFunction(param: string): string\n```\n\n\n*@param* `param` - the greatest of days\n", @@ -87,7 +87,7 @@ function myFunction(param) { /*marker*/myFunction();`, expected: map[string]*lsproto.Hover{ "marker": { - Contents: lsproto.MarkupContentOrMarkedStringOrMarkedStrings{ + Contents: lsproto.MarkupContentOrStringOrMarkedStringWithLanguageOrMarkedStrings{ MarkupContent: &lsproto.MarkupContent{ Kind: lsproto.MarkupKindMarkdown, Value: "```tsx\nfunction myFunction(param: string): string\n```\n\n\n*@param* `param` - the greatest of days\n", @@ -110,7 +110,7 @@ function myFunction(/*marker*/param) { myFunction();`, expected: map[string]*lsproto.Hover{ "marker": { - Contents: lsproto.MarkupContentOrMarkedStringOrMarkedStrings{ + Contents: lsproto.MarkupContentOrStringOrMarkedStringWithLanguageOrMarkedStrings{ MarkupContent: &lsproto.MarkupContent{ Kind: lsproto.MarkupKindMarkdown, Value: "```tsx\n(parameter) param: string\n```\n- the greatest of days\n", @@ -170,7 +170,7 @@ func runHoverTest(t *testing.T, input string, expected map[string]*lsproto.Hover assert.Assert(t, result == nil) } else { assert.Assert(t, result != nil) - assert.DeepEqual(t, *result, *expectedResult) + assert.DeepEqual(t, result, expectedResult) } } } diff --git a/internal/ls/signaturehelp.go b/internal/ls/signaturehelp.go index 8ad8567e21..68d7521b54 100644 --- a/internal/ls/signaturehelp.go +++ b/internal/ls/signaturehelp.go @@ -126,15 +126,15 @@ func createTypeHelpItems(symbol *ast.Symbol, argumentInfo *argumentListInfo, sou }, } - var activeParameter *lsproto.Nullable[uint32] + var activeParameter *lsproto.UintegerOrNull if argumentInfo.argumentIndex == nil { if clientOptions.SignatureInformation.NoActiveParameterSupport != nil && *clientOptions.SignatureInformation.NoActiveParameterSupport { activeParameter = nil } else { - activeParameter = ptrTo(lsproto.ToNullable(uint32(0))) + activeParameter = &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))} } } else { - activeParameter = ptrTo(lsproto.ToNullable(uint32(*argumentInfo.argumentIndex))) + activeParameter = &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(*argumentInfo.argumentIndex))} } return &lsproto.SignatureHelp{ Signatures: signatureInformation, @@ -240,13 +240,13 @@ func createSignatureHelpItems(candidates []*checker.Signature, resolvedSignature } } - var activeParameter *lsproto.Nullable[uint32] + var activeParameter *lsproto.UintegerOrNull if argumentInfo.argumentIndex == nil { if clientOptions.SignatureInformation.NoActiveParameterSupport != nil && *clientOptions.SignatureInformation.NoActiveParameterSupport { activeParameter = nil } } else { - activeParameter = ptrTo(lsproto.ToNullable(uint32(*argumentInfo.argumentIndex))) + activeParameter = &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(*argumentInfo.argumentIndex))} } help := &lsproto.SignatureHelp{ Signatures: signatureInformation, @@ -261,10 +261,10 @@ func createSignatureHelpItems(candidates []*checker.Signature, resolvedSignature }) if -1 < firstRest && firstRest < len(activeSignature.Parameters)-1 { // We don't have any code to get this correct; instead, don't highlight a current parameter AT ALL - help.ActiveParameter = ptrTo(lsproto.ToNullable(uint32(len(activeSignature.Parameters)))) + help.ActiveParameter = &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(len(activeSignature.Parameters)))} } - if help.ActiveParameter != nil && *&help.ActiveParameter.Value > uint32(len(activeSignature.Parameters)-1) { - help.ActiveParameter = ptrTo(lsproto.ToNullable(uint32(len(activeSignature.Parameters) - 1))) + if help.ActiveParameter != nil && help.ActiveParameter.Uinteger != nil && *help.ActiveParameter.Uinteger > uint32(len(activeSignature.Parameters)-1) { + help.ActiveParameter = &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(len(activeSignature.Parameters) - 1))} } } return help diff --git a/internal/ls/signaturehelp_test.go b/internal/ls/signaturehelp_test.go index 36be7655de..e4ab14dc09 100644 --- a/internal/ls/signaturehelp_test.go +++ b/internal/ls/signaturehelp_test.go @@ -16,7 +16,7 @@ type verifySignatureHelpOptions struct { text string parameterSpan string parameterCount int - activeParameter *lsproto.Nullable[uint32] + activeParameter *lsproto.UintegerOrNull // triggerReason ls.SignatureHelpTriggerReason // tags?: ReadonlyArray; } @@ -42,13 +42,13 @@ fnTest(/*1*/'', /*2*/5);`, "1": { text: `fnTest(str: string, num: number): void`, parameterCount: 2, - activeParameter: &lsproto.Nullable[uint32]{Value: 0}, + activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}, parameterSpan: "str: string", }, "2": { text: `fnTest(str: string, num: number): void`, parameterCount: 2, - activeParameter: &lsproto.Nullable[uint32]{Value: 1}, + activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(1))}, parameterSpan: "num: number", }, }, @@ -78,73 +78,73 @@ const cb2: () => void = (/*contextualFunctionType*/)`, "takesObj0": { text: "m(n: number, s: string): void", parameterCount: 2, - activeParameter: &lsproto.Nullable[uint32]{Value: 0}, + activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}, parameterSpan: "n: number", }, "takesObj1": { text: "m(n: number, s: string): void", parameterCount: 2, - activeParameter: &lsproto.Nullable[uint32]{Value: 0}, + activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}, parameterSpan: "n: number", }, "takesObj2": { text: "m(n: number, s: string): void", parameterCount: 2, - activeParameter: &lsproto.Nullable[uint32]{Value: 0}, + activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}, parameterSpan: "n: number", }, "takesObj3": { text: "m2(): void", parameterCount: 0, - activeParameter: &lsproto.Nullable[uint32]{Value: 0}, + activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}, parameterSpan: "", }, "contextualParameter1": { text: "cb(n: number, s: string, b: boolean): void", parameterCount: 3, - activeParameter: &lsproto.Nullable[uint32]{Value: 0}, + activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}, parameterSpan: "n: number", }, "contextualParameter1b": { text: "cb(n: number, s: string, b: boolean): void", parameterCount: 3, - activeParameter: &lsproto.Nullable[uint32]{Value: 0}, + activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}, parameterSpan: "n: number", }, "contextualParameter2": { text: "cb(n: number, s: string, b: boolean): void", parameterCount: 3, - activeParameter: &lsproto.Nullable[uint32]{Value: 1}, + activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(1))}, parameterSpan: "s: string", }, "contextualParameter3": { text: "cb(n: number, s: string, b: boolean): void", parameterCount: 3, - activeParameter: &lsproto.Nullable[uint32]{Value: 2}, + activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(2))}, parameterSpan: "b: boolean", }, "contextualParameter3_2": { text: "cb(n: number, s: string, b: boolean): void", parameterCount: 3, - activeParameter: &lsproto.Nullable[uint32]{Value: 1}, + activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(1))}, parameterSpan: "s: string", }, "contextualParameter4": { text: "cb(n: number, s: string, b: boolean): void", parameterCount: 3, - activeParameter: &lsproto.Nullable[uint32]{Value: 3}, + activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(3))}, parameterSpan: "", }, "contextualTypeAlias": { text: "Cb(): void", parameterCount: 0, - activeParameter: &lsproto.Nullable[uint32]{Value: 0}, + activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}, parameterSpan: "", }, "contextualFunctionType": { text: "cb2(): void", parameterCount: 0, - activeParameter: &lsproto.Nullable[uint32]{Value: 0}, + activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}, parameterSpan: "", }, }, @@ -159,13 +159,13 @@ anonymousFunctionTest(5, "")(/*anonymousFunction1*/1, /*anonymousFunction2*/""); "anonymousFunction1": { text: `(a: number, b: string): string`, parameterCount: 2, - activeParameter: &lsproto.Nullable[uint32]{Value: 0}, + activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}, parameterSpan: "a: number", }, "anonymousFunction2": { text: `(a: number, b: string): string`, parameterCount: 2, - activeParameter: &lsproto.Nullable[uint32]{Value: 1}, + activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(1))}, parameterSpan: "b: string", }, }, @@ -180,7 +180,7 @@ Foo(/**/`, "": { text: "Foo(arg1: string, arg2: string): void", parameterCount: 2, - activeParameter: &lsproto.Nullable[uint32]{Value: 0}, + activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}, parameterSpan: "arg1: string", }, }, @@ -195,7 +195,7 @@ Foo(/**/;`, "": { text: "Foo(arg1: string, arg2: string): void", parameterCount: 2, - activeParameter: &lsproto.Nullable[uint32]{Value: 0}, + activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}, parameterSpan: "arg1: string", }, }, @@ -208,13 +208,13 @@ fnTest(/*1*/'', /*2*/5);`, "1": { text: `fnTest(str: string, num: number): void`, parameterCount: 2, - activeParameter: &lsproto.Nullable[uint32]{Value: 0}, + activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}, parameterSpan: "str: string", }, "2": { text: `fnTest(str: string, num: number): void`, parameterCount: 2, - activeParameter: &lsproto.Nullable[uint32]{Value: 1}, + activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(1))}, parameterSpan: "num: number", }, }, @@ -227,13 +227,13 @@ var x = new sampleCls(/*1*/"", /*2*/5);`, "1": { text: "sampleCls(str: string, num: number): sampleCls", parameterCount: 2, - activeParameter: &lsproto.Nullable[uint32]{Value: 0}, + activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}, parameterSpan: "str: string", }, "2": { text: "sampleCls(str: string, num: number): sampleCls", parameterCount: 2, - activeParameter: &lsproto.Nullable[uint32]{Value: 1}, + activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(1))}, parameterSpan: "num: number", }, }, @@ -256,7 +256,7 @@ class B3 extends B2 { "indirectSuperCall": { text: "B2(n: number): B2", parameterCount: 1, - activeParameter: &lsproto.Nullable[uint32]{Value: 0}, + activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}, parameterSpan: "n: number", }, }, @@ -270,12 +270,12 @@ var y = new clsOverload(/*2*/'');`, "1": { text: "clsOverload(): clsOverload", parameterCount: 0, - activeParameter: &lsproto.Nullable[uint32]{Value: 0}, + activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}, }, "2": { text: "clsOverload(test: string): clsOverload", parameterCount: 1, - activeParameter: &lsproto.Nullable[uint32]{Value: 0}, + activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}, parameterSpan: "test: string", }, }, @@ -292,13 +292,13 @@ var y = new clsOverload(/*2*/'');`, "1": { text: "Foo(arg1: string, arg2: string): void", parameterCount: 2, - activeParameter: &lsproto.Nullable[uint32]{Value: 0}, + activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}, parameterSpan: "arg1: string", }, "2": { text: "Bar(arg1: string, arg2: string): void", parameterCount: 1, - activeParameter: &lsproto.Nullable[uint32]{Value: 0}, + activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}, parameterSpan: "T", }, }, @@ -317,19 +317,19 @@ complex("ok", "ok", e => void e, {}, /*3*/);`, "1": { text: "complex(item: string, another: string): void", parameterCount: 2, - activeParameter: &lsproto.Nullable[uint32]{Value: 0}, + activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}, parameterSpan: "item: string", }, "2": { text: "complex(item: string, another: string, settings: object, errorHandler: (err: Error) => void): void", parameterCount: 4, - activeParameter: &lsproto.Nullable[uint32]{Value: 2}, + activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(2))}, parameterSpan: "settings: object", }, "3": { text: "complex(item: string, another: string, errorHandler: (err: Error) => void, ...mixins: object[]): void", parameterCount: 4, - activeParameter: &lsproto.Nullable[uint32]{Value: 3}, + activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(3))}, parameterSpan: "...mixins: object[]", }, }, @@ -347,19 +347,19 @@ complex("ok", "ok", e => void e, {}, /*3*/);`, "1": { text: "complex(item: string, another: string): void", parameterCount: 2, - activeParameter: &lsproto.Nullable[uint32]{Value: 0}, + activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}, parameterSpan: "item: string", }, "2": { text: "complex(item: string, another: string, rest_0: object, rest_1: (err: Error) => void): void", parameterCount: 4, - activeParameter: &lsproto.Nullable[uint32]{Value: 2}, + activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(2))}, parameterSpan: "rest_0: object", }, "3": { text: "complex(item: string, another: string, rest_0: (err: Error) => void, ...rest: object[]): void", parameterCount: 4, - activeParameter: &lsproto.Nullable[uint32]{Value: 3}, + activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(3))}, parameterSpan: "...rest: object[]", }, }, @@ -378,49 +378,49 @@ foo(123/*6*/, ""/*7*/, ""/*8*/)`, "1": { text: "foo(args_0: string, args_1: string): void", parameterCount: 2, - activeParameter: &lsproto.Nullable[uint32]{Value: 0}, + activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}, parameterSpan: "args_0: string", }, "2": { text: "foo(args_0: string, args_1: string): void", parameterCount: 2, - activeParameter: &lsproto.Nullable[uint32]{Value: 0}, + activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}, parameterSpan: "args_0: string", }, "3": { text: "foo(args_0: string, args_1: string): void", parameterCount: 2, - activeParameter: &lsproto.Nullable[uint32]{Value: 1}, + activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(1))}, parameterSpan: "args_1: string", }, "4": { text: "foo(args_0: number, args_1: string, args_2: string): void", parameterCount: 3, - activeParameter: &lsproto.Nullable[uint32]{Value: 0}, + activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}, parameterSpan: "args_0: number", }, "5": { text: "foo(args_0: number, args_1: string, args_2: string): void", parameterCount: 3, - activeParameter: &lsproto.Nullable[uint32]{Value: 1}, + activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(1))}, parameterSpan: "args_1: string", }, "6": { text: "foo(args_0: number, args_1: string, args_2: string): void", parameterCount: 3, - activeParameter: &lsproto.Nullable[uint32]{Value: 0}, + activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}, parameterSpan: "args_0: number", }, "7": { text: "foo(args_0: number, args_1: string, args_2: string): void", parameterCount: 3, - activeParameter: &lsproto.Nullable[uint32]{Value: 1}, + activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(1))}, parameterSpan: "args_1: string", }, "8": { text: "foo(args_0: number, args_1: string, args_2: string): void", parameterCount: 3, - activeParameter: &lsproto.Nullable[uint32]{Value: 2}, + activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(2))}, parameterSpan: "args_2: string", }, }, @@ -445,21 +445,21 @@ g(/*8*/); h(/*9*/); j(/*10*/);`, expected: map[string]verifySignatureHelpOptions{ - "1": {text: "f(x: number, y: string): number", parameterCount: 2, activeParameter: &lsproto.Nullable[uint32]{Value: 0}, parameterSpan: "x: number"}, - "2": {text: "f(x: boolean, y: string): boolean", parameterCount: 2, parameterSpan: "x: boolean", activeParameter: &lsproto.Nullable[uint32]{Value: 0}}, + "1": {text: "f(x: number, y: string): number", parameterCount: 2, activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}, parameterSpan: "x: number"}, + "2": {text: "f(x: boolean, y: string): boolean", parameterCount: 2, parameterSpan: "x: boolean", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}}, // too few -- fill in rest with default - "3": {text: "f(x: number, y: string): number", parameterCount: 2, parameterSpan: "x: number", activeParameter: &lsproto.Nullable[uint32]{Value: 0}}, + "3": {text: "f(x: number, y: string): number", parameterCount: 2, parameterSpan: "x: number", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}}, // too many -- ignore extra type arguments - "4": {text: "f(x: number, y: string): number", parameterCount: 2, parameterSpan: "x: number", activeParameter: &lsproto.Nullable[uint32]{Value: 0}}, + "4": {text: "f(x: number, y: string): number", parameterCount: 2, parameterSpan: "x: number", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}}, // not matched signature and no type arguments - "5": {text: "g(x: unknown, y: unknown, z: B): unknown", parameterCount: 3, parameterSpan: "x: unknown", activeParameter: &lsproto.Nullable[uint32]{Value: 0}}, - "6": {text: "h(x: unknown, y: unknown, z: A): unknown", parameterCount: 3, parameterSpan: "x: unknown", activeParameter: &lsproto.Nullable[uint32]{Value: 0}}, - "7": {text: "j(x: unknown, y: unknown, z: B): unknown", parameterCount: 3, parameterSpan: "x: unknown", activeParameter: &lsproto.Nullable[uint32]{Value: 0}}, + "5": {text: "g(x: unknown, y: unknown, z: B): unknown", parameterCount: 3, parameterSpan: "x: unknown", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}}, + "6": {text: "h(x: unknown, y: unknown, z: A): unknown", parameterCount: 3, parameterSpan: "x: unknown", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}}, + "7": {text: "j(x: unknown, y: unknown, z: B): unknown", parameterCount: 3, parameterSpan: "x: unknown", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}}, // not matched signature and too few type arguments - "8": {text: "g(x: number, y: unknown, z: B): number", parameterCount: 3, parameterSpan: "x: number", activeParameter: &lsproto.Nullable[uint32]{Value: 0}}, - "9": {text: "h(x: number, y: unknown, z: A): number", parameterCount: 3, parameterSpan: "x: number", activeParameter: &lsproto.Nullable[uint32]{Value: 0}}, - "10": {text: "j(x: number, y: unknown, z: B): number", parameterCount: 3, parameterSpan: "x: number", activeParameter: &lsproto.Nullable[uint32]{Value: 0}}, + "8": {text: "g(x: number, y: unknown, z: B): number", parameterCount: 3, parameterSpan: "x: number", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}}, + "9": {text: "h(x: number, y: unknown, z: A): number", parameterCount: 3, parameterSpan: "x: number", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}}, + "10": {text: "j(x: number, y: unknown, z: B): number", parameterCount: 3, parameterSpan: "x: number", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}}, }, }, { @@ -474,7 +474,7 @@ const o: Obj = { } };`, expected: map[string]verifySignatureHelpOptions{ - "1": {text: "optionalMethod(current: any): any", parameterCount: 1, parameterSpan: "current: any", activeParameter: &lsproto.Nullable[uint32]{Value: 0}}, + "1": {text: "optionalMethod(current: any): any", parameterCount: 1, parameterSpan: "current: any", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}}, }, }, { @@ -496,8 +496,8 @@ class C2 extends B2 { } }`, expected: map[string]verifySignatureHelpOptions{ - "1": {text: "B(): B", parameterCount: 0, parameterSpan: "", activeParameter: &lsproto.Nullable[uint32]{Value: 0}}, - "2": {text: "B2(x: number): B2", parameterCount: 1, parameterSpan: "x: number", activeParameter: &lsproto.Nullable[uint32]{Value: 0}}, + "1": {text: "B(): B", parameterCount: 0, parameterSpan: "", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}}, + "2": {text: "B2(x: number): B2", parameterCount: 1, parameterSpan: "x: number", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}}, }, }, { @@ -508,8 +508,8 @@ function functionOverload(test?: string) { } functionOverload(/*functionOverload1*/); functionOverload(""/*functionOverload2*/);`, expected: map[string]verifySignatureHelpOptions{ - "functionOverload1": {text: "functionOverload(): any", parameterCount: 0, parameterSpan: "", activeParameter: &lsproto.Nullable[uint32]{Value: 0}}, - "functionOverload2": {text: "functionOverload(test: string): any", parameterCount: 1, parameterSpan: "test: string", activeParameter: &lsproto.Nullable[uint32]{Value: 0}}, + "functionOverload1": {text: "functionOverload(): any", parameterCount: 0, parameterSpan: "", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}}, + "functionOverload2": {text: "functionOverload(test: string): any", parameterCount: 1, parameterSpan: "test: string", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}}, }, }, { @@ -518,8 +518,8 @@ functionOverload(""/*functionOverload2*/);`, callback(/*parameterFunction1*/5, /*parameterFunction2*/""); }`, expected: map[string]verifySignatureHelpOptions{ - "parameterFunction1": {text: "callback(a: number, b: string): void", parameterCount: 2, parameterSpan: "a: number", activeParameter: &lsproto.Nullable[uint32]{Value: 0}}, - "parameterFunction2": {text: "callback(a: number, b: string): void", parameterCount: 2, parameterSpan: "b: string", activeParameter: &lsproto.Nullable[uint32]{Value: 1}}, + "parameterFunction1": {text: "callback(a: number, b: string): void", parameterCount: 2, parameterSpan: "a: number", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}}, + "parameterFunction2": {text: "callback(a: number, b: string): void", parameterCount: 2, parameterSpan: "b: string", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(1))}}, }, }, { @@ -528,7 +528,7 @@ functionOverload(""/*functionOverload2*/);`, } var implicitConstructor = new ImplicitConstructor(/*1*/);`, expected: map[string]verifySignatureHelpOptions{ - "1": {text: "ImplicitConstructor(): ImplicitConstructor", parameterCount: 0, parameterSpan: "", activeParameter: &lsproto.Nullable[uint32]{Value: 0}}, + "1": {text: "ImplicitConstructor(): ImplicitConstructor", parameterCount: 0, parameterSpan: "", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}}, }, }, { @@ -537,7 +537,7 @@ var implicitConstructor = new ImplicitConstructor(/*1*/);`, forEach(/*1*/() => { });`, expected: map[string]verifySignatureHelpOptions{ - "1": {text: "forEach(f: () => void): any", parameterCount: 1, parameterSpan: "f: () => void", activeParameter: &lsproto.Nullable[uint32]{Value: 0}}, + "1": {text: "forEach(f: () => void): any", parameterCount: 1, parameterSpan: "f: () => void", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}}, }, }, { @@ -557,9 +557,9 @@ forEach(/*1*/() => { x.f3(5,/*incompleteCalls3*/ }`, expected: map[string]verifySignatureHelpOptions{ - "incompleteCalls1": {text: "f1(): void", parameterCount: 0, parameterSpan: "", activeParameter: &lsproto.Nullable[uint32]{Value: 0}}, - "incompleteCalls2": {text: "f2(n: number): number", parameterCount: 1, parameterSpan: "", activeParameter: &lsproto.Nullable[uint32]{Value: 1}}, - "incompleteCalls3": {text: "f3(n: number, s: string): string", parameterCount: 2, parameterSpan: "s: string", activeParameter: &lsproto.Nullable[uint32]{Value: 1}}, + "incompleteCalls1": {text: "f1(): void", parameterCount: 0, parameterSpan: "", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}}, + "incompleteCalls2": {text: "f2(n: number): number", parameterCount: 1, parameterSpan: "", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(1))}}, + "incompleteCalls3": {text: "f3(n: number, s: string): string", parameterCount: 2, parameterSpan: "s: string", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(1))}}, }, }, { @@ -568,7 +568,7 @@ forEach(/*1*/() => { } foo(/*1*/`, expected: map[string]verifySignatureHelpOptions{ - "1": {text: "foo(x: number, callback: (x: unknown) => number): void", parameterCount: 2, parameterSpan: "x: number", activeParameter: &lsproto.Nullable[uint32]{Value: 0}}, + "1": {text: "foo(x: number, callback: (x: unknown) => number): void", parameterCount: 2, parameterSpan: "x: number", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}}, }, }, { @@ -576,7 +576,7 @@ foo(/*1*/`, input: `declare function f(a: T, b: T, c: T): void; f("x", /**/);`, expected: map[string]verifySignatureHelpOptions{ - "": {text: `f(a: "x", b: "x", c: "x"): void`, parameterCount: 3, parameterSpan: `b: "x"`, activeParameter: &lsproto.Nullable[uint32]{Value: 1}}, + "": {text: `f(a: "x", b: "x", c: "x"): void`, parameterCount: 3, parameterSpan: `b: "x"`, activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(1))}}, }, }, { @@ -585,8 +585,8 @@ f("x", /**/);`, (new base(/*1*/ (new base(0, /*2*/`, expected: map[string]verifySignatureHelpOptions{ - "1": {text: "base(n: number, y: string): base", parameterCount: 2, parameterSpan: "n: number", activeParameter: &lsproto.Nullable[uint32]{Value: 0}}, - "2": {text: "base(n: number, y: string): base", parameterCount: 2, parameterSpan: "y: string", activeParameter: &lsproto.Nullable[uint32]{Value: 1}}, + "1": {text: "base(n: number, y: string): base", parameterCount: 2, parameterSpan: "n: number", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}}, + "2": {text: "base(n: number, y: string): base", parameterCount: 2, parameterSpan: "y: string", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(1))}}, }, }, { @@ -598,9 +598,9 @@ leading(/*1*/); leading("ok", /*2*/); leading("ok", "ok", /*3*/);`, expected: map[string]verifySignatureHelpOptions{ - "1": {text: "leading(...names: string[], allCaps: boolean): void", parameterCount: 2, parameterSpan: "allCaps: boolean", activeParameter: &lsproto.Nullable[uint32]{Value: 1}}, - "2": {text: "leading(...names: string[], allCaps: boolean): void", parameterCount: 2, parameterSpan: "allCaps: boolean", activeParameter: &lsproto.Nullable[uint32]{Value: 1}}, - "3": {text: "leading(...names: string[], allCaps: boolean): void", parameterCount: 2, parameterSpan: "allCaps: boolean", activeParameter: &lsproto.Nullable[uint32]{Value: 1}}, + "1": {text: "leading(...names: string[], allCaps: boolean): void", parameterCount: 2, parameterSpan: "allCaps: boolean", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(1))}}, + "2": {text: "leading(...names: string[], allCaps: boolean): void", parameterCount: 2, parameterSpan: "allCaps: boolean", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(1))}}, + "3": {text: "leading(...names: string[], allCaps: boolean): void", parameterCount: 2, parameterSpan: "allCaps: boolean", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(1))}}, }, }, { @@ -609,7 +609,7 @@ leading("ok", "ok", /*3*/);`, } foo(/**/`, expected: map[string]verifySignatureHelpOptions{ - "": {text: "foo(n: number): string", parameterCount: 1, parameterSpan: "n: number", activeParameter: &lsproto.Nullable[uint32]{Value: 0}}, + "": {text: "foo(n: number): string", parameterCount: 1, parameterSpan: "n: number", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}}, }, }, { @@ -617,8 +617,8 @@ foo(/**/`, input: `var objectLiteral = { n: 5, s: "", f: (a: number, b: string) => "" }; objectLiteral.f(/*objectLiteral1*/4, /*objectLiteral2*/"");`, expected: map[string]verifySignatureHelpOptions{ - "objectLiteral1": {text: "f(a: number, b: string): string", parameterCount: 2, parameterSpan: "a: number", activeParameter: &lsproto.Nullable[uint32]{Value: 0}}, - "objectLiteral2": {text: "f(a: number, b: string): string", parameterCount: 2, parameterSpan: "b: string", activeParameter: &lsproto.Nullable[uint32]{Value: 1}}, + "objectLiteral1": {text: "f(a: number, b: string): string", parameterCount: 2, parameterSpan: "a: number", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}}, + "objectLiteral2": {text: "f(a: number, b: string): string", parameterCount: 2, parameterSpan: "b: string", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(1))}}, }, }, { @@ -630,8 +630,8 @@ declare function fn2(x: string, y: number); fn('', fn2(/*1*/ fn2('', fn2('',/*2*/`, expected: map[string]verifySignatureHelpOptions{ - "1": {text: "fn2(x: string): any", parameterCount: 1, parameterSpan: "x: string", activeParameter: &lsproto.Nullable[uint32]{Value: 0}}, - "2": {text: "fn2(x: string, y: number): any", parameterCount: 2, parameterSpan: "y: number", activeParameter: &lsproto.Nullable[uint32]{Value: 1}}, + "1": {text: "fn2(x: string): any", parameterCount: 1, parameterSpan: "x: string", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}}, + "2": {text: "fn2(x: string, y: number): any", parameterCount: 2, parameterSpan: "y: number", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(1))}}, }, }, { @@ -646,9 +646,9 @@ x1(''/*1*/); x1('hi'/*2*/); x1('bye'/*3*/);`, expected: map[string]verifySignatureHelpOptions{ - "1": {text: `x1(z: string): any`, parameterCount: 1, parameterSpan: "z: string", activeParameter: &lsproto.Nullable[uint32]{Value: 0}}, - "2": {text: `x1(x: "hi"): any`, parameterCount: 1, parameterSpan: `x: "hi"`, activeParameter: &lsproto.Nullable[uint32]{Value: 0}}, - "3": {text: `x1(y: "bye"): any`, parameterCount: 1, parameterSpan: `y: "bye"`, activeParameter: &lsproto.Nullable[uint32]{Value: 0}}, + "1": {text: `x1(z: string): any`, parameterCount: 1, parameterSpan: "z: string", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}}, + "2": {text: `x1(x: "hi"): any`, parameterCount: 1, parameterSpan: `x: "hi"`, activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}}, + "3": {text: `x1(y: "bye"): any`, parameterCount: 1, parameterSpan: `y: "bye"`, activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}}, }, }, { @@ -658,8 +658,8 @@ declare function fn(x: string, y: number); fn(/*1*/ fn('',/*2*/)`, expected: map[string]verifySignatureHelpOptions{ - "1": {text: "fn(x: string): any", parameterCount: 1, parameterSpan: "x: string", activeParameter: &lsproto.Nullable[uint32]{Value: 0}}, - "2": {text: "fn(x: string, y: number): any", parameterCount: 2, parameterSpan: "y: number", activeParameter: &lsproto.Nullable[uint32]{Value: 1}}, + "1": {text: "fn(x: string): any", parameterCount: 1, parameterSpan: "x: string", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}}, + "2": {text: "fn(x: string, y: number): any", parameterCount: 2, parameterSpan: "y: number", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(1))}}, }, }, { @@ -670,7 +670,7 @@ declare function f(s: string, b: boolean); declare function f(n: number, b: boolean) f(1/*1*/`, expected: map[string]verifySignatureHelpOptions{ - "1": {text: "f(n: number): any", parameterCount: 1, parameterSpan: "n: number", activeParameter: &lsproto.Nullable[uint32]{Value: 0}}, + "1": {text: "f(n: number): any", parameterCount: 1, parameterSpan: "n: number", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}}, }, }, { @@ -681,7 +681,7 @@ declare function f(s: string, b: boolean); declare function f(n: number, b: boolean) f(1, /*1*/`, expected: map[string]verifySignatureHelpOptions{ - "1": {text: "f(n: number, b: boolean): any", parameterCount: 2, parameterSpan: "b: boolean", activeParameter: &lsproto.Nullable[uint32]{Value: 1}}, + "1": {text: "f(n: number, b: boolean): any", parameterCount: 2, parameterSpan: "b: boolean", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(1))}}, }, }, { @@ -693,7 +693,7 @@ declare function f(n: number, b: boolean); f(1/*1*/ var`, expected: map[string]verifySignatureHelpOptions{ - "1": {text: "f(n: number): any", parameterCount: 1, parameterSpan: "n: number", activeParameter: &lsproto.Nullable[uint32]{Value: 0}}, + "1": {text: "f(n: number): any", parameterCount: 1, parameterSpan: "n: number", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}}, }, }, { @@ -705,7 +705,7 @@ declare function f(n: number, b: boolean); f(1, /*1*/var`, expected: map[string]verifySignatureHelpOptions{ - "1": {text: "f(n: number, b: boolean): any", parameterCount: 2, parameterSpan: "b: boolean", activeParameter: &lsproto.Nullable[uint32]{Value: 1}}, + "1": {text: "f(n: number, b: boolean): any", parameterCount: 2, parameterSpan: "b: boolean", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(1))}}, }, }, { @@ -717,7 +717,7 @@ declare function f(n: number, b: boolean); f(/*1*/`, expected: map[string]verifySignatureHelpOptions{ - "1": {text: "f(): any", parameterCount: 0, parameterSpan: "", activeParameter: &lsproto.Nullable[uint32]{Value: 0}}, + "1": {text: "f(): any", parameterCount: 0, parameterSpan: "", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}}, }, }, { @@ -729,7 +729,7 @@ declare function f(n: number, b: boolean); f(x, /*1*/`, expected: map[string]verifySignatureHelpOptions{ - "1": {text: "f(s: string, b: boolean): any", parameterCount: 2, parameterSpan: "b: boolean", activeParameter: &lsproto.Nullable[uint32]{Value: 1}}, + "1": {text: "f(s: string, b: boolean): any", parameterCount: 2, parameterSpan: "b: boolean", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(1))}}, }, }, { @@ -742,7 +742,7 @@ class C extends B { } }`, expected: map[string]verifySignatureHelpOptions{ - "1": {text: "B(x: string): B", parameterCount: 1, parameterSpan: "x: string", activeParameter: &lsproto.Nullable[uint32]{Value: 0}}, + "1": {text: "B(x: string): B", parameterCount: 1, parameterSpan: "x: string", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}}, }, }, { @@ -754,9 +754,9 @@ f1(/*1*/) f2(/*2*/) f3(/*3*/)`, expected: map[string]verifySignatureHelpOptions{ - "1": {text: "f1(a: any): a is number", parameterCount: 1, parameterSpan: "a: any", activeParameter: &lsproto.Nullable[uint32]{Value: 0}}, - "2": {text: "f2(a: any): a is unknown", parameterCount: 1, parameterSpan: "a: any", activeParameter: &lsproto.Nullable[uint32]{Value: 0}}, - "3": {text: "f3(a: any, ...b: any[]): a is number", parameterCount: 2, parameterSpan: "a: any", activeParameter: &lsproto.Nullable[uint32]{Value: 0}}, + "1": {text: "f1(a: any): a is number", parameterCount: 1, parameterSpan: "a: any", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}}, + "2": {text: "f2(a: any): a is unknown", parameterCount: 1, parameterSpan: "a: any", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}}, + "3": {text: "f3(a: any, ...b: any[]): a is number", parameterCount: 2, parameterSpan: "a: any", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}}, }, }, { @@ -764,7 +764,7 @@ f3(/*3*/)`, input: `function fnTest(str: string, num: number) { } fnTest?.(/*1*/);`, expected: map[string]verifySignatureHelpOptions{ - "1": {text: "fnTest(str: string, num: number): void", parameterCount: 2, parameterSpan: "str: string", activeParameter: &lsproto.Nullable[uint32]{Value: 0}}, + "1": {text: "fnTest(str: string, num: number): void", parameterCount: 2, parameterSpan: "str: string", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}}, }, }, { @@ -775,8 +775,8 @@ fnTest?.(/*1*/);`, } var x = new ConstructorCall(/*constructorCall1*/1,/*constructorCall2*/2);`, expected: map[string]verifySignatureHelpOptions{ - "constructorCall1": {text: "ConstructorCall(str: string, num: number): ConstructorCall", parameterCount: 2, parameterSpan: "str: string", activeParameter: &lsproto.Nullable[uint32]{Value: 0}}, - "constructorCall2": {text: "ConstructorCall(str: string, num: number): ConstructorCall", parameterCount: 2, parameterSpan: "num: number", activeParameter: &lsproto.Nullable[uint32]{Value: 1}}, + "constructorCall1": {text: "ConstructorCall(str: string, num: number): ConstructorCall", parameterCount: 2, parameterSpan: "str: string", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}}, + "constructorCall2": {text: "ConstructorCall(str: string, num: number): ConstructorCall", parameterCount: 2, parameterSpan: "num: number", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(1))}}, }, }, { @@ -786,8 +786,8 @@ var x = new ConstructorCall(/*constructorCall1*/1,/*constructorCall2*/2);`, functionCall(/*functionCall1*/); functionCall("", /*functionCall2*/1);`, expected: map[string]verifySignatureHelpOptions{ - "functionCall1": {text: "functionCall(str: string, num: number): void", parameterCount: 2, parameterSpan: "str: string", activeParameter: &lsproto.Nullable[uint32]{Value: 0}}, - "functionCall2": {text: "functionCall(str: string, num: number): void", parameterCount: 2, parameterSpan: "num: number", activeParameter: &lsproto.Nullable[uint32]{Value: 1}}, + "functionCall1": {text: "functionCall(str: string, num: number): void", parameterCount: 2, parameterSpan: "str: string", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}}, + "functionCall2": {text: "functionCall(str: string, num: number): void", parameterCount: 2, parameterSpan: "num: number", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(1))}}, }, }, { @@ -802,7 +802,7 @@ class SuperCall extends SuperCallBase { } }`, expected: map[string]verifySignatureHelpOptions{ - "superCall": {text: "SuperCallBase(b: boolean): SuperCallBase", parameterCount: 1, parameterSpan: "b: boolean", activeParameter: &lsproto.Nullable[uint32]{Value: 0}}, + "superCall": {text: "SuperCallBase(b: boolean): SuperCallBase", parameterCount: 1, parameterSpan: "b: boolean", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}}, }, }, { @@ -824,8 +824,8 @@ class SuperOverLoad2 extends SuperOverloadBase { } }`, expected: map[string]verifySignatureHelpOptions{ - "superOverload1": {text: "SuperOverloadBase(): SuperOverloadBase", parameterCount: 0, parameterSpan: "", activeParameter: &lsproto.Nullable[uint32]{Value: 0}}, - "superOverload2": {text: "SuperOverloadBase(test: string): SuperOverloadBase", parameterCount: 1, parameterSpan: "test: string", activeParameter: &lsproto.Nullable[uint32]{Value: 0}}, + "superOverload1": {text: "SuperOverloadBase(): SuperOverloadBase", parameterCount: 0, parameterSpan: "", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}}, + "superOverload2": {text: "SuperOverloadBase(test: string): SuperOverloadBase", parameterCount: 1, parameterSpan: "test: string", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}}, }, }, { @@ -837,9 +837,9 @@ leading(/*1*/); leading(false, /*2*/); leading(false, "ok", /*3*/);`, expected: map[string]verifySignatureHelpOptions{ - "1": {text: "leading(allCaps: boolean, ...names: string[]): void", parameterCount: 2, parameterSpan: "allCaps: boolean", activeParameter: &lsproto.Nullable[uint32]{Value: 0}}, - "2": {text: "leading(allCaps: boolean, ...names: string[]): void", parameterCount: 2, parameterSpan: "...names: string[]", activeParameter: &lsproto.Nullable[uint32]{Value: 1}}, - "3": {text: "leading(allCaps: boolean, ...names: string[]): void", parameterCount: 2, parameterSpan: "...names: string[]", activeParameter: &lsproto.Nullable[uint32]{Value: 1}}, + "1": {text: "leading(allCaps: boolean, ...names: string[]): void", parameterCount: 2, parameterSpan: "allCaps: boolean", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}}, + "2": {text: "leading(allCaps: boolean, ...names: string[]): void", parameterCount: 2, parameterSpan: "...names: string[]", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(1))}}, + "3": {text: "leading(allCaps: boolean, ...names: string[]): void", parameterCount: 2, parameterSpan: "...names: string[]", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(1))}}, }, }, { @@ -847,7 +847,7 @@ leading(false, "ok", /*3*/);`, input: `function foo(a) { } foo(hello my name /**/is`, expected: map[string]verifySignatureHelpOptions{ - "": {text: "foo(a: any): void", parameterCount: 1, parameterSpan: "", activeParameter: &lsproto.Nullable[uint32]{Value: 2}}, + "": {text: "foo(a: any): void", parameterCount: 1, parameterSpan: "", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(2))}}, }, }, { @@ -857,18 +857,18 @@ const a: Type = (a/*1*/, b/*2*/) => {} const b: Type = function (a/*3*/, b/*4*/) {} const c: Type = ({ /*5*/a: { b/*6*/ }}/*7*/ = { }/*8*/, [b/*9*/]/*10*/, .../*11*/c/*12*/) => {}`, expected: map[string]verifySignatureHelpOptions{ - "1": {text: "Type(a: any, b: any, c: any): void", parameterCount: 3, parameterSpan: "a: any", activeParameter: &lsproto.Nullable[uint32]{Value: 0}}, - "2": {text: "Type(a: any, b: any, c: any): void", parameterCount: 3, parameterSpan: "b: any", activeParameter: &lsproto.Nullable[uint32]{Value: 1}}, - "3": {text: "Type(a: any, b: any, c: any): void", parameterCount: 3, parameterSpan: "a: any", activeParameter: &lsproto.Nullable[uint32]{Value: 0}}, - "4": {text: "Type(a: any, b: any, c: any): void", parameterCount: 3, parameterSpan: "b: any", activeParameter: &lsproto.Nullable[uint32]{Value: 1}}, - "5": {text: "Type(a: any, b: any, c: any): void", parameterCount: 3, parameterSpan: "a: any", activeParameter: &lsproto.Nullable[uint32]{Value: 0}}, - "6": {text: "Type(a: any, b: any, c: any): void", parameterCount: 3, parameterSpan: "a: any", activeParameter: &lsproto.Nullable[uint32]{Value: 0}}, - "7": {text: "Type(a: any, b: any, c: any): void", parameterCount: 3, parameterSpan: "a: any", activeParameter: &lsproto.Nullable[uint32]{Value: 0}}, - "8": {text: "Type(a: any, b: any, c: any): void", parameterCount: 3, parameterSpan: "a: any", activeParameter: &lsproto.Nullable[uint32]{Value: 0}}, - "9": {text: "Type(a: any, b: any, c: any): void", parameterCount: 3, parameterSpan: "b: any", activeParameter: &lsproto.Nullable[uint32]{Value: 1}}, - "10": {text: "Type(a: any, b: any, c: any): void", parameterCount: 3, parameterSpan: "b: any", activeParameter: &lsproto.Nullable[uint32]{Value: 1}}, - "11": {text: "Type(a: any, b: any, c: any): void", parameterCount: 3, parameterSpan: "c: any", activeParameter: &lsproto.Nullable[uint32]{Value: 2}}, - "12": {text: "Type(a: any, b: any, c: any): void", parameterCount: 3, parameterSpan: "c: any", activeParameter: &lsproto.Nullable[uint32]{Value: 2}}, + "1": {text: "Type(a: any, b: any, c: any): void", parameterCount: 3, parameterSpan: "a: any", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}}, + "2": {text: "Type(a: any, b: any, c: any): void", parameterCount: 3, parameterSpan: "b: any", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(1))}}, + "3": {text: "Type(a: any, b: any, c: any): void", parameterCount: 3, parameterSpan: "a: any", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}}, + "4": {text: "Type(a: any, b: any, c: any): void", parameterCount: 3, parameterSpan: "b: any", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(1))}}, + "5": {text: "Type(a: any, b: any, c: any): void", parameterCount: 3, parameterSpan: "a: any", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}}, + "6": {text: "Type(a: any, b: any, c: any): void", parameterCount: 3, parameterSpan: "a: any", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}}, + "7": {text: "Type(a: any, b: any, c: any): void", parameterCount: 3, parameterSpan: "a: any", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}}, + "8": {text: "Type(a: any, b: any, c: any): void", parameterCount: 3, parameterSpan: "a: any", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}}, + "9": {text: "Type(a: any, b: any, c: any): void", parameterCount: 3, parameterSpan: "b: any", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(1))}}, + "10": {text: "Type(a: any, b: any, c: any): void", parameterCount: 3, parameterSpan: "b: any", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(1))}}, + "11": {text: "Type(a: any, b: any, c: any): void", parameterCount: 3, parameterSpan: "c: any", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(2))}}, + "12": {text: "Type(a: any, b: any, c: any): void", parameterCount: 3, parameterSpan: "c: any", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(2))}}, }, }, { @@ -884,11 +884,11 @@ function fnNoParams () { } var fnNoParamsWrapped = wrap(fnNoParams); fnNoParamsWrapped(/*5*/);`, expected: map[string]verifySignatureHelpOptions{ - "1": {text: "fnWrapped(str: string, num: number): void", parameterCount: 2, parameterSpan: "str: string", activeParameter: &lsproto.Nullable[uint32]{Value: 0}}, - "2": {text: "fnWrapped(str: string, num: number): void", parameterCount: 2, parameterSpan: "num: number", activeParameter: &lsproto.Nullable[uint32]{Value: 1}}, - "3": {text: "fnVariadicWrapped(str: string, ...num: number[]): void", parameterCount: 2, parameterSpan: "str: string", activeParameter: &lsproto.Nullable[uint32]{Value: 0}}, - "4": {text: "fnVariadicWrapped(str: string, ...num: number[]): void", parameterCount: 2, parameterSpan: "...num: number[]", activeParameter: &lsproto.Nullable[uint32]{Value: 1}}, - "5": {text: "fnNoParamsWrapped(): void", parameterCount: 0, parameterSpan: "", activeParameter: &lsproto.Nullable[uint32]{Value: 0}}, + "1": {text: "fnWrapped(str: string, num: number): void", parameterCount: 2, parameterSpan: "str: string", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}}, + "2": {text: "fnWrapped(str: string, num: number): void", parameterCount: 2, parameterSpan: "num: number", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(1))}}, + "3": {text: "fnVariadicWrapped(str: string, ...num: number[]): void", parameterCount: 2, parameterSpan: "str: string", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}}, + "4": {text: "fnVariadicWrapped(str: string, ...num: number[]): void", parameterCount: 2, parameterSpan: "...num: number[]", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(1))}}, + "5": {text: "fnNoParamsWrapped(): void", parameterCount: 0, parameterSpan: "", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}}, }, }, { @@ -899,7 +899,7 @@ fnNoParamsWrapped(/*5*/);`, } var a = new Circle(/**/`, expected: map[string]verifySignatureHelpOptions{ - "": {text: "Circle(radius: number): Circle", parameterCount: 1, parameterSpan: "radius: number", activeParameter: &lsproto.Nullable[uint32]{Value: 0}}, + "": {text: "Circle(radius: number): Circle", parameterCount: 1, parameterSpan: "radius: number", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}}, }, }, { @@ -916,7 +916,7 @@ type _Reverse = { type Foo = Reverse<[0,/**/]>;`, expected: map[string]verifySignatureHelpOptions{ - "": {text: "Reverse", parameterCount: 1, parameterSpan: "List extends any[]", activeParameter: &lsproto.Nullable[uint32]{Value: 0}}, + "": {text: "Reverse", parameterCount: 1, parameterSpan: "List extends any[]", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}}, }, }, { @@ -931,11 +931,11 @@ fn(/*2*/, ...a); fn(...b, /*3*/); fn(/*4*/, ...b, /*5*/);`, expected: map[string]verifySignatureHelpOptions{ - "1": {text: "fn(a: number, b: number, c: number): void", parameterCount: 3, parameterSpan: "c: number", activeParameter: &lsproto.Nullable[uint32]{Value: 2}}, - "2": {text: "fn(a: number, b: number, c: number): void", parameterCount: 3, parameterSpan: "a: number", activeParameter: &lsproto.Nullable[uint32]{Value: 0}}, - "3": {text: "fn(a: number, b: number, c: number): void", parameterCount: 3, parameterSpan: "b: number", activeParameter: &lsproto.Nullable[uint32]{Value: 1}}, - "4": {text: "fn(a: number, b: number, c: number): void", parameterCount: 3, parameterSpan: "a: number", activeParameter: &lsproto.Nullable[uint32]{Value: 0}}, - "5": {text: "fn(a: number, b: number, c: number): void", parameterCount: 3, parameterSpan: "c: number", activeParameter: &lsproto.Nullable[uint32]{Value: 2}}, + "1": {text: "fn(a: number, b: number, c: number): void", parameterCount: 3, parameterSpan: "c: number", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(2))}}, + "2": {text: "fn(a: number, b: number, c: number): void", parameterCount: 3, parameterSpan: "a: number", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}}, + "3": {text: "fn(a: number, b: number, c: number): void", parameterCount: 3, parameterSpan: "b: number", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(1))}}, + "4": {text: "fn(a: number, b: number, c: number): void", parameterCount: 3, parameterSpan: "a: number", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}}, + "5": {text: "fn(a: number, b: number, c: number): void", parameterCount: 3, parameterSpan: "c: number", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(2))}}, }, }, { @@ -943,11 +943,11 @@ fn(/*4*/, ...b, /*5*/);`, input: `function fn(a: number, b: number, c: number) {} fn(/*1*/, /*2*/, /*3*/, /*4*/, /*5*/);`, expected: map[string]verifySignatureHelpOptions{ - "1": {text: "fn(a: number, b: number, c: number): void", parameterCount: 3, parameterSpan: "a: number", activeParameter: &lsproto.Nullable[uint32]{Value: 0}}, - "2": {text: "fn(a: number, b: number, c: number): void", parameterCount: 3, parameterSpan: "b: number", activeParameter: &lsproto.Nullable[uint32]{Value: 1}}, - "3": {text: "fn(a: number, b: number, c: number): void", parameterCount: 3, parameterSpan: "c: number", activeParameter: &lsproto.Nullable[uint32]{Value: 2}}, - "4": {text: "fn(a: number, b: number, c: number): void", parameterCount: 3, parameterSpan: "", activeParameter: &lsproto.Nullable[uint32]{Value: 3}}, - "5": {text: "fn(a: number, b: number, c: number): void", parameterCount: 3, parameterSpan: "", activeParameter: &lsproto.Nullable[uint32]{Value: 4}}, + "1": {text: "fn(a: number, b: number, c: number): void", parameterCount: 3, parameterSpan: "a: number", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}}, + "2": {text: "fn(a: number, b: number, c: number): void", parameterCount: 3, parameterSpan: "b: number", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(1))}}, + "3": {text: "fn(a: number, b: number, c: number): void", parameterCount: 3, parameterSpan: "c: number", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(2))}}, + "4": {text: "fn(a: number, b: number, c: number): void", parameterCount: 3, parameterSpan: "", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(3))}}, + "5": {text: "fn(a: number, b: number, c: number): void", parameterCount: 3, parameterSpan: "", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(4))}}, }, }, { @@ -969,12 +969,12 @@ new C(): void", parameterCount: 1, parameterSpan: "T extends number", activeParameter: &lsproto.Nullable[uint32]{Value: 0}}, - "f1": {text: "f(): void", parameterCount: 2, parameterSpan: "U", activeParameter: &lsproto.Nullable[uint32]{Value: 1}}, - "f2": {text: "f(): void", parameterCount: 3, parameterSpan: "V extends string", activeParameter: &lsproto.Nullable[uint32]{Value: 2}}, - "C0": {text: "C(): void", parameterCount: 1, parameterSpan: "T extends number", activeParameter: &lsproto.Nullable[uint32]{Value: 0}}, - "C1": {text: "C(): void", parameterCount: 2, parameterSpan: "U", activeParameter: &lsproto.Nullable[uint32]{Value: 1}}, - "C2": {text: "C(): void", parameterCount: 3, parameterSpan: "V extends string", activeParameter: &lsproto.Nullable[uint32]{Value: 2}}, + "f0": {text: "f(): void", parameterCount: 1, parameterSpan: "T extends number", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}}, + "f1": {text: "f(): void", parameterCount: 2, parameterSpan: "U", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(1))}}, + "f2": {text: "f(): void", parameterCount: 3, parameterSpan: "V extends string", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(2))}}, + "C0": {text: "C(): void", parameterCount: 1, parameterSpan: "T extends number", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}}, + "C1": {text: "C(): void", parameterCount: 2, parameterSpan: "U", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(1))}}, + "C2": {text: "C(): void", parameterCount: 3, parameterSpan: "V extends string", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(2))}}, }, }, { @@ -985,10 +985,10 @@ f(a: number, b: string, c: boolean): void", parameterCount: 4, parameterSpan: "T", activeParameter: &lsproto.Nullable[uint32]{Value: 0}}, - "f1": {text: "f(a: number, b: string, c: boolean): void", parameterCount: 4, parameterSpan: "U", activeParameter: &lsproto.Nullable[uint32]{Value: 1}}, - "f2": {text: "f(a: number, b: string, c: boolean): void", parameterCount: 4, parameterSpan: "V", activeParameter: &lsproto.Nullable[uint32]{Value: 2}}, - "f3": {text: "f(a: number, b: string, c: boolean): void", parameterCount: 4, parameterSpan: "W", activeParameter: &lsproto.Nullable[uint32]{Value: 3}}, + "f0": {text: "f(a: number, b: string, c: boolean): void", parameterCount: 4, parameterSpan: "T", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}}, + "f1": {text: "f(a: number, b: string, c: boolean): void", parameterCount: 4, parameterSpan: "U", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(1))}}, + "f2": {text: "f(a: number, b: string, c: boolean): void", parameterCount: 4, parameterSpan: "V", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(2))}}, + "f3": {text: "f(a: number, b: string, c: boolean): void", parameterCount: 4, parameterSpan: "W", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(3))}}, }, }, { @@ -996,14 +996,14 @@ f(1, 2);`, expected: map[string]verifySignatureHelpOptions{ - "1": {text: "f<>(a: any, ...b: any[]): any", parameterCount: 0, parameterSpan: "", activeParameter: &lsproto.Nullable[uint32]{Value: 0}}, + "1": {text: "f<>(a: any, ...b: any[]): any", parameterCount: 0, parameterSpan: "", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}}, }, }, { title: "signatureHelpWithUnknown", input: `eval(\/*1*/`, expected: map[string]verifySignatureHelpOptions{ - "1": {text: "eval(x: string): any", parameterCount: 1, parameterSpan: "x: string", activeParameter: &lsproto.Nullable[uint32]{Value: 0}}, + "1": {text: "eval(x: string): any", parameterCount: 1, parameterSpan: "x: string", activeParameter: &lsproto.UintegerOrNull{Uinteger: ptrTo(uint32(0))}}, }, }, } @@ -1050,8 +1050,8 @@ func runSignatureHelpTest(t *testing.T, input string, expected map[string]verify assert.Equal(t, expectedResult.parameterCount, len(*result.Signatures[*result.ActiveSignature].Parameters)) assert.DeepEqual(t, expectedResult.activeParameter, result.ActiveParameter) // Checking the parameter span that will be highlighted in the editor - if expectedResult.activeParameter != nil && int(expectedResult.activeParameter.Value) < expectedResult.parameterCount { - assert.Equal(t, expectedResult.parameterSpan, *(*result.Signatures[*result.ActiveSignature].Parameters)[int(result.ActiveParameter.Value)].Label.String) + if expectedResult.activeParameter != nil && expectedResult.activeParameter.Uinteger != nil && int(*expectedResult.activeParameter.Uinteger) < expectedResult.parameterCount { + assert.Equal(t, expectedResult.parameterSpan, *(*result.Signatures[*result.ActiveSignature].Parameters)[int(*result.ActiveParameter.Uinteger)].Label.String) } } } diff --git a/internal/ls/symbols.go b/internal/ls/symbols.go index c227ca1a29..2a161d4f72 100644 --- a/internal/ls/symbols.go +++ b/internal/ls/symbols.go @@ -193,7 +193,7 @@ type DeclarationInfo struct { matchScore int } -func ProvideWorkspaceSymbols(ctx context.Context, programs []*compiler.Program, converters *Converters, query string) ([]lsproto.SymbolInformation, error) { +func ProvideWorkspaceSymbols(ctx context.Context, programs []*compiler.Program, converters *Converters, query string) ([]*lsproto.SymbolInformation, error) { // Obtain set of non-declaration source files from all active programs. var sourceFiles collections.Set[*ast.SourceFile] for _, program := range programs { @@ -207,7 +207,7 @@ func ProvideWorkspaceSymbols(ctx context.Context, programs []*compiler.Program, var infos []DeclarationInfo for sourceFile := range sourceFiles.Keys() { if ctx != nil && ctx.Err() != nil { - return []lsproto.SymbolInformation{}, nil + return []*lsproto.SymbolInformation{}, nil } declarationMap := sourceFile.GetDeclarationMap() for name, declarations := range declarationMap { @@ -222,7 +222,7 @@ func ProvideWorkspaceSymbols(ctx context.Context, programs []*compiler.Program, // Sort the DeclarationInfos and return the top 256 matches. slices.SortFunc(infos, compareDeclarationInfos) count := min(len(infos), 256) - symbols := make([]lsproto.SymbolInformation, count) + symbols := make([]*lsproto.SymbolInformation, count) for i, info := range infos[0:count] { node := core.OrElse(ast.GetNameOfDeclaration(info.declaration), info.declaration) sourceFile := ast.GetSourceFileOfNode(node) @@ -231,7 +231,7 @@ func ProvideWorkspaceSymbols(ctx context.Context, programs []*compiler.Program, symbol.Name = info.name symbol.Kind = getSymbolKindFromNode(info.declaration) symbol.Location = converters.ToLSPLocation(sourceFile, core.NewTextRange(pos, node.End())) - symbols[i] = symbol + symbols[i] = &symbol } return symbols, nil } diff --git a/internal/lsp/lsproto/_generate/generate.mts b/internal/lsp/lsproto/_generate/generate.mts index 5d5c25c260..7b2a19a63c 100644 --- a/internal/lsp/lsproto/_generate/generate.mts +++ b/internal/lsp/lsproto/_generate/generate.mts @@ -34,20 +34,22 @@ interface GoType { interface TypeInfo { types: Map; literalTypes: Map; - unionTypes: Map; + unionTypes: Map; + typeAliasMap: Map; } const typeInfo: TypeInfo = { types: new Map(), literalTypes: new Map(), unionTypes: new Map(), + typeAliasMap: new Map(), }; function titleCase(s: string) { return s.charAt(0).toUpperCase() + s.slice(1); } -function resolveType(type: Type): GoType { +function resolveType(type: Type, nullToPointer?: boolean): GoType { switch (type.kind) { case "base": switch (type.name) { @@ -65,6 +67,8 @@ function resolveType(type: Type): GoType { return { name: "DocumentUri", needsPointer: false }; case "decimal": return { name: "float64", needsPointer: false }; + case "null": + return { name: "any", needsPointer: false }; default: throw new Error(`Unsupported base type: ${type.name}`); } @@ -75,6 +79,12 @@ function resolveType(type: Type): GoType { return typeAliasOverride; } + // Check if this is a type alias that resolves to a union type + const aliasedType = typeInfo.typeAliasMap.get(type.name); + if (aliasedType) { + return resolveType(aliasedType); + } + let refType = typeInfo.types.get(type.name); if (!refType) { refType = { name: type.name, needsPointer: true }; @@ -141,7 +151,7 @@ function resolveType(type: Type): GoType { throw new Error("Unexpected non-empty literal object: " + JSON.stringify(type.value)); case "or": { - return handleOrType(type); + return handleOrType(type, nullToPointer); } default: @@ -149,34 +159,57 @@ function resolveType(type: Type): GoType { } } -function handleOrType(orType: OrType): GoType { - const types = orType.items; +function flattenOrTypes(types: Type[]): Type[] { + const flattened = new Set(); - // Check for nullable types (OR with null) - const nullIndex = types.findIndex(item => item.kind === "base" && item.name === "null"); + for (const rawType of types) { + let type = rawType; - // If it's nullable and only has one other type - if (nullIndex !== -1) { - if (types.length !== 2) { - throw new Error("Expected exactly two items in OR type for null handling: " + JSON.stringify(types)); + // Dereference reference types that point to OR types + if (rawType.kind === "reference") { + const aliasedType = typeInfo.typeAliasMap.get(rawType.name); + if (aliasedType && aliasedType.kind === "or") { + type = aliasedType; + } } - const otherType = types[1 - nullIndex]; - const resolvedType = resolveType(otherType); + if (type.kind === "or") { + // Recursively flatten OR types + for (const subType of flattenOrTypes(type.items)) { + flattened.add(subType); + } + } + else { + flattened.add(rawType); + } + } - // Use Nullable[T] instead of pointer for null union with one other type - return { - name: `Nullable[${resolvedType.name}]`, - needsPointer: false, - }; + return Array.from(flattened); +} + +function handleOrType(orType: OrType, nullToPointer: boolean | undefined): GoType { + // First, flatten any nested OR types + const types = flattenOrTypes(orType.items); + + // Check for nullable types (OR with null) + const nullIndex = types.findIndex(item => item.kind === "base" && item.name === "null"); + let containedNull = nullIndex !== -1; + + // If it's nullable, remove the null type from the list + let nonNullTypes = types; + if (containedNull) { + nonNullTypes = types.filter((_, i) => i !== nullIndex); } - // If only one type remains after filtering null - if (types.length === 1) { - return resolveType(types[0]); + // If no types remain after filtering null, this shouldn't happen + if (nonNullTypes.length === 0) { + throw new Error("Union type with only null is not supported: " + JSON.stringify(types)); } - const memberNames = types.map(type => { + // Even if only one type remains after filtering null, we still need to create a union type + // to preserve the nullable behavior (all fields nil = null) + + let memberNames = nonNullTypes.map(type => { if (type.kind === "reference") { return type.name; } @@ -189,6 +222,11 @@ function handleOrType(orType: OrType): GoType { ) { return `${titleCase(type.element.name)}s`; } + else if (type.kind === "array") { + // Handle more complex array types + const elementType = resolveType(type.element); + return `${elementType.name}Array`; + } else if (type.kind === "literal" && type.value.properties.length === 0) { return "EmptyObject"; } @@ -200,14 +238,95 @@ function handleOrType(orType: OrType): GoType { } }); - const unionTypeName = memberNames.join("Or"); - const union = memberNames.map((name, i) => ({ name, type: types[i] })); + const needsPointer = containedNull && !!nullToPointer; + + if (needsPointer && nonNullTypes.length === 1) { + const name = resolveType(nonNullTypes[0], true).name; + return { + name, + needsPointer: true, + }; + } + + // Find longest common prefix of member names chunked by PascalCase + function findLongestCommonPrefix(names: string[]): string { + if (names.length === 0) return ""; + if (names.length === 1) return ""; + + // Split each name into PascalCase chunks + function splitPascalCase(name: string): string[] { + const chunks: string[] = []; + let currentChunk = ""; + + for (let i = 0; i < name.length; i++) { + const char = name[i]; + if (char >= "A" && char <= "Z" && currentChunk.length > 0) { + // Start of a new chunk + chunks.push(currentChunk); + currentChunk = char; + } + else { + currentChunk += char; + } + } + + if (currentChunk.length > 0) { + chunks.push(currentChunk); + } + + return chunks; + } + + const allChunks = names.map(splitPascalCase); + const minChunkLength = Math.min(...allChunks.map(chunks => chunks.length)); + + // Find the longest common prefix of chunks + let commonChunks: string[] = []; + for (let i = 0; i < minChunkLength; i++) { + const chunk = allChunks[0][i]; + if (allChunks.every(chunks => chunks[i] === chunk)) { + commonChunks.push(chunk); + } + else { + break; + } + } + + return commonChunks.join(""); + } + + const commonPrefix = findLongestCommonPrefix(memberNames); + + let unionTypeName = ""; + + if (commonPrefix.length > 0) { + const trimmedMemberNames = memberNames.map(name => name.slice(commonPrefix.length)); + if (trimmedMemberNames.every(name => name)) { + unionTypeName = commonPrefix + trimmedMemberNames.join("Or"); + memberNames = trimmedMemberNames; + } + else { + unionTypeName = memberNames.join("Or"); + } + } + else { + unionTypeName = memberNames.join("Or"); + } + + if (containedNull && !nullToPointer) { + unionTypeName += "OrNull"; + } + else { + containedNull = false; + } + + const union = memberNames.map((name, i) => ({ name, type: nonNullTypes[i], containedNull })); typeInfo.unionTypes.set(unionTypeName, union); return { name: unionTypeName, - needsPointer: false, + needsPointer, }; } @@ -256,11 +375,8 @@ function collectTypeDefinitions() { continue; } - const resolvedType = resolveType(typeAlias.type); - typeInfo.types.set(typeAlias.name, { - name: typeAlias.name, - needsPointer: resolvedType.needsPointer, - }); + // Store the alias mapping so we can resolve it later + typeInfo.typeAliasMap.set(typeAlias.name, typeAlias.type); } } @@ -483,21 +599,6 @@ function generateCode() { writeLine(""); } - // Generate type aliases - writeLine("// Type aliases\n"); - - for (const typeAlias of model.typeAliases) { - if (typeAliasOverrides.has(typeAlias.name)) { - continue; - } - - write(formatDocumentation(typeAlias.documentation)); - - const resolvedType = resolveType(typeAlias.type); - writeLine(`type ${typeAlias.name} = ${resolvedType.name}`); - writeLine(""); - } - const requestsAndNotifications: (Request | Notification)[] = [...model.requests, ...model.notifications]; // Generate unmarshalParams function @@ -546,6 +647,49 @@ function generateCode() { writeLine(")"); writeLine(""); + // Generate request response types + writeLine("// Request response types"); + writeLine(""); + + for (const request of requestsAndNotifications) { + const methodName = methodNameIdentifier(request.method); + + let responseTypeName: string | undefined; + + if ("result" in request) { + if (request.typeName && request.typeName.endsWith("Request")) { + responseTypeName = request.typeName.replace(/Request$/, "Response"); + } + else { + responseTypeName = `${methodName}Response`; + } + + writeLine(`// Response type for \`${request.method}\``); + const resultType = resolveType(request.result, /*nullToPointer*/ true); + const goType = resultType.needsPointer ? `*${resultType.name}` : resultType.name; + + writeLine(`type ${responseTypeName} = ${goType}`); + writeLine(""); + } + + if (Array.isArray(request.params)) { + throw new Error("Unexpected request params for " + methodName + ": " + JSON.stringify(request.params)); + } + + const paramType = request.params ? resolveType(request.params) : undefined; + const paramGoType = paramType ? (paramType.needsPointer ? `*${paramType.name}` : paramType.name) : "any"; + + writeLine(`// Type mapping info for \`${request.method}\``); + if (responseTypeName) { + writeLine(`var ${methodName}Info = RequestInfo[${paramGoType}, ${responseTypeName}]{Method: Method${methodName}}`); + } + else { + writeLine(`var ${methodName}Info = NotificationInfo[${paramGoType}]{Method: Method${methodName}}`); + } + + writeLine(""); + } + // Generate union types writeLine("// Union types\n"); @@ -574,8 +718,12 @@ function generateCode() { // Marshal method writeLine(`func (o ${name}) MarshalJSON() ([]byte, error) {`); - // Create assertion to ensure only one field is set at a time - write(`\tassertOnlyOne("more than one element of ${name} is set", `); + // Determine if this union contained null (check if any member has containedNull = true) + const unionContainedNull = members.some(member => member.containedNull); + const assertionFunc = unionContainedNull ? "assertAtMostOne" : "assertOnlyOne"; + + // Create assertion to ensure at most one field is set at a time + write(`\t${assertionFunc}("more than one element of ${name} is set", `); // Write the assertion conditions for (let i = 0; i < fieldEntries.length; i++) { @@ -584,19 +732,37 @@ function generateCode() { } writeLine(`)`); writeLine(""); + for (const entry of fieldEntries) { writeLine(`\tif o.${entry.fieldName} != nil {`); writeLine(`\t\treturn json.Marshal(*o.${entry.fieldName})`); writeLine(`\t}`); } - writeLine(`\tpanic("unreachable")`); + // If all fields are nil, marshal as null (only for unions that can contain null) + if (unionContainedNull) { + writeLine(`\t// All fields are nil, represent as null`); + writeLine(`\treturn []byte("null"), nil`); + } + else { + writeLine(`\tpanic("unreachable")`); + } writeLine(`}`); writeLine(""); // Unmarshal method writeLine(`func (o *${name}) UnmarshalJSON(data []byte) error {`); writeLine(`\t*o = ${name}{}`); + writeLine(""); + + // Handle null case only for unions that can contain null + if (unionContainedNull) { + writeLine(`\t// Handle null case`); + writeLine(`\tif string(data) == "null" {`); + writeLine(`\t\treturn nil`); + writeLine(`\t}`); + writeLine(""); + } for (const entry of fieldEntries) { writeLine(`\tvar v${entry.fieldName} ${entry.typeName}`); diff --git a/internal/lsp/lsproto/lsp.go b/internal/lsp/lsproto/lsp.go index 32672dd894..8ccb31702b 100644 --- a/internal/lsp/lsproto/lsp.go +++ b/internal/lsp/lsproto/lsp.go @@ -13,35 +13,6 @@ type URI string // !!! type Method string -type Nullable[T any] struct { - Value T - Null bool -} - -func ToNullable[T any](v T) Nullable[T] { - return Nullable[T]{Value: v} -} - -func Null[T any]() Nullable[T] { - return Nullable[T]{Null: true} -} - -func (n Nullable[T]) MarshalJSON() ([]byte, error) { - if n.Null { - return []byte(`null`), nil - } - return json.Marshal(n.Value) -} - -func (n *Nullable[T]) UnmarshalJSON(data []byte) error { - *n = Nullable[T]{} - if string(data) == `null` { - n.Null = true - return nil - } - return json.Unmarshal(data, &n.Value) -} - func unmarshalPtrTo[T any](data []byte) (*T, error) { var v T if err := json.Unmarshal(data, &v); err != nil { @@ -77,6 +48,18 @@ func assertOnlyOne(message string, values ...bool) { } } +func assertAtMostOne(message string, values ...bool) { + count := 0 + for _, v := range values { + if v { + count++ + } + } + if count > 1 { + panic(message) + } +} + func ptrTo[T any](v T) *T { return &v } @@ -92,3 +75,16 @@ func (v *requiredProp) UnmarshalJSONFrom(dec *jsontext.Decoder) error { *v = true return dec.SkipValue() } + +// Inspired by https://www.youtube.com/watch?v=dab3I-HcTVk + +type RequestInfo[Params, Resp any] struct { + _ [0]Params + _ [0]Resp + Method Method +} + +type NotificationInfo[Params any] struct { + _ [0]Params + Method Method +} diff --git a/internal/lsp/lsproto/lsp_generated.go b/internal/lsp/lsproto/lsp_generated.go index b9ba4f1912..b78a76031f 100644 --- a/internal/lsp/lsproto/lsp_generated.go +++ b/internal/lsp/lsproto/lsp_generated.go @@ -344,7 +344,7 @@ type WorkDoneProgressOptions struct { type TextDocumentRegistrationOptions struct { // A document selector to identify the scope of the registration. If set to null // the document selector provided on the client side will be used. - DocumentSelector Nullable[DocumentSelector] `json:"documentSelector"` + DocumentSelector DocumentSelectorOrNull `json:"documentSelector"` } func (s *TextDocumentRegistrationOptions) UnmarshalJSON(data []byte) error { @@ -364,7 +364,7 @@ func (s *TextDocumentRegistrationOptions) UnmarshalJSON(data []byte) error { // Redeclare the struct to prevent infinite recursion type temp struct { - DocumentSelector Nullable[DocumentSelector] `json:"documentSelector"` + DocumentSelector DocumentSelectorOrNull `json:"documentSelector"` } return json.Unmarshal(data, (*temp)(s)) @@ -570,7 +570,7 @@ type SelectionRangeRegistrationOptions struct { type WorkDoneProgressCreateParams struct { // The token to be used to report progress. - Token ProgressToken `json:"token"` + Token IntegerOrString `json:"token"` } func (s *WorkDoneProgressCreateParams) UnmarshalJSON(data []byte) error { @@ -590,7 +590,7 @@ func (s *WorkDoneProgressCreateParams) UnmarshalJSON(data []byte) error { // Redeclare the struct to prevent infinite recursion type temp struct { - Token ProgressToken `json:"token"` + Token IntegerOrString `json:"token"` } return json.Unmarshal(data, (*temp)(s)) @@ -598,7 +598,7 @@ func (s *WorkDoneProgressCreateParams) UnmarshalJSON(data []byte) error { type WorkDoneProgressCancelParams struct { // The token to be used to report progress. - Token ProgressToken `json:"token"` + Token IntegerOrString `json:"token"` } func (s *WorkDoneProgressCancelParams) UnmarshalJSON(data []byte) error { @@ -618,7 +618,7 @@ func (s *WorkDoneProgressCancelParams) UnmarshalJSON(data []byte) error { // Redeclare the struct to prevent infinite recursion type temp struct { - Token ProgressToken `json:"token"` + Token IntegerOrString `json:"token"` } return json.Unmarshal(data, (*temp)(s)) @@ -1322,7 +1322,7 @@ type WorkspaceEdit struct { // Whether clients honor this property depends on the client capability `workspace.changeAnnotationSupport`. // // Since: 3.16.0 - ChangeAnnotations *map[ChangeAnnotationIdentifier]*ChangeAnnotation `json:"changeAnnotations,omitempty"` + ChangeAnnotations *map[string]*ChangeAnnotation `json:"changeAnnotations,omitempty"` } // The options to register for file operations. @@ -2008,7 +2008,7 @@ func (s *WorkspaceDiagnosticParams) UnmarshalJSON(data []byte) error { // // Since: 3.17.0 type WorkspaceDiagnosticReport struct { - Items []WorkspaceDocumentDiagnosticReport `json:"items"` + Items []WorkspaceFullDocumentDiagnosticReportOrUnchangedDocumentDiagnosticReport `json:"items"` } func (s *WorkspaceDiagnosticReport) UnmarshalJSON(data []byte) error { @@ -2028,7 +2028,7 @@ func (s *WorkspaceDiagnosticReport) UnmarshalJSON(data []byte) error { // Redeclare the struct to prevent infinite recursion type temp struct { - Items []WorkspaceDocumentDiagnosticReport `json:"items"` + Items []WorkspaceFullDocumentDiagnosticReportOrUnchangedDocumentDiagnosticReport `json:"items"` } return json.Unmarshal(data, (*temp)(s)) @@ -2038,7 +2038,7 @@ func (s *WorkspaceDiagnosticReport) UnmarshalJSON(data []byte) error { // // Since: 3.17.0 type WorkspaceDiagnosticReportPartialResult struct { - Items []WorkspaceDocumentDiagnosticReport `json:"items"` + Items []WorkspaceFullDocumentDiagnosticReportOrUnchangedDocumentDiagnosticReport `json:"items"` } func (s *WorkspaceDiagnosticReportPartialResult) UnmarshalJSON(data []byte) error { @@ -2058,7 +2058,7 @@ func (s *WorkspaceDiagnosticReportPartialResult) UnmarshalJSON(data []byte) erro // Redeclare the struct to prevent infinite recursion type temp struct { - Items []WorkspaceDocumentDiagnosticReport `json:"items"` + Items []WorkspaceFullDocumentDiagnosticReportOrUnchangedDocumentDiagnosticReport `json:"items"` } return json.Unmarshal(data, (*temp)(s)) @@ -2829,7 +2829,7 @@ type DidChangeTextDocumentParams struct { // - apply the 'textDocument/didChange' notifications in the order you receive them. // - apply the `TextDocumentContentChangeEvent`s in a single notification in the order // you receive them. - ContentChanges []TextDocumentContentChangeEvent `json:"contentChanges"` + ContentChanges []TextDocumentContentChangePartialOrWholeDocument `json:"contentChanges"` } func (s *DidChangeTextDocumentParams) UnmarshalJSON(data []byte) error { @@ -2853,8 +2853,8 @@ func (s *DidChangeTextDocumentParams) UnmarshalJSON(data []byte) error { // Redeclare the struct to prevent infinite recursion type temp struct { - TextDocument VersionedTextDocumentIdentifier `json:"textDocument"` - ContentChanges []TextDocumentContentChangeEvent `json:"contentChanges"` + TextDocument VersionedTextDocumentIdentifier `json:"textDocument"` + ContentChanges []TextDocumentContentChangePartialOrWholeDocument `json:"contentChanges"` } return json.Unmarshal(data, (*temp)(s)) @@ -3426,7 +3426,7 @@ type HoverParams struct { // The result of a hover request. type Hover struct { // The hover's content - Contents MarkupContentOrMarkedStringOrMarkedStrings `json:"contents"` + Contents MarkupContentOrStringOrMarkedStringWithLanguageOrMarkedStrings `json:"contents"` // An optional range inside the text document that is used to // visualize the hover, e.g. by changing the background color. @@ -3450,8 +3450,8 @@ func (s *Hover) UnmarshalJSON(data []byte) error { // Redeclare the struct to prevent infinite recursion type temp struct { - Contents MarkupContentOrMarkedStringOrMarkedStrings `json:"contents"` - Range *Range `json:"range,omitempty"` + Contents MarkupContentOrStringOrMarkedStringWithLanguageOrMarkedStrings `json:"contents"` + Range *Range `json:"range,omitempty"` } return json.Unmarshal(data, (*temp)(s)) @@ -3509,7 +3509,7 @@ type SignatureHelp struct { // In future version of the protocol this property might become // mandatory (but still nullable) to better express the active parameter if // the active signature does have any. - ActiveParameter *Nullable[uint32] `json:"activeParameter,omitempty"` + ActiveParameter *UintegerOrNull `json:"activeParameter,omitempty"` } func (s *SignatureHelp) UnmarshalJSON(data []byte) error { @@ -3531,7 +3531,7 @@ func (s *SignatureHelp) UnmarshalJSON(data []byte) error { type temp struct { Signatures []*SignatureInformation `json:"signatures"` ActiveSignature *uint32 `json:"activeSignature,omitempty"` - ActiveParameter *Nullable[uint32] `json:"activeParameter,omitempty"` + ActiveParameter *UintegerOrNull `json:"activeParameter,omitempty"` } return json.Unmarshal(data, (*temp)(s)) @@ -4924,7 +4924,7 @@ func (s *CancelParams) UnmarshalJSON(data []byte) error { type ProgressParams struct { // The progress token provided by the client or server. - Token ProgressToken `json:"token"` + Token IntegerOrString `json:"token"` // The progress data. Value any `json:"value"` @@ -4951,8 +4951,8 @@ func (s *ProgressParams) UnmarshalJSON(data []byte) error { // Redeclare the struct to prevent infinite recursion type temp struct { - Token ProgressToken `json:"token"` - Value any `json:"value"` + Token IntegerOrString `json:"token"` + Value any `json:"value"` } return json.Unmarshal(data, (*temp)(s)) @@ -4998,13 +4998,13 @@ func (s *TextDocumentPositionParams) UnmarshalJSON(data []byte) error { type WorkDoneProgressParams struct { // An optional token that a server can use to report work done progress. - WorkDoneToken *ProgressToken `json:"workDoneToken,omitempty"` + WorkDoneToken *IntegerOrString `json:"workDoneToken,omitempty"` } type PartialResultParams struct { // An optional token that a server can use to report partial results (e.g. streaming) to // the client. - PartialResultToken *ProgressToken `json:"partialResultToken,omitempty"` + PartialResultToken *IntegerOrString `json:"partialResultToken,omitempty"` } // Represents the connection of two locations. Provides additional metadata over normal locations, @@ -6453,7 +6453,7 @@ func (s *TextDocumentItem) UnmarshalJSON(data []byte) error { // Since: 3.17.0 type NotebookDocumentSyncOptions struct { // The notebooks to be synced - NotebookSelector []NotebookDocumentFilterWithNotebookOrNotebookDocumentFilterWithCells `json:"notebookSelector"` + NotebookSelector []NotebookDocumentFilterWithNotebookOrCells `json:"notebookSelector"` // Whether save notification should be forwarded to // the server. Will only be honored if mode === `notebook`. @@ -6477,8 +6477,8 @@ func (s *NotebookDocumentSyncOptions) UnmarshalJSON(data []byte) error { // Redeclare the struct to prevent infinite recursion type temp struct { - NotebookSelector []NotebookDocumentFilterWithNotebookOrNotebookDocumentFilterWithCells `json:"notebookSelector"` - Save *bool `json:"save,omitempty"` + NotebookSelector []NotebookDocumentFilterWithNotebookOrCells `json:"notebookSelector"` + Save *bool `json:"save,omitempty"` } return json.Unmarshal(data, (*temp)(s)) @@ -6782,7 +6782,7 @@ type InitializeParamsBase struct { // // Is `null` if the process has not been started by another process. // If the parent process is not alive then the server should exit. - ProcessId Nullable[int32] `json:"processId"` + ProcessId IntegerOrNull `json:"processId"` // Information about the client // @@ -6803,14 +6803,14 @@ type InitializeParamsBase struct { // if no folder is open. // // Deprecated: in favour of rootUri. - RootPath *Nullable[string] `json:"rootPath,omitempty"` + RootPath *StringOrNull `json:"rootPath,omitempty"` // The rootUri of the workspace. Is null if no // folder is open. If both `rootPath` and `rootUri` are set // `rootUri` wins. // // Deprecated: in favour of workspaceFolders. - RootUri Nullable[DocumentUri] `json:"rootUri"` + RootUri DocumentUriOrNull `json:"rootUri"` // The capabilities provided by the client (editor or tool) Capabilities *ClientCapabilities `json:"capabilities"` @@ -6849,14 +6849,14 @@ func (s *InitializeParamsBase) UnmarshalJSON(data []byte) error { type temp struct { WorkDoneProgressParams - ProcessId Nullable[int32] `json:"processId"` - ClientInfo *ClientInfo `json:"clientInfo,omitempty"` - Locale *string `json:"locale,omitempty"` - RootPath *Nullable[string] `json:"rootPath,omitempty"` - RootUri Nullable[DocumentUri] `json:"rootUri"` - Capabilities *ClientCapabilities `json:"capabilities"` - InitializationOptions *any `json:"initializationOptions,omitempty"` - Trace *TraceValue `json:"trace,omitempty"` + ProcessId IntegerOrNull `json:"processId"` + ClientInfo *ClientInfo `json:"clientInfo,omitempty"` + Locale *string `json:"locale,omitempty"` + RootPath *StringOrNull `json:"rootPath,omitempty"` + RootUri DocumentUriOrNull `json:"rootUri"` + Capabilities *ClientCapabilities `json:"capabilities"` + InitializationOptions *any `json:"initializationOptions,omitempty"` + Trace *TraceValue `json:"trace,omitempty"` } return json.Unmarshal(data, (*temp)(s)) @@ -6870,7 +6870,7 @@ type WorkspaceFoldersInitializeParams struct { // configured. // // Since: 3.6.0 - WorkspaceFolders *Nullable[[]*WorkspaceFolder] `json:"workspaceFolders,omitempty"` + WorkspaceFolders *WorkspaceFoldersOrNull `json:"workspaceFolders,omitempty"` } // Defines the capabilities provided by a language @@ -6890,12 +6890,12 @@ type ServerCapabilities struct { // Defines how text documents are synced. Is either a detailed structure // defining each notification or for backwards compatibility the // TextDocumentSyncKind number. - TextDocumentSync *TextDocumentSyncOptionsOrTextDocumentSyncKind `json:"textDocumentSync,omitempty"` + TextDocumentSync *TextDocumentSyncOptionsOrKind `json:"textDocumentSync,omitempty"` // Defines how notebook documents are synced. // // Since: 3.17.0 - NotebookDocumentSync *NotebookDocumentSyncOptionsOrNotebookDocumentSyncRegistrationOptions `json:"notebookDocumentSync,omitempty"` + NotebookDocumentSync *NotebookDocumentSyncOptionsOrRegistrationOptions `json:"notebookDocumentSync,omitempty"` // The server provides completion support. CompletionProvider *CompletionOptions `json:"completionProvider,omitempty"` @@ -6980,7 +6980,7 @@ type ServerCapabilities struct { // The server provides semantic tokens support. // // Since: 3.16.0 - SemanticTokensProvider *SemanticTokensOptionsOrSemanticTokensRegistrationOptions `json:"semanticTokensProvider,omitempty"` + SemanticTokensProvider *SemanticTokensOptionsOrRegistrationOptions `json:"semanticTokensProvider,omitempty"` // The server provides moniker support. // @@ -7005,7 +7005,7 @@ type ServerCapabilities struct { // The server has support for pull model diagnostics. // // Since: 3.17.0 - DiagnosticProvider *DiagnosticOptionsOrDiagnosticRegistrationOptions `json:"diagnosticProvider,omitempty"` + DiagnosticProvider *DiagnosticOptionsOrRegistrationOptions `json:"diagnosticProvider,omitempty"` // Inline completion options used during static registration. // @@ -7138,7 +7138,7 @@ type FileSystemWatcher struct { // The glob pattern to watch. See pattern for more detail. // // Since: 3.17.0 support for relative patterns. - GlobPattern GlobPattern `json:"globPattern"` + GlobPattern PatternOrRelativePattern `json:"globPattern"` // The kind of events of interest. If omitted it defaults // to WatchKind.Create | WatchKind.Change | WatchKind.Delete @@ -7163,8 +7163,8 @@ func (s *FileSystemWatcher) UnmarshalJSON(data []byte) error { // Redeclare the struct to prevent infinite recursion type temp struct { - GlobPattern GlobPattern `json:"globPattern"` - Kind *WatchKind `json:"kind,omitempty"` + GlobPattern PatternOrRelativePattern `json:"globPattern"` + Kind *WatchKind `json:"kind,omitempty"` } return json.Unmarshal(data, (*temp)(s)) @@ -7566,7 +7566,7 @@ type SignatureInformation struct { // `SignatureHelp.activeParameter`. // // Since: 3.16.0 - ActiveParameter *Nullable[uint32] `json:"activeParameter,omitempty"` + ActiveParameter *UintegerOrNull `json:"activeParameter,omitempty"` } func (s *SignatureInformation) UnmarshalJSON(data []byte) error { @@ -7589,7 +7589,7 @@ func (s *SignatureInformation) UnmarshalJSON(data []byte) error { Label string `json:"label"` Documentation *StringOrMarkupContent `json:"documentation,omitempty"` Parameters *[]*ParameterInformation `json:"parameters,omitempty"` - ActiveParameter *Nullable[uint32] `json:"activeParameter,omitempty"` + ActiveParameter *UintegerOrNull `json:"activeParameter,omitempty"` } return json.Unmarshal(data, (*temp)(s)) @@ -8164,7 +8164,7 @@ type OptionalVersionedTextDocumentIdentifier struct { // (the server has not received an open notification before) the server can send // `null` to indicate that the version is unknown and the content on disk is the // truth (as specified with document content ownership). - Version Nullable[int32] `json:"version"` + Version IntegerOrNull `json:"version"` } func (s *OptionalVersionedTextDocumentIdentifier) UnmarshalJSON(data []byte) error { @@ -8186,7 +8186,7 @@ func (s *OptionalVersionedTextDocumentIdentifier) UnmarshalJSON(data []byte) err type temp struct { TextDocumentIdentifier - Version Nullable[int32] `json:"version"` + Version IntegerOrNull `json:"version"` } return json.Unmarshal(data, (*temp)(s)) @@ -8199,7 +8199,7 @@ type AnnotatedTextEdit struct { TextEdit // The actual identifier of the change annotation - AnnotationId ChangeAnnotationIdentifier `json:"annotationId"` + AnnotationId string `json:"annotationId"` } func (s *AnnotatedTextEdit) UnmarshalJSON(data []byte) error { @@ -8221,7 +8221,7 @@ func (s *AnnotatedTextEdit) UnmarshalJSON(data []byte) error { type temp struct { TextEdit - AnnotationId ChangeAnnotationIdentifier `json:"annotationId"` + AnnotationId string `json:"annotationId"` } return json.Unmarshal(data, (*temp)(s)) @@ -8240,7 +8240,7 @@ type SnippetTextEdit struct { Snippet *StringValue `json:"snippet"` // The actual identifier of the snippet edit. - AnnotationId *ChangeAnnotationIdentifier `json:"annotationId,omitempty"` + AnnotationId *string `json:"annotationId,omitempty"` } func (s *SnippetTextEdit) UnmarshalJSON(data []byte) error { @@ -8264,9 +8264,9 @@ func (s *SnippetTextEdit) UnmarshalJSON(data []byte) error { // Redeclare the struct to prevent infinite recursion type temp struct { - Range Range `json:"range"` - Snippet *StringValue `json:"snippet"` - AnnotationId *ChangeAnnotationIdentifier `json:"annotationId,omitempty"` + Range Range `json:"range"` + Snippet *StringValue `json:"snippet"` + AnnotationId *string `json:"annotationId,omitempty"` } return json.Unmarshal(data, (*temp)(s)) @@ -8280,7 +8280,7 @@ type ResourceOperation struct { // An optional annotation identifier describing the operation. // // Since: 3.16.0 - AnnotationId *ChangeAnnotationIdentifier `json:"annotationId,omitempty"` + AnnotationId *string `json:"annotationId,omitempty"` } func (s *ResourceOperation) UnmarshalJSON(data []byte) error { @@ -8300,8 +8300,8 @@ func (s *ResourceOperation) UnmarshalJSON(data []byte) error { // Redeclare the struct to prevent infinite recursion type temp struct { - Kind string `json:"kind"` - AnnotationId *ChangeAnnotationIdentifier `json:"annotationId,omitempty"` + Kind string `json:"kind"` + AnnotationId *string `json:"annotationId,omitempty"` } return json.Unmarshal(data, (*temp)(s)) @@ -8393,7 +8393,7 @@ type WorkspaceFullDocumentDiagnosticReport struct { // The version number for which the diagnostics are reported. // If the document is not marked as open `null` can be provided. - Version Nullable[int32] `json:"version"` + Version IntegerOrNull `json:"version"` } func (s *WorkspaceFullDocumentDiagnosticReport) UnmarshalJSON(data []byte) error { @@ -8419,8 +8419,8 @@ func (s *WorkspaceFullDocumentDiagnosticReport) UnmarshalJSON(data []byte) error type temp struct { FullDocumentDiagnosticReport - Uri DocumentUri `json:"uri"` - Version Nullable[int32] `json:"version"` + Uri DocumentUri `json:"uri"` + Version IntegerOrNull `json:"version"` } return json.Unmarshal(data, (*temp)(s)) @@ -8437,7 +8437,7 @@ type WorkspaceUnchangedDocumentDiagnosticReport struct { // The version number for which the diagnostics are reported. // If the document is not marked as open `null` can be provided. - Version Nullable[int32] `json:"version"` + Version IntegerOrNull `json:"version"` } func (s *WorkspaceUnchangedDocumentDiagnosticReport) UnmarshalJSON(data []byte) error { @@ -8463,8 +8463,8 @@ func (s *WorkspaceUnchangedDocumentDiagnosticReport) UnmarshalJSON(data []byte) type temp struct { UnchangedDocumentDiagnosticReport - Uri DocumentUri `json:"uri"` - Version Nullable[int32] `json:"version"` + Uri DocumentUri `json:"uri"` + Version IntegerOrNull `json:"version"` } return json.Unmarshal(data, (*temp)(s)) @@ -8530,7 +8530,7 @@ type NotebookDocumentFilterWithNotebook struct { // The notebook to be synced If a string // value is provided it matches against the // notebook type. '*' matches every notebook. - Notebook StringOrNotebookDocumentFilter `json:"notebook"` + Notebook StringOrNotebookDocumentFilterNotebookTypeOrNotebookDocumentFilterSchemeOrNotebookDocumentFilterPattern `json:"notebook"` // The cells of the matching notebook to be synced. Cells *[]*NotebookCellLanguage `json:"cells,omitempty"` @@ -8553,8 +8553,8 @@ func (s *NotebookDocumentFilterWithNotebook) UnmarshalJSON(data []byte) error { // Redeclare the struct to prevent infinite recursion type temp struct { - Notebook StringOrNotebookDocumentFilter `json:"notebook"` - Cells *[]*NotebookCellLanguage `json:"cells,omitempty"` + Notebook StringOrNotebookDocumentFilterNotebookTypeOrNotebookDocumentFilterSchemeOrNotebookDocumentFilterPattern `json:"notebook"` + Cells *[]*NotebookCellLanguage `json:"cells,omitempty"` } return json.Unmarshal(data, (*temp)(s)) @@ -8565,7 +8565,7 @@ type NotebookDocumentFilterWithCells struct { // The notebook to be synced If a string // value is provided it matches against the // notebook type. '*' matches every notebook. - Notebook *StringOrNotebookDocumentFilter `json:"notebook,omitempty"` + Notebook *StringOrNotebookDocumentFilterNotebookTypeOrNotebookDocumentFilterSchemeOrNotebookDocumentFilterPattern `json:"notebook,omitempty"` // The cells of the matching notebook to be synced. Cells []*NotebookCellLanguage `json:"cells"` @@ -8588,8 +8588,8 @@ func (s *NotebookDocumentFilterWithCells) UnmarshalJSON(data []byte) error { // Redeclare the struct to prevent infinite recursion type temp struct { - Notebook *StringOrNotebookDocumentFilter `json:"notebook,omitempty"` - Cells []*NotebookCellLanguage `json:"cells"` + Notebook *StringOrNotebookDocumentFilterNotebookTypeOrNotebookDocumentFilterSchemeOrNotebookDocumentFilterPattern `json:"notebook,omitempty"` + Cells []*NotebookCellLanguage `json:"cells"` } return json.Unmarshal(data, (*temp)(s)) @@ -8755,7 +8755,7 @@ type WorkspaceOptions struct { // Since: 3.18.0 // // Proposed. - TextDocumentContent *TextDocumentContentOptionsOrTextDocumentContentRegistrationOptions `json:"textDocumentContent,omitempty"` + TextDocumentContent *TextDocumentContentOptionsOrRegistrationOptions `json:"textDocumentContent,omitempty"` } // Since: 3.18.0 @@ -9086,7 +9086,7 @@ type NotebookCellTextDocumentFilter struct { // containing the notebook cell. If a string // value is provided it matches against the // notebook type. '*' matches every notebook. - Notebook StringOrNotebookDocumentFilter `json:"notebook"` + Notebook StringOrNotebookDocumentFilterNotebookTypeOrNotebookDocumentFilterSchemeOrNotebookDocumentFilterPattern `json:"notebook"` // A language id like `python`. // @@ -9112,8 +9112,8 @@ func (s *NotebookCellTextDocumentFilter) UnmarshalJSON(data []byte) error { // Redeclare the struct to prevent infinite recursion type temp struct { - Notebook StringOrNotebookDocumentFilter `json:"notebook"` - Language *string `json:"language,omitempty"` + Notebook StringOrNotebookDocumentFilterNotebookTypeOrNotebookDocumentFilterSchemeOrNotebookDocumentFilterPattern `json:"notebook"` + Language *string `json:"language,omitempty"` } return json.Unmarshal(data, (*temp)(s)) @@ -9235,7 +9235,7 @@ func (s *NotebookDocumentCellChangeStructure) UnmarshalJSON(data []byte) error { type NotebookDocumentCellContentChanges struct { Document VersionedTextDocumentIdentifier `json:"document"` - Changes []TextDocumentContentChangeEvent `json:"changes"` + Changes []TextDocumentContentChangePartialOrWholeDocument `json:"changes"` } func (s *NotebookDocumentCellContentChanges) UnmarshalJSON(data []byte) error { @@ -9259,8 +9259,8 @@ func (s *NotebookDocumentCellContentChanges) UnmarshalJSON(data []byte) error { // Redeclare the struct to prevent infinite recursion type temp struct { - Document VersionedTextDocumentIdentifier `json:"document"` - Changes []TextDocumentContentChangeEvent `json:"changes"` + Document VersionedTextDocumentIdentifier `json:"document"` + Changes []TextDocumentContentChangePartialOrWholeDocument `json:"changes"` } return json.Unmarshal(data, (*temp)(s)) @@ -9629,7 +9629,7 @@ type RelativePattern struct { BaseUri WorkspaceFolderOrURI `json:"baseUri"` // The actual glob pattern; - Pattern Pattern `json:"pattern"` + Pattern string `json:"pattern"` } func (s *RelativePattern) UnmarshalJSON(data []byte) error { @@ -9654,7 +9654,7 @@ func (s *RelativePattern) UnmarshalJSON(data []byte) error { // Redeclare the struct to prevent infinite recursion type temp struct { BaseUri WorkspaceFolderOrURI `json:"baseUri"` - Pattern Pattern `json:"pattern"` + Pattern string `json:"pattern"` } return json.Unmarshal(data, (*temp)(s)) @@ -9675,7 +9675,7 @@ type TextDocumentFilterLanguage struct { // Since: 3.18.0 - support for relative patterns. Whether clients support // relative patterns depends on the client capability // `textDocuments.filters.relativePatternSupport`. - Pattern *GlobPattern `json:"pattern,omitempty"` + Pattern *PatternOrRelativePattern `json:"pattern,omitempty"` } func (s *TextDocumentFilterLanguage) UnmarshalJSON(data []byte) error { @@ -9695,9 +9695,9 @@ func (s *TextDocumentFilterLanguage) UnmarshalJSON(data []byte) error { // Redeclare the struct to prevent infinite recursion type temp struct { - Language string `json:"language"` - Scheme *string `json:"scheme,omitempty"` - Pattern *GlobPattern `json:"pattern,omitempty"` + Language string `json:"language"` + Scheme *string `json:"scheme,omitempty"` + Pattern *PatternOrRelativePattern `json:"pattern,omitempty"` } return json.Unmarshal(data, (*temp)(s)) @@ -9718,7 +9718,7 @@ type TextDocumentFilterScheme struct { // Since: 3.18.0 - support for relative patterns. Whether clients support // relative patterns depends on the client capability // `textDocuments.filters.relativePatternSupport`. - Pattern *GlobPattern `json:"pattern,omitempty"` + Pattern *PatternOrRelativePattern `json:"pattern,omitempty"` } func (s *TextDocumentFilterScheme) UnmarshalJSON(data []byte) error { @@ -9738,9 +9738,9 @@ func (s *TextDocumentFilterScheme) UnmarshalJSON(data []byte) error { // Redeclare the struct to prevent infinite recursion type temp struct { - Language *string `json:"language,omitempty"` - Scheme string `json:"scheme"` - Pattern *GlobPattern `json:"pattern,omitempty"` + Language *string `json:"language,omitempty"` + Scheme string `json:"scheme"` + Pattern *PatternOrRelativePattern `json:"pattern,omitempty"` } return json.Unmarshal(data, (*temp)(s)) @@ -9761,7 +9761,7 @@ type TextDocumentFilterPattern struct { // Since: 3.18.0 - support for relative patterns. Whether clients support // relative patterns depends on the client capability // `textDocuments.filters.relativePatternSupport`. - Pattern GlobPattern `json:"pattern"` + Pattern PatternOrRelativePattern `json:"pattern"` } func (s *TextDocumentFilterPattern) UnmarshalJSON(data []byte) error { @@ -9781,9 +9781,9 @@ func (s *TextDocumentFilterPattern) UnmarshalJSON(data []byte) error { // Redeclare the struct to prevent infinite recursion type temp struct { - Language *string `json:"language,omitempty"` - Scheme *string `json:"scheme,omitempty"` - Pattern GlobPattern `json:"pattern"` + Language *string `json:"language,omitempty"` + Scheme *string `json:"scheme,omitempty"` + Pattern PatternOrRelativePattern `json:"pattern"` } return json.Unmarshal(data, (*temp)(s)) @@ -9800,7 +9800,7 @@ type NotebookDocumentFilterNotebookType struct { Scheme *string `json:"scheme,omitempty"` // A glob pattern. - Pattern *GlobPattern `json:"pattern,omitempty"` + Pattern *PatternOrRelativePattern `json:"pattern,omitempty"` } func (s *NotebookDocumentFilterNotebookType) UnmarshalJSON(data []byte) error { @@ -9820,9 +9820,9 @@ func (s *NotebookDocumentFilterNotebookType) UnmarshalJSON(data []byte) error { // Redeclare the struct to prevent infinite recursion type temp struct { - NotebookType string `json:"notebookType"` - Scheme *string `json:"scheme,omitempty"` - Pattern *GlobPattern `json:"pattern,omitempty"` + NotebookType string `json:"notebookType"` + Scheme *string `json:"scheme,omitempty"` + Pattern *PatternOrRelativePattern `json:"pattern,omitempty"` } return json.Unmarshal(data, (*temp)(s)) @@ -9839,7 +9839,7 @@ type NotebookDocumentFilterScheme struct { Scheme string `json:"scheme"` // A glob pattern. - Pattern *GlobPattern `json:"pattern,omitempty"` + Pattern *PatternOrRelativePattern `json:"pattern,omitempty"` } func (s *NotebookDocumentFilterScheme) UnmarshalJSON(data []byte) error { @@ -9859,9 +9859,9 @@ func (s *NotebookDocumentFilterScheme) UnmarshalJSON(data []byte) error { // Redeclare the struct to prevent infinite recursion type temp struct { - NotebookType *string `json:"notebookType,omitempty"` - Scheme string `json:"scheme"` - Pattern *GlobPattern `json:"pattern,omitempty"` + NotebookType *string `json:"notebookType,omitempty"` + Scheme string `json:"scheme"` + Pattern *PatternOrRelativePattern `json:"pattern,omitempty"` } return json.Unmarshal(data, (*temp)(s)) @@ -9878,7 +9878,7 @@ type NotebookDocumentFilterPattern struct { Scheme *string `json:"scheme,omitempty"` // A glob pattern. - Pattern GlobPattern `json:"pattern"` + Pattern PatternOrRelativePattern `json:"pattern"` } func (s *NotebookDocumentFilterPattern) UnmarshalJSON(data []byte) error { @@ -9898,9 +9898,9 @@ func (s *NotebookDocumentFilterPattern) UnmarshalJSON(data []byte) error { // Redeclare the struct to prevent infinite recursion type temp struct { - NotebookType *string `json:"notebookType,omitempty"` - Scheme *string `json:"scheme,omitempty"` - Pattern GlobPattern `json:"pattern"` + NotebookType *string `json:"notebookType,omitempty"` + Scheme *string `json:"scheme,omitempty"` + Pattern PatternOrRelativePattern `json:"pattern"` } return json.Unmarshal(data, (*temp)(s)) @@ -10793,7 +10793,7 @@ func (s *StaleRequestSupportOptions) UnmarshalJSON(data []byte) error { // Since: 3.16.0 type RegularExpressionsClientCapabilities struct { // The engine's name. - Engine RegularExpressionEngineKind `json:"engine"` + Engine string `json:"engine"` // The engine's version. Version *string `json:"version,omitempty"` @@ -10816,8 +10816,8 @@ func (s *RegularExpressionsClientCapabilities) UnmarshalJSON(data []byte) error // Redeclare the struct to prevent infinite recursion type temp struct { - Engine RegularExpressionEngineKind `json:"engine"` - Version *string `json:"version,omitempty"` + Engine string `json:"engine"` + Version *string `json:"version,omitempty"` } return json.Unmarshal(data, (*temp)(s)) @@ -12565,139 +12565,6 @@ func (e *TokenFormat) UnmarshalJSON(data []byte) error { return nil } -// Type aliases - -// The definition of a symbol represented as one or many locations. -// For most programming languages there is only one location at which a symbol is -// defined. -// -// Servers should prefer returning `DefinitionLink` over `Definition` if supported -// by the client. -type Definition = LocationOrLocations - -// Information about where a symbol is defined. -// -// Provides additional metadata over normal location definitions, including the range of -// the defining symbol -type DefinitionLink = LocationLink - -// The declaration of a symbol representation as one or many locations. -type Declaration = LocationOrLocations - -// Information about where a symbol is declared. -// -// Provides additional metadata over normal location declarations, including the range of -// the declaring symbol. -// -// Servers should prefer returning `DeclarationLink` over `Declaration` if supported -// by the client. -type DeclarationLink = LocationLink - -// Inline value information can be provided by different means: -// - directly as a text value (class InlineValueText). -// - as a name to use for a variable lookup (class InlineValueVariableLookup) -// - as an evaluatable expression (class InlineValueEvaluatableExpression) -// The InlineValue types combines all inline value types into one type. -// -// Since: 3.17.0 -type InlineValue = InlineValueTextOrInlineValueVariableLookupOrInlineValueEvaluatableExpression - -// The result of a document diagnostic pull request. A report can -// either be a full report containing all diagnostics for the -// requested document or an unchanged report indicating that nothing -// has changed in terms of diagnostics in comparison to the last -// pull request. -// -// Since: 3.17.0 -type DocumentDiagnosticReport = RelatedFullDocumentDiagnosticReportOrRelatedUnchangedDocumentDiagnosticReport - -type PrepareRenameResult = RangeOrPrepareRenamePlaceholderOrPrepareRenameDefaultBehavior - -// A document selector is the combination of one or many document filters. -// -// @sample `let sel:DocumentSelector = [{ language: 'typescript' }, { language: 'json', pattern: '**∕tsconfig.json' }]`; -// -// The use of a string as a document filter is deprecated @since 3.16.0. -type DocumentSelector = []DocumentFilter - -type ProgressToken = IntegerOrString - -// An identifier to refer to a change annotation stored with a workspace edit. -type ChangeAnnotationIdentifier = string - -// A workspace diagnostic document report. -// -// Since: 3.17.0 -type WorkspaceDocumentDiagnosticReport = WorkspaceFullDocumentDiagnosticReportOrWorkspaceUnchangedDocumentDiagnosticReport - -// An event describing a change to a text document. If only a text is provided -// it is considered to be the full content of the document. -type TextDocumentContentChangeEvent = TextDocumentContentChangePartialOrTextDocumentContentChangeWholeDocument - -// MarkedString can be used to render human readable text. It is either a markdown string -// or a code-block that provides a language and a code snippet. The language identifier -// is semantically equal to the optional language identifier in fenced code blocks in GitHub -// issues. See https://help.github.com/articles/creating-and-highlighting-code-blocks/#syntax-highlighting -// -// The pair of a language and a value is an equivalent to markdown: -// ```${language} -// ${value} -// ``` -// -// Note that markdown strings will be sanitized - that means html will be escaped. -// -// Deprecated: use MarkupContent instead. -type MarkedString = StringOrMarkedStringWithLanguage - -// A document filter describes a top level text document or -// a notebook cell document. -// -// Since: 3.17.0 - support for NotebookCellTextDocumentFilter. -type DocumentFilter = TextDocumentFilterOrNotebookCellTextDocumentFilter - -// The glob pattern. Either a string pattern or a relative pattern. -// -// Since: 3.17.0 -type GlobPattern = PatternOrRelativePattern - -// A document filter denotes a document by different properties like -// the language, the scheme of -// its resource, or a glob-pattern that is applied to the path. -// -// Glob patterns can have the following syntax: -// - `*` to match one or more characters in a path segment -// - `?` to match on one character in a path segment -// - `**` to match any number of path segments, including none -// - `{}` to group sub patterns into an OR expression. (e.g. `**​/*.{ts,js}` matches all TypeScript and JavaScript files) -// - `[]` to declare a range of characters to match in a path segment (e.g., `example.[0-9]` to match on `example.0`, `example.1`, …) -// - `[!...]` to negate a range of characters to match in a path segment (e.g., `example.[!0-9]` to match on `example.a`, `example.b`, but not `example.0`) -// -// @sample A language filter that applies to typescript files on disk: `{ language: 'typescript', scheme: 'file' }` -// @sample A language filter that applies to all package.json paths: `{ language: 'json', pattern: '**package.json' }` -// -// Since: 3.17.0 -type TextDocumentFilter = TextDocumentFilterLanguageOrTextDocumentFilterSchemeOrTextDocumentFilterPattern - -// A notebook document filter denotes a notebook document by -// different properties. The properties will be match -// against the notebook's URI (same as with documents) -// -// Since: 3.17.0 -type NotebookDocumentFilter = NotebookDocumentFilterNotebookTypeOrNotebookDocumentFilterSchemeOrNotebookDocumentFilterPattern - -// The glob pattern to watch relative to the base path. Glob patterns can have the following syntax: -// - `*` to match one or more characters in a path segment -// - `?` to match on one character in a path segment -// - `**` to match any number of path segments, including none -// - `{}` to group conditions (e.g. `**​/*.{ts,js}` matches all TypeScript and JavaScript files) -// - `[]` to declare a range of characters to match in a path segment (e.g., `example.[0-9]` to match on `example.0`, `example.1`, …) -// - `[!...]` to negate a range of characters to match in a path segment (e.g., `example.[!0-9]` to match on `example.a`, `example.b`, but not `example.0`) -// -// Since: 3.17.0 -type Pattern = string - -type RegularExpressionEngineKind = string - func unmarshalParams(method Method, data []byte) (any, error) { switch method { case MethodTextDocumentImplementation: @@ -13286,426 +13153,563 @@ const ( MethodProgress Method = "$/progress" ) -// Union types +// Request response types -type LocationOrLocations struct { - Location *Location - Locations *[]Location -} +// Response type for `textDocument/implementation` +type ImplementationResponse = *LocationOrLocationsOrDefinitionLinks -func (o LocationOrLocations) MarshalJSON() ([]byte, error) { - assertOnlyOne("more than one element of LocationOrLocations is set", o.Location != nil, o.Locations != nil) +// Type mapping info for `textDocument/implementation` +var TextDocumentImplementationInfo = RequestInfo[*ImplementationParams, ImplementationResponse]{Method: MethodTextDocumentImplementation} - if o.Location != nil { - return json.Marshal(*o.Location) - } - if o.Locations != nil { - return json.Marshal(*o.Locations) - } - panic("unreachable") -} +// Response type for `textDocument/typeDefinition` +type TypeDefinitionResponse = *LocationOrLocationsOrDefinitionLinks -func (o *LocationOrLocations) UnmarshalJSON(data []byte) error { - *o = LocationOrLocations{} - var vLocation Location - if err := json.Unmarshal(data, &vLocation); err == nil { - o.Location = &vLocation - return nil - } - var vLocations []Location - if err := json.Unmarshal(data, &vLocations); err == nil { - o.Locations = &vLocations - return nil - } - return fmt.Errorf("invalid LocationOrLocations: %s", data) -} +// Type mapping info for `textDocument/typeDefinition` +var TextDocumentTypeDefinitionInfo = RequestInfo[*TypeDefinitionParams, TypeDefinitionResponse]{Method: MethodTextDocumentTypeDefinition} -type InlineValueTextOrInlineValueVariableLookupOrInlineValueEvaluatableExpression struct { - InlineValueText *InlineValueText - InlineValueVariableLookup *InlineValueVariableLookup - InlineValueEvaluatableExpression *InlineValueEvaluatableExpression -} +// Response type for `workspace/workspaceFolders` +type WorkspaceFoldersResponse = *[]*WorkspaceFolder -func (o InlineValueTextOrInlineValueVariableLookupOrInlineValueEvaluatableExpression) MarshalJSON() ([]byte, error) { - assertOnlyOne("more than one element of InlineValueTextOrInlineValueVariableLookupOrInlineValueEvaluatableExpression is set", o.InlineValueText != nil, o.InlineValueVariableLookup != nil, o.InlineValueEvaluatableExpression != nil) +// Type mapping info for `workspace/workspaceFolders` +var WorkspaceWorkspaceFoldersInfo = RequestInfo[any, WorkspaceFoldersResponse]{Method: MethodWorkspaceWorkspaceFolders} - if o.InlineValueText != nil { - return json.Marshal(*o.InlineValueText) - } - if o.InlineValueVariableLookup != nil { - return json.Marshal(*o.InlineValueVariableLookup) - } - if o.InlineValueEvaluatableExpression != nil { - return json.Marshal(*o.InlineValueEvaluatableExpression) - } - panic("unreachable") -} +// Response type for `workspace/configuration` +type ConfigurationResponse = []any -func (o *InlineValueTextOrInlineValueVariableLookupOrInlineValueEvaluatableExpression) UnmarshalJSON(data []byte) error { - *o = InlineValueTextOrInlineValueVariableLookupOrInlineValueEvaluatableExpression{} - var vInlineValueText InlineValueText - if err := json.Unmarshal(data, &vInlineValueText); err == nil { - o.InlineValueText = &vInlineValueText - return nil - } - var vInlineValueVariableLookup InlineValueVariableLookup - if err := json.Unmarshal(data, &vInlineValueVariableLookup); err == nil { - o.InlineValueVariableLookup = &vInlineValueVariableLookup - return nil - } - var vInlineValueEvaluatableExpression InlineValueEvaluatableExpression - if err := json.Unmarshal(data, &vInlineValueEvaluatableExpression); err == nil { - o.InlineValueEvaluatableExpression = &vInlineValueEvaluatableExpression - return nil - } - return fmt.Errorf("invalid InlineValueTextOrInlineValueVariableLookupOrInlineValueEvaluatableExpression: %s", data) -} +// Type mapping info for `workspace/configuration` +var WorkspaceConfigurationInfo = RequestInfo[*ConfigurationParams, ConfigurationResponse]{Method: MethodWorkspaceConfiguration} -type RelatedFullDocumentDiagnosticReportOrRelatedUnchangedDocumentDiagnosticReport struct { - RelatedFullDocumentDiagnosticReport *RelatedFullDocumentDiagnosticReport - RelatedUnchangedDocumentDiagnosticReport *RelatedUnchangedDocumentDiagnosticReport -} +// Response type for `textDocument/documentColor` +type DocumentColorResponse = []*ColorInformation -func (o RelatedFullDocumentDiagnosticReportOrRelatedUnchangedDocumentDiagnosticReport) MarshalJSON() ([]byte, error) { - assertOnlyOne("more than one element of RelatedFullDocumentDiagnosticReportOrRelatedUnchangedDocumentDiagnosticReport is set", o.RelatedFullDocumentDiagnosticReport != nil, o.RelatedUnchangedDocumentDiagnosticReport != nil) +// Type mapping info for `textDocument/documentColor` +var TextDocumentDocumentColorInfo = RequestInfo[*DocumentColorParams, DocumentColorResponse]{Method: MethodTextDocumentDocumentColor} - if o.RelatedFullDocumentDiagnosticReport != nil { - return json.Marshal(*o.RelatedFullDocumentDiagnosticReport) - } - if o.RelatedUnchangedDocumentDiagnosticReport != nil { - return json.Marshal(*o.RelatedUnchangedDocumentDiagnosticReport) - } - panic("unreachable") -} +// Response type for `textDocument/colorPresentation` +type ColorPresentationResponse = []*ColorPresentation -func (o *RelatedFullDocumentDiagnosticReportOrRelatedUnchangedDocumentDiagnosticReport) UnmarshalJSON(data []byte) error { - *o = RelatedFullDocumentDiagnosticReportOrRelatedUnchangedDocumentDiagnosticReport{} - var vRelatedFullDocumentDiagnosticReport RelatedFullDocumentDiagnosticReport - if err := json.Unmarshal(data, &vRelatedFullDocumentDiagnosticReport); err == nil { - o.RelatedFullDocumentDiagnosticReport = &vRelatedFullDocumentDiagnosticReport - return nil - } - var vRelatedUnchangedDocumentDiagnosticReport RelatedUnchangedDocumentDiagnosticReport - if err := json.Unmarshal(data, &vRelatedUnchangedDocumentDiagnosticReport); err == nil { - o.RelatedUnchangedDocumentDiagnosticReport = &vRelatedUnchangedDocumentDiagnosticReport - return nil - } - return fmt.Errorf("invalid RelatedFullDocumentDiagnosticReportOrRelatedUnchangedDocumentDiagnosticReport: %s", data) -} +// Type mapping info for `textDocument/colorPresentation` +var TextDocumentColorPresentationInfo = RequestInfo[*ColorPresentationParams, ColorPresentationResponse]{Method: MethodTextDocumentColorPresentation} -type RangeOrPrepareRenamePlaceholderOrPrepareRenameDefaultBehavior struct { - Range *Range - PrepareRenamePlaceholder *PrepareRenamePlaceholder - PrepareRenameDefaultBehavior *PrepareRenameDefaultBehavior -} +// Response type for `textDocument/foldingRange` +type FoldingRangeResponse = *[]*FoldingRange -func (o RangeOrPrepareRenamePlaceholderOrPrepareRenameDefaultBehavior) MarshalJSON() ([]byte, error) { - assertOnlyOne("more than one element of RangeOrPrepareRenamePlaceholderOrPrepareRenameDefaultBehavior is set", o.Range != nil, o.PrepareRenamePlaceholder != nil, o.PrepareRenameDefaultBehavior != nil) +// Type mapping info for `textDocument/foldingRange` +var TextDocumentFoldingRangeInfo = RequestInfo[*FoldingRangeParams, FoldingRangeResponse]{Method: MethodTextDocumentFoldingRange} - if o.Range != nil { - return json.Marshal(*o.Range) - } - if o.PrepareRenamePlaceholder != nil { - return json.Marshal(*o.PrepareRenamePlaceholder) - } - if o.PrepareRenameDefaultBehavior != nil { - return json.Marshal(*o.PrepareRenameDefaultBehavior) - } - panic("unreachable") -} +// Response type for `workspace/foldingRange/refresh` +type FoldingRangeRefreshResponse = any -func (o *RangeOrPrepareRenamePlaceholderOrPrepareRenameDefaultBehavior) UnmarshalJSON(data []byte) error { - *o = RangeOrPrepareRenamePlaceholderOrPrepareRenameDefaultBehavior{} - var vRange Range - if err := json.Unmarshal(data, &vRange); err == nil { - o.Range = &vRange - return nil - } - var vPrepareRenamePlaceholder PrepareRenamePlaceholder - if err := json.Unmarshal(data, &vPrepareRenamePlaceholder); err == nil { - o.PrepareRenamePlaceholder = &vPrepareRenamePlaceholder - return nil - } - var vPrepareRenameDefaultBehavior PrepareRenameDefaultBehavior - if err := json.Unmarshal(data, &vPrepareRenameDefaultBehavior); err == nil { - o.PrepareRenameDefaultBehavior = &vPrepareRenameDefaultBehavior - return nil - } - return fmt.Errorf("invalid RangeOrPrepareRenamePlaceholderOrPrepareRenameDefaultBehavior: %s", data) -} +// Type mapping info for `workspace/foldingRange/refresh` +var WorkspaceFoldingRangeRefreshInfo = RequestInfo[any, FoldingRangeRefreshResponse]{Method: MethodWorkspaceFoldingRangeRefresh} -type IntegerOrString struct { - Integer *int32 - String *string -} +// Response type for `textDocument/declaration` +type DeclarationResponse = *LocationOrLocationsOrDeclarationLinks -func (o IntegerOrString) MarshalJSON() ([]byte, error) { - assertOnlyOne("more than one element of IntegerOrString is set", o.Integer != nil, o.String != nil) +// Type mapping info for `textDocument/declaration` +var TextDocumentDeclarationInfo = RequestInfo[*DeclarationParams, DeclarationResponse]{Method: MethodTextDocumentDeclaration} - if o.Integer != nil { - return json.Marshal(*o.Integer) - } - if o.String != nil { - return json.Marshal(*o.String) - } - panic("unreachable") -} +// Response type for `textDocument/selectionRange` +type SelectionRangeResponse = *[]*SelectionRange -func (o *IntegerOrString) UnmarshalJSON(data []byte) error { - *o = IntegerOrString{} - var vInteger int32 - if err := json.Unmarshal(data, &vInteger); err == nil { - o.Integer = &vInteger - return nil - } - var vString string - if err := json.Unmarshal(data, &vString); err == nil { - o.String = &vString - return nil - } - return fmt.Errorf("invalid IntegerOrString: %s", data) -} +// Type mapping info for `textDocument/selectionRange` +var TextDocumentSelectionRangeInfo = RequestInfo[*SelectionRangeParams, SelectionRangeResponse]{Method: MethodTextDocumentSelectionRange} -type WorkspaceFullDocumentDiagnosticReportOrWorkspaceUnchangedDocumentDiagnosticReport struct { - WorkspaceFullDocumentDiagnosticReport *WorkspaceFullDocumentDiagnosticReport - WorkspaceUnchangedDocumentDiagnosticReport *WorkspaceUnchangedDocumentDiagnosticReport -} +// Response type for `window/workDoneProgress/create` +type WorkDoneProgressCreateResponse = any -func (o WorkspaceFullDocumentDiagnosticReportOrWorkspaceUnchangedDocumentDiagnosticReport) MarshalJSON() ([]byte, error) { - assertOnlyOne("more than one element of WorkspaceFullDocumentDiagnosticReportOrWorkspaceUnchangedDocumentDiagnosticReport is set", o.WorkspaceFullDocumentDiagnosticReport != nil, o.WorkspaceUnchangedDocumentDiagnosticReport != nil) +// Type mapping info for `window/workDoneProgress/create` +var WindowWorkDoneProgressCreateInfo = RequestInfo[*WorkDoneProgressCreateParams, WorkDoneProgressCreateResponse]{Method: MethodWindowWorkDoneProgressCreate} - if o.WorkspaceFullDocumentDiagnosticReport != nil { - return json.Marshal(*o.WorkspaceFullDocumentDiagnosticReport) - } - if o.WorkspaceUnchangedDocumentDiagnosticReport != nil { - return json.Marshal(*o.WorkspaceUnchangedDocumentDiagnosticReport) - } - panic("unreachable") -} +// Response type for `textDocument/prepareCallHierarchy` +type CallHierarchyPrepareResponse = *[]*CallHierarchyItem -func (o *WorkspaceFullDocumentDiagnosticReportOrWorkspaceUnchangedDocumentDiagnosticReport) UnmarshalJSON(data []byte) error { - *o = WorkspaceFullDocumentDiagnosticReportOrWorkspaceUnchangedDocumentDiagnosticReport{} - var vWorkspaceFullDocumentDiagnosticReport WorkspaceFullDocumentDiagnosticReport - if err := json.Unmarshal(data, &vWorkspaceFullDocumentDiagnosticReport); err == nil { - o.WorkspaceFullDocumentDiagnosticReport = &vWorkspaceFullDocumentDiagnosticReport - return nil - } - var vWorkspaceUnchangedDocumentDiagnosticReport WorkspaceUnchangedDocumentDiagnosticReport - if err := json.Unmarshal(data, &vWorkspaceUnchangedDocumentDiagnosticReport); err == nil { - o.WorkspaceUnchangedDocumentDiagnosticReport = &vWorkspaceUnchangedDocumentDiagnosticReport - return nil - } - return fmt.Errorf("invalid WorkspaceFullDocumentDiagnosticReportOrWorkspaceUnchangedDocumentDiagnosticReport: %s", data) -} +// Type mapping info for `textDocument/prepareCallHierarchy` +var TextDocumentPrepareCallHierarchyInfo = RequestInfo[*CallHierarchyPrepareParams, CallHierarchyPrepareResponse]{Method: MethodTextDocumentPrepareCallHierarchy} -type TextDocumentContentChangePartialOrTextDocumentContentChangeWholeDocument struct { - TextDocumentContentChangePartial *TextDocumentContentChangePartial - TextDocumentContentChangeWholeDocument *TextDocumentContentChangeWholeDocument -} +// Response type for `callHierarchy/incomingCalls` +type CallHierarchyIncomingCallsResponse = *[]*CallHierarchyIncomingCall -func (o TextDocumentContentChangePartialOrTextDocumentContentChangeWholeDocument) MarshalJSON() ([]byte, error) { - assertOnlyOne("more than one element of TextDocumentContentChangePartialOrTextDocumentContentChangeWholeDocument is set", o.TextDocumentContentChangePartial != nil, o.TextDocumentContentChangeWholeDocument != nil) +// Type mapping info for `callHierarchy/incomingCalls` +var CallHierarchyIncomingCallsInfo = RequestInfo[*CallHierarchyIncomingCallsParams, CallHierarchyIncomingCallsResponse]{Method: MethodCallHierarchyIncomingCalls} - if o.TextDocumentContentChangePartial != nil { - return json.Marshal(*o.TextDocumentContentChangePartial) - } - if o.TextDocumentContentChangeWholeDocument != nil { - return json.Marshal(*o.TextDocumentContentChangeWholeDocument) - } - panic("unreachable") -} +// Response type for `callHierarchy/outgoingCalls` +type CallHierarchyOutgoingCallsResponse = *[]*CallHierarchyOutgoingCall -func (o *TextDocumentContentChangePartialOrTextDocumentContentChangeWholeDocument) UnmarshalJSON(data []byte) error { - *o = TextDocumentContentChangePartialOrTextDocumentContentChangeWholeDocument{} - var vTextDocumentContentChangePartial TextDocumentContentChangePartial - if err := json.Unmarshal(data, &vTextDocumentContentChangePartial); err == nil { - o.TextDocumentContentChangePartial = &vTextDocumentContentChangePartial - return nil - } - var vTextDocumentContentChangeWholeDocument TextDocumentContentChangeWholeDocument - if err := json.Unmarshal(data, &vTextDocumentContentChangeWholeDocument); err == nil { - o.TextDocumentContentChangeWholeDocument = &vTextDocumentContentChangeWholeDocument - return nil - } - return fmt.Errorf("invalid TextDocumentContentChangePartialOrTextDocumentContentChangeWholeDocument: %s", data) -} +// Type mapping info for `callHierarchy/outgoingCalls` +var CallHierarchyOutgoingCallsInfo = RequestInfo[*CallHierarchyOutgoingCallsParams, CallHierarchyOutgoingCallsResponse]{Method: MethodCallHierarchyOutgoingCalls} -type StringOrMarkedStringWithLanguage struct { - String *string - MarkedStringWithLanguage *MarkedStringWithLanguage -} +// Response type for `textDocument/semanticTokens/full` +type SemanticTokensResponse = *SemanticTokens -func (o StringOrMarkedStringWithLanguage) MarshalJSON() ([]byte, error) { - assertOnlyOne("more than one element of StringOrMarkedStringWithLanguage is set", o.String != nil, o.MarkedStringWithLanguage != nil) +// Type mapping info for `textDocument/semanticTokens/full` +var TextDocumentSemanticTokensFullInfo = RequestInfo[*SemanticTokensParams, SemanticTokensResponse]{Method: MethodTextDocumentSemanticTokensFull} - if o.String != nil { - return json.Marshal(*o.String) - } - if o.MarkedStringWithLanguage != nil { - return json.Marshal(*o.MarkedStringWithLanguage) - } - panic("unreachable") -} +// Response type for `textDocument/semanticTokens/full/delta` +type SemanticTokensDeltaResponse = *SemanticTokensOrSemanticTokensDelta -func (o *StringOrMarkedStringWithLanguage) UnmarshalJSON(data []byte) error { - *o = StringOrMarkedStringWithLanguage{} - var vString string - if err := json.Unmarshal(data, &vString); err == nil { - o.String = &vString - return nil - } - var vMarkedStringWithLanguage MarkedStringWithLanguage - if err := json.Unmarshal(data, &vMarkedStringWithLanguage); err == nil { - o.MarkedStringWithLanguage = &vMarkedStringWithLanguage - return nil - } - return fmt.Errorf("invalid StringOrMarkedStringWithLanguage: %s", data) -} +// Type mapping info for `textDocument/semanticTokens/full/delta` +var TextDocumentSemanticTokensFullDeltaInfo = RequestInfo[*SemanticTokensDeltaParams, SemanticTokensDeltaResponse]{Method: MethodTextDocumentSemanticTokensFullDelta} -type TextDocumentFilterOrNotebookCellTextDocumentFilter struct { - TextDocumentFilter *TextDocumentFilter - NotebookCellTextDocumentFilter *NotebookCellTextDocumentFilter -} +// Response type for `textDocument/semanticTokens/range` +type SemanticTokensRangeResponse = *SemanticTokens -func (o TextDocumentFilterOrNotebookCellTextDocumentFilter) MarshalJSON() ([]byte, error) { - assertOnlyOne("more than one element of TextDocumentFilterOrNotebookCellTextDocumentFilter is set", o.TextDocumentFilter != nil, o.NotebookCellTextDocumentFilter != nil) +// Type mapping info for `textDocument/semanticTokens/range` +var TextDocumentSemanticTokensRangeInfo = RequestInfo[*SemanticTokensRangeParams, SemanticTokensRangeResponse]{Method: MethodTextDocumentSemanticTokensRange} - if o.TextDocumentFilter != nil { - return json.Marshal(*o.TextDocumentFilter) - } - if o.NotebookCellTextDocumentFilter != nil { - return json.Marshal(*o.NotebookCellTextDocumentFilter) - } - panic("unreachable") -} +// Response type for `workspace/semanticTokens/refresh` +type SemanticTokensRefreshResponse = any -func (o *TextDocumentFilterOrNotebookCellTextDocumentFilter) UnmarshalJSON(data []byte) error { - *o = TextDocumentFilterOrNotebookCellTextDocumentFilter{} - var vTextDocumentFilter TextDocumentFilter - if err := json.Unmarshal(data, &vTextDocumentFilter); err == nil { - o.TextDocumentFilter = &vTextDocumentFilter - return nil - } - var vNotebookCellTextDocumentFilter NotebookCellTextDocumentFilter - if err := json.Unmarshal(data, &vNotebookCellTextDocumentFilter); err == nil { - o.NotebookCellTextDocumentFilter = &vNotebookCellTextDocumentFilter - return nil - } - return fmt.Errorf("invalid TextDocumentFilterOrNotebookCellTextDocumentFilter: %s", data) -} +// Type mapping info for `workspace/semanticTokens/refresh` +var WorkspaceSemanticTokensRefreshInfo = RequestInfo[any, SemanticTokensRefreshResponse]{Method: MethodWorkspaceSemanticTokensRefresh} -type PatternOrRelativePattern struct { - Pattern *Pattern - RelativePattern *RelativePattern -} +// Response type for `window/showDocument` +type ShowDocumentResponse = *ShowDocumentResult -func (o PatternOrRelativePattern) MarshalJSON() ([]byte, error) { - assertOnlyOne("more than one element of PatternOrRelativePattern is set", o.Pattern != nil, o.RelativePattern != nil) +// Type mapping info for `window/showDocument` +var WindowShowDocumentInfo = RequestInfo[*ShowDocumentParams, ShowDocumentResponse]{Method: MethodWindowShowDocument} - if o.Pattern != nil { - return json.Marshal(*o.Pattern) - } - if o.RelativePattern != nil { - return json.Marshal(*o.RelativePattern) - } - panic("unreachable") -} +// Response type for `textDocument/linkedEditingRange` +type LinkedEditingRangeResponse = *LinkedEditingRanges -func (o *PatternOrRelativePattern) UnmarshalJSON(data []byte) error { - *o = PatternOrRelativePattern{} - var vPattern Pattern - if err := json.Unmarshal(data, &vPattern); err == nil { - o.Pattern = &vPattern - return nil - } - var vRelativePattern RelativePattern - if err := json.Unmarshal(data, &vRelativePattern); err == nil { - o.RelativePattern = &vRelativePattern - return nil - } - return fmt.Errorf("invalid PatternOrRelativePattern: %s", data) -} +// Type mapping info for `textDocument/linkedEditingRange` +var TextDocumentLinkedEditingRangeInfo = RequestInfo[*LinkedEditingRangeParams, LinkedEditingRangeResponse]{Method: MethodTextDocumentLinkedEditingRange} -type TextDocumentFilterLanguageOrTextDocumentFilterSchemeOrTextDocumentFilterPattern struct { - TextDocumentFilterLanguage *TextDocumentFilterLanguage - TextDocumentFilterScheme *TextDocumentFilterScheme - TextDocumentFilterPattern *TextDocumentFilterPattern -} +// Response type for `workspace/willCreateFiles` +type WillCreateFilesResponse = *WorkspaceEdit -func (o TextDocumentFilterLanguageOrTextDocumentFilterSchemeOrTextDocumentFilterPattern) MarshalJSON() ([]byte, error) { - assertOnlyOne("more than one element of TextDocumentFilterLanguageOrTextDocumentFilterSchemeOrTextDocumentFilterPattern is set", o.TextDocumentFilterLanguage != nil, o.TextDocumentFilterScheme != nil, o.TextDocumentFilterPattern != nil) +// Type mapping info for `workspace/willCreateFiles` +var WorkspaceWillCreateFilesInfo = RequestInfo[*CreateFilesParams, WillCreateFilesResponse]{Method: MethodWorkspaceWillCreateFiles} - if o.TextDocumentFilterLanguage != nil { - return json.Marshal(*o.TextDocumentFilterLanguage) - } - if o.TextDocumentFilterScheme != nil { - return json.Marshal(*o.TextDocumentFilterScheme) - } - if o.TextDocumentFilterPattern != nil { - return json.Marshal(*o.TextDocumentFilterPattern) - } - panic("unreachable") +// Response type for `workspace/willRenameFiles` +type WillRenameFilesResponse = *WorkspaceEdit + +// Type mapping info for `workspace/willRenameFiles` +var WorkspaceWillRenameFilesInfo = RequestInfo[*RenameFilesParams, WillRenameFilesResponse]{Method: MethodWorkspaceWillRenameFiles} + +// Response type for `workspace/willDeleteFiles` +type WillDeleteFilesResponse = *WorkspaceEdit + +// Type mapping info for `workspace/willDeleteFiles` +var WorkspaceWillDeleteFilesInfo = RequestInfo[*DeleteFilesParams, WillDeleteFilesResponse]{Method: MethodWorkspaceWillDeleteFiles} + +// Response type for `textDocument/moniker` +type MonikerResponse = *[]*Moniker + +// Type mapping info for `textDocument/moniker` +var TextDocumentMonikerInfo = RequestInfo[*MonikerParams, MonikerResponse]{Method: MethodTextDocumentMoniker} + +// Response type for `textDocument/prepareTypeHierarchy` +type TypeHierarchyPrepareResponse = *[]*TypeHierarchyItem + +// Type mapping info for `textDocument/prepareTypeHierarchy` +var TextDocumentPrepareTypeHierarchyInfo = RequestInfo[*TypeHierarchyPrepareParams, TypeHierarchyPrepareResponse]{Method: MethodTextDocumentPrepareTypeHierarchy} + +// Response type for `typeHierarchy/supertypes` +type TypeHierarchySupertypesResponse = *[]*TypeHierarchyItem + +// Type mapping info for `typeHierarchy/supertypes` +var TypeHierarchySupertypesInfo = RequestInfo[*TypeHierarchySupertypesParams, TypeHierarchySupertypesResponse]{Method: MethodTypeHierarchySupertypes} + +// Response type for `typeHierarchy/subtypes` +type TypeHierarchySubtypesResponse = *[]*TypeHierarchyItem + +// Type mapping info for `typeHierarchy/subtypes` +var TypeHierarchySubtypesInfo = RequestInfo[*TypeHierarchySubtypesParams, TypeHierarchySubtypesResponse]{Method: MethodTypeHierarchySubtypes} + +// Response type for `textDocument/inlineValue` +type InlineValueResponse = *[]InlineValueTextOrVariableLookupOrEvaluatableExpression + +// Type mapping info for `textDocument/inlineValue` +var TextDocumentInlineValueInfo = RequestInfo[*InlineValueParams, InlineValueResponse]{Method: MethodTextDocumentInlineValue} + +// Response type for `workspace/inlineValue/refresh` +type InlineValueRefreshResponse = any + +// Type mapping info for `workspace/inlineValue/refresh` +var WorkspaceInlineValueRefreshInfo = RequestInfo[any, InlineValueRefreshResponse]{Method: MethodWorkspaceInlineValueRefresh} + +// Response type for `textDocument/inlayHint` +type InlayHintResponse = *[]*InlayHint + +// Type mapping info for `textDocument/inlayHint` +var TextDocumentInlayHintInfo = RequestInfo[*InlayHintParams, InlayHintResponse]{Method: MethodTextDocumentInlayHint} + +// Response type for `inlayHint/resolve` +type InlayHintResolveResponse = *InlayHint + +// Type mapping info for `inlayHint/resolve` +var InlayHintResolveInfo = RequestInfo[*InlayHint, InlayHintResolveResponse]{Method: MethodInlayHintResolve} + +// Response type for `workspace/inlayHint/refresh` +type InlayHintRefreshResponse = any + +// Type mapping info for `workspace/inlayHint/refresh` +var WorkspaceInlayHintRefreshInfo = RequestInfo[any, InlayHintRefreshResponse]{Method: MethodWorkspaceInlayHintRefresh} + +// Response type for `textDocument/diagnostic` +type DocumentDiagnosticResponse = RelatedFullDocumentDiagnosticReportOrUnchangedDocumentDiagnosticReport + +// Type mapping info for `textDocument/diagnostic` +var TextDocumentDiagnosticInfo = RequestInfo[*DocumentDiagnosticParams, DocumentDiagnosticResponse]{Method: MethodTextDocumentDiagnostic} + +// Response type for `workspace/diagnostic` +type WorkspaceDiagnosticResponse = *WorkspaceDiagnosticReport + +// Type mapping info for `workspace/diagnostic` +var WorkspaceDiagnosticInfo = RequestInfo[*WorkspaceDiagnosticParams, WorkspaceDiagnosticResponse]{Method: MethodWorkspaceDiagnostic} + +// Response type for `workspace/diagnostic/refresh` +type DiagnosticRefreshResponse = any + +// Type mapping info for `workspace/diagnostic/refresh` +var WorkspaceDiagnosticRefreshInfo = RequestInfo[any, DiagnosticRefreshResponse]{Method: MethodWorkspaceDiagnosticRefresh} + +// Response type for `textDocument/inlineCompletion` +type InlineCompletionResponse = *InlineCompletionListOrItems + +// Type mapping info for `textDocument/inlineCompletion` +var TextDocumentInlineCompletionInfo = RequestInfo[*InlineCompletionParams, InlineCompletionResponse]{Method: MethodTextDocumentInlineCompletion} + +// Response type for `workspace/textDocumentContent` +type TextDocumentContentResponse = *TextDocumentContentResult + +// Type mapping info for `workspace/textDocumentContent` +var WorkspaceTextDocumentContentInfo = RequestInfo[*TextDocumentContentParams, TextDocumentContentResponse]{Method: MethodWorkspaceTextDocumentContent} + +// Response type for `workspace/textDocumentContent/refresh` +type TextDocumentContentRefreshResponse = any + +// Type mapping info for `workspace/textDocumentContent/refresh` +var WorkspaceTextDocumentContentRefreshInfo = RequestInfo[*TextDocumentContentRefreshParams, TextDocumentContentRefreshResponse]{Method: MethodWorkspaceTextDocumentContentRefresh} + +// Response type for `client/registerCapability` +type RegistrationResponse = any + +// Type mapping info for `client/registerCapability` +var ClientRegisterCapabilityInfo = RequestInfo[*RegistrationParams, RegistrationResponse]{Method: MethodClientRegisterCapability} + +// Response type for `client/unregisterCapability` +type UnregistrationResponse = any + +// Type mapping info for `client/unregisterCapability` +var ClientUnregisterCapabilityInfo = RequestInfo[*UnregistrationParams, UnregistrationResponse]{Method: MethodClientUnregisterCapability} + +// Response type for `initialize` +type InitializeResponse = *InitializeResult + +// Type mapping info for `initialize` +var InitializeInfo = RequestInfo[*InitializeParams, InitializeResponse]{Method: MethodInitialize} + +// Response type for `shutdown` +type ShutdownResponse = any + +// Type mapping info for `shutdown` +var ShutdownInfo = RequestInfo[any, ShutdownResponse]{Method: MethodShutdown} + +// Response type for `window/showMessageRequest` +type ShowMessageResponse = *MessageActionItem + +// Type mapping info for `window/showMessageRequest` +var WindowShowMessageRequestInfo = RequestInfo[*ShowMessageRequestParams, ShowMessageResponse]{Method: MethodWindowShowMessageRequest} + +// Response type for `textDocument/willSaveWaitUntil` +type WillSaveTextDocumentWaitUntilResponse = *[]*TextEdit + +// Type mapping info for `textDocument/willSaveWaitUntil` +var TextDocumentWillSaveWaitUntilInfo = RequestInfo[*WillSaveTextDocumentParams, WillSaveTextDocumentWaitUntilResponse]{Method: MethodTextDocumentWillSaveWaitUntil} + +// Response type for `textDocument/completion` +type CompletionResponse = *CompletionItemsOrList + +// Type mapping info for `textDocument/completion` +var TextDocumentCompletionInfo = RequestInfo[*CompletionParams, CompletionResponse]{Method: MethodTextDocumentCompletion} + +// Response type for `completionItem/resolve` +type CompletionResolveResponse = *CompletionItem + +// Type mapping info for `completionItem/resolve` +var CompletionItemResolveInfo = RequestInfo[*CompletionItem, CompletionResolveResponse]{Method: MethodCompletionItemResolve} + +// Response type for `textDocument/hover` +type HoverResponse = *Hover + +// Type mapping info for `textDocument/hover` +var TextDocumentHoverInfo = RequestInfo[*HoverParams, HoverResponse]{Method: MethodTextDocumentHover} + +// Response type for `textDocument/signatureHelp` +type SignatureHelpResponse = *SignatureHelp + +// Type mapping info for `textDocument/signatureHelp` +var TextDocumentSignatureHelpInfo = RequestInfo[*SignatureHelpParams, SignatureHelpResponse]{Method: MethodTextDocumentSignatureHelp} + +// Response type for `textDocument/definition` +type DefinitionResponse = *LocationOrLocationsOrDefinitionLinks + +// Type mapping info for `textDocument/definition` +var TextDocumentDefinitionInfo = RequestInfo[*DefinitionParams, DefinitionResponse]{Method: MethodTextDocumentDefinition} + +// Response type for `textDocument/references` +type ReferencesResponse = *[]Location + +// Type mapping info for `textDocument/references` +var TextDocumentReferencesInfo = RequestInfo[*ReferenceParams, ReferencesResponse]{Method: MethodTextDocumentReferences} + +// Response type for `textDocument/documentHighlight` +type DocumentHighlightResponse = *[]*DocumentHighlight + +// Type mapping info for `textDocument/documentHighlight` +var TextDocumentDocumentHighlightInfo = RequestInfo[*DocumentHighlightParams, DocumentHighlightResponse]{Method: MethodTextDocumentDocumentHighlight} + +// Response type for `textDocument/documentSymbol` +type DocumentSymbolResponse = *SymbolInformationsOrDocumentSymbols + +// Type mapping info for `textDocument/documentSymbol` +var TextDocumentDocumentSymbolInfo = RequestInfo[*DocumentSymbolParams, DocumentSymbolResponse]{Method: MethodTextDocumentDocumentSymbol} + +// Response type for `textDocument/codeAction` +type CodeActionResponse = *[]CommandOrCodeAction + +// Type mapping info for `textDocument/codeAction` +var TextDocumentCodeActionInfo = RequestInfo[*CodeActionParams, CodeActionResponse]{Method: MethodTextDocumentCodeAction} + +// Response type for `codeAction/resolve` +type CodeActionResolveResponse = *CodeAction + +// Type mapping info for `codeAction/resolve` +var CodeActionResolveInfo = RequestInfo[*CodeAction, CodeActionResolveResponse]{Method: MethodCodeActionResolve} + +// Response type for `workspace/symbol` +type WorkspaceSymbolResponse = *SymbolInformationsOrWorkspaceSymbols + +// Type mapping info for `workspace/symbol` +var WorkspaceSymbolInfo = RequestInfo[*WorkspaceSymbolParams, WorkspaceSymbolResponse]{Method: MethodWorkspaceSymbol} + +// Response type for `workspaceSymbol/resolve` +type WorkspaceSymbolResolveResponse = *WorkspaceSymbol + +// Type mapping info for `workspaceSymbol/resolve` +var WorkspaceSymbolResolveInfo = RequestInfo[*WorkspaceSymbol, WorkspaceSymbolResolveResponse]{Method: MethodWorkspaceSymbolResolve} + +// Response type for `textDocument/codeLens` +type CodeLensResponse = *[]*CodeLens + +// Type mapping info for `textDocument/codeLens` +var TextDocumentCodeLensInfo = RequestInfo[*CodeLensParams, CodeLensResponse]{Method: MethodTextDocumentCodeLens} + +// Response type for `codeLens/resolve` +type CodeLensResolveResponse = *CodeLens + +// Type mapping info for `codeLens/resolve` +var CodeLensResolveInfo = RequestInfo[*CodeLens, CodeLensResolveResponse]{Method: MethodCodeLensResolve} + +// Response type for `workspace/codeLens/refresh` +type CodeLensRefreshResponse = any + +// Type mapping info for `workspace/codeLens/refresh` +var WorkspaceCodeLensRefreshInfo = RequestInfo[any, CodeLensRefreshResponse]{Method: MethodWorkspaceCodeLensRefresh} + +// Response type for `textDocument/documentLink` +type DocumentLinkResponse = *[]*DocumentLink + +// Type mapping info for `textDocument/documentLink` +var TextDocumentDocumentLinkInfo = RequestInfo[*DocumentLinkParams, DocumentLinkResponse]{Method: MethodTextDocumentDocumentLink} + +// Response type for `documentLink/resolve` +type DocumentLinkResolveResponse = *DocumentLink + +// Type mapping info for `documentLink/resolve` +var DocumentLinkResolveInfo = RequestInfo[*DocumentLink, DocumentLinkResolveResponse]{Method: MethodDocumentLinkResolve} + +// Response type for `textDocument/formatting` +type DocumentFormattingResponse = *[]*TextEdit + +// Type mapping info for `textDocument/formatting` +var TextDocumentFormattingInfo = RequestInfo[*DocumentFormattingParams, DocumentFormattingResponse]{Method: MethodTextDocumentFormatting} + +// Response type for `textDocument/rangeFormatting` +type DocumentRangeFormattingResponse = *[]*TextEdit + +// Type mapping info for `textDocument/rangeFormatting` +var TextDocumentRangeFormattingInfo = RequestInfo[*DocumentRangeFormattingParams, DocumentRangeFormattingResponse]{Method: MethodTextDocumentRangeFormatting} + +// Response type for `textDocument/rangesFormatting` +type DocumentRangesFormattingResponse = *[]*TextEdit + +// Type mapping info for `textDocument/rangesFormatting` +var TextDocumentRangesFormattingInfo = RequestInfo[*DocumentRangesFormattingParams, DocumentRangesFormattingResponse]{Method: MethodTextDocumentRangesFormatting} + +// Response type for `textDocument/onTypeFormatting` +type DocumentOnTypeFormattingResponse = *[]*TextEdit + +// Type mapping info for `textDocument/onTypeFormatting` +var TextDocumentOnTypeFormattingInfo = RequestInfo[*DocumentOnTypeFormattingParams, DocumentOnTypeFormattingResponse]{Method: MethodTextDocumentOnTypeFormatting} + +// Response type for `textDocument/rename` +type RenameResponse = *WorkspaceEdit + +// Type mapping info for `textDocument/rename` +var TextDocumentRenameInfo = RequestInfo[*RenameParams, RenameResponse]{Method: MethodTextDocumentRename} + +// Response type for `textDocument/prepareRename` +type PrepareRenameResponse = *RangeOrPrepareRenamePlaceholderOrPrepareRenameDefaultBehavior + +// Type mapping info for `textDocument/prepareRename` +var TextDocumentPrepareRenameInfo = RequestInfo[*PrepareRenameParams, PrepareRenameResponse]{Method: MethodTextDocumentPrepareRename} + +// Response type for `workspace/executeCommand` +type ExecuteCommandResponse = *any + +// Type mapping info for `workspace/executeCommand` +var WorkspaceExecuteCommandInfo = RequestInfo[*ExecuteCommandParams, ExecuteCommandResponse]{Method: MethodWorkspaceExecuteCommand} + +// Response type for `workspace/applyEdit` +type ApplyWorkspaceEditResponse = *ApplyWorkspaceEditResult + +// Type mapping info for `workspace/applyEdit` +var WorkspaceApplyEditInfo = RequestInfo[*ApplyWorkspaceEditParams, ApplyWorkspaceEditResponse]{Method: MethodWorkspaceApplyEdit} + +// Type mapping info for `workspace/didChangeWorkspaceFolders` +var WorkspaceDidChangeWorkspaceFoldersInfo = NotificationInfo[*DidChangeWorkspaceFoldersParams]{Method: MethodWorkspaceDidChangeWorkspaceFolders} + +// Type mapping info for `window/workDoneProgress/cancel` +var WindowWorkDoneProgressCancelInfo = NotificationInfo[*WorkDoneProgressCancelParams]{Method: MethodWindowWorkDoneProgressCancel} + +// Type mapping info for `workspace/didCreateFiles` +var WorkspaceDidCreateFilesInfo = NotificationInfo[*CreateFilesParams]{Method: MethodWorkspaceDidCreateFiles} + +// Type mapping info for `workspace/didRenameFiles` +var WorkspaceDidRenameFilesInfo = NotificationInfo[*RenameFilesParams]{Method: MethodWorkspaceDidRenameFiles} + +// Type mapping info for `workspace/didDeleteFiles` +var WorkspaceDidDeleteFilesInfo = NotificationInfo[*DeleteFilesParams]{Method: MethodWorkspaceDidDeleteFiles} + +// Type mapping info for `notebookDocument/didOpen` +var NotebookDocumentDidOpenInfo = NotificationInfo[*DidOpenNotebookDocumentParams]{Method: MethodNotebookDocumentDidOpen} + +// Type mapping info for `notebookDocument/didChange` +var NotebookDocumentDidChangeInfo = NotificationInfo[*DidChangeNotebookDocumentParams]{Method: MethodNotebookDocumentDidChange} + +// Type mapping info for `notebookDocument/didSave` +var NotebookDocumentDidSaveInfo = NotificationInfo[*DidSaveNotebookDocumentParams]{Method: MethodNotebookDocumentDidSave} + +// Type mapping info for `notebookDocument/didClose` +var NotebookDocumentDidCloseInfo = NotificationInfo[*DidCloseNotebookDocumentParams]{Method: MethodNotebookDocumentDidClose} + +// Type mapping info for `initialized` +var InitializedInfo = NotificationInfo[*InitializedParams]{Method: MethodInitialized} + +// Type mapping info for `exit` +var ExitInfo = NotificationInfo[any]{Method: MethodExit} + +// Type mapping info for `workspace/didChangeConfiguration` +var WorkspaceDidChangeConfigurationInfo = NotificationInfo[*DidChangeConfigurationParams]{Method: MethodWorkspaceDidChangeConfiguration} + +// Type mapping info for `window/showMessage` +var WindowShowMessageInfo = NotificationInfo[*ShowMessageParams]{Method: MethodWindowShowMessage} + +// Type mapping info for `window/logMessage` +var WindowLogMessageInfo = NotificationInfo[*LogMessageParams]{Method: MethodWindowLogMessage} + +// Type mapping info for `telemetry/event` +var TelemetryEventInfo = NotificationInfo[any]{Method: MethodTelemetryEvent} + +// Type mapping info for `textDocument/didOpen` +var TextDocumentDidOpenInfo = NotificationInfo[*DidOpenTextDocumentParams]{Method: MethodTextDocumentDidOpen} + +// Type mapping info for `textDocument/didChange` +var TextDocumentDidChangeInfo = NotificationInfo[*DidChangeTextDocumentParams]{Method: MethodTextDocumentDidChange} + +// Type mapping info for `textDocument/didClose` +var TextDocumentDidCloseInfo = NotificationInfo[*DidCloseTextDocumentParams]{Method: MethodTextDocumentDidClose} + +// Type mapping info for `textDocument/didSave` +var TextDocumentDidSaveInfo = NotificationInfo[*DidSaveTextDocumentParams]{Method: MethodTextDocumentDidSave} + +// Type mapping info for `textDocument/willSave` +var TextDocumentWillSaveInfo = NotificationInfo[*WillSaveTextDocumentParams]{Method: MethodTextDocumentWillSave} + +// Type mapping info for `workspace/didChangeWatchedFiles` +var WorkspaceDidChangeWatchedFilesInfo = NotificationInfo[*DidChangeWatchedFilesParams]{Method: MethodWorkspaceDidChangeWatchedFiles} + +// Type mapping info for `textDocument/publishDiagnostics` +var TextDocumentPublishDiagnosticsInfo = NotificationInfo[*PublishDiagnosticsParams]{Method: MethodTextDocumentPublishDiagnostics} + +// Type mapping info for `$/setTrace` +var SetTraceInfo = NotificationInfo[*SetTraceParams]{Method: MethodSetTrace} + +// Type mapping info for `$/logTrace` +var LogTraceInfo = NotificationInfo[*LogTraceParams]{Method: MethodLogTrace} + +// Type mapping info for `$/cancelRequest` +var CancelRequestInfo = NotificationInfo[*CancelParams]{Method: MethodCancelRequest} + +// Type mapping info for `$/progress` +var ProgressInfo = NotificationInfo[*ProgressParams]{Method: MethodProgress} + +// Union types + +type DocumentSelectorOrNull struct { + DocumentSelector *[]TextDocumentFilterLanguageOrTextDocumentFilterSchemeOrTextDocumentFilterPatternOrNotebookCellTextDocumentFilter } -func (o *TextDocumentFilterLanguageOrTextDocumentFilterSchemeOrTextDocumentFilterPattern) UnmarshalJSON(data []byte) error { - *o = TextDocumentFilterLanguageOrTextDocumentFilterSchemeOrTextDocumentFilterPattern{} - var vTextDocumentFilterLanguage TextDocumentFilterLanguage - if err := json.Unmarshal(data, &vTextDocumentFilterLanguage); err == nil { - o.TextDocumentFilterLanguage = &vTextDocumentFilterLanguage - return nil +func (o DocumentSelectorOrNull) MarshalJSON() ([]byte, error) { + assertAtMostOne("more than one element of DocumentSelectorOrNull is set", o.DocumentSelector != nil) + + if o.DocumentSelector != nil { + return json.Marshal(*o.DocumentSelector) } - var vTextDocumentFilterScheme TextDocumentFilterScheme - if err := json.Unmarshal(data, &vTextDocumentFilterScheme); err == nil { - o.TextDocumentFilterScheme = &vTextDocumentFilterScheme + // All fields are nil, represent as null + return []byte("null"), nil +} + +func (o *DocumentSelectorOrNull) UnmarshalJSON(data []byte) error { + *o = DocumentSelectorOrNull{} + + // Handle null case + if string(data) == "null" { return nil } - var vTextDocumentFilterPattern TextDocumentFilterPattern - if err := json.Unmarshal(data, &vTextDocumentFilterPattern); err == nil { - o.TextDocumentFilterPattern = &vTextDocumentFilterPattern + + var vDocumentSelector []TextDocumentFilterLanguageOrTextDocumentFilterSchemeOrTextDocumentFilterPatternOrNotebookCellTextDocumentFilter + if err := json.Unmarshal(data, &vDocumentSelector); err == nil { + o.DocumentSelector = &vDocumentSelector return nil } - return fmt.Errorf("invalid TextDocumentFilterLanguageOrTextDocumentFilterSchemeOrTextDocumentFilterPattern: %s", data) + return fmt.Errorf("invalid DocumentSelectorOrNull: %s", data) } -type NotebookDocumentFilterNotebookTypeOrNotebookDocumentFilterSchemeOrNotebookDocumentFilterPattern struct { - NotebookDocumentFilterNotebookType *NotebookDocumentFilterNotebookType - NotebookDocumentFilterScheme *NotebookDocumentFilterScheme - NotebookDocumentFilterPattern *NotebookDocumentFilterPattern +type IntegerOrString struct { + Integer *int32 + String *string } -func (o NotebookDocumentFilterNotebookTypeOrNotebookDocumentFilterSchemeOrNotebookDocumentFilterPattern) MarshalJSON() ([]byte, error) { - assertOnlyOne("more than one element of NotebookDocumentFilterNotebookTypeOrNotebookDocumentFilterSchemeOrNotebookDocumentFilterPattern is set", o.NotebookDocumentFilterNotebookType != nil, o.NotebookDocumentFilterScheme != nil, o.NotebookDocumentFilterPattern != nil) +func (o IntegerOrString) MarshalJSON() ([]byte, error) { + assertOnlyOne("more than one element of IntegerOrString is set", o.Integer != nil, o.String != nil) - if o.NotebookDocumentFilterNotebookType != nil { - return json.Marshal(*o.NotebookDocumentFilterNotebookType) - } - if o.NotebookDocumentFilterScheme != nil { - return json.Marshal(*o.NotebookDocumentFilterScheme) + if o.Integer != nil { + return json.Marshal(*o.Integer) } - if o.NotebookDocumentFilterPattern != nil { - return json.Marshal(*o.NotebookDocumentFilterPattern) + if o.String != nil { + return json.Marshal(*o.String) } panic("unreachable") } -func (o *NotebookDocumentFilterNotebookTypeOrNotebookDocumentFilterSchemeOrNotebookDocumentFilterPattern) UnmarshalJSON(data []byte) error { - *o = NotebookDocumentFilterNotebookTypeOrNotebookDocumentFilterSchemeOrNotebookDocumentFilterPattern{} - var vNotebookDocumentFilterNotebookType NotebookDocumentFilterNotebookType - if err := json.Unmarshal(data, &vNotebookDocumentFilterNotebookType); err == nil { - o.NotebookDocumentFilterNotebookType = &vNotebookDocumentFilterNotebookType - return nil - } - var vNotebookDocumentFilterScheme NotebookDocumentFilterScheme - if err := json.Unmarshal(data, &vNotebookDocumentFilterScheme); err == nil { - o.NotebookDocumentFilterScheme = &vNotebookDocumentFilterScheme +func (o *IntegerOrString) UnmarshalJSON(data []byte) error { + *o = IntegerOrString{} + + var vInteger int32 + if err := json.Unmarshal(data, &vInteger); err == nil { + o.Integer = &vInteger return nil } - var vNotebookDocumentFilterPattern NotebookDocumentFilterPattern - if err := json.Unmarshal(data, &vNotebookDocumentFilterPattern); err == nil { - o.NotebookDocumentFilterPattern = &vNotebookDocumentFilterPattern + var vString string + if err := json.Unmarshal(data, &vString); err == nil { + o.String = &vString return nil } - return fmt.Errorf("invalid NotebookDocumentFilterNotebookTypeOrNotebookDocumentFilterSchemeOrNotebookDocumentFilterPattern: %s", data) + return fmt.Errorf("invalid IntegerOrString: %s", data) } type TextDocumentEditOrCreateFileOrRenameFileOrDeleteFile struct { @@ -13735,6 +13739,7 @@ func (o TextDocumentEditOrCreateFileOrRenameFileOrDeleteFile) MarshalJSON() ([]b func (o *TextDocumentEditOrCreateFileOrRenameFileOrDeleteFile) UnmarshalJSON(data []byte) error { *o = TextDocumentEditOrCreateFileOrRenameFileOrDeleteFile{} + var vTextDocumentEdit TextDocumentEdit if err := json.Unmarshal(data, &vTextDocumentEdit); err == nil { o.TextDocumentEdit = &vTextDocumentEdit @@ -13777,6 +13782,7 @@ func (o StringOrInlayHintLabelParts) MarshalJSON() ([]byte, error) { func (o *StringOrInlayHintLabelParts) UnmarshalJSON(data []byte) error { *o = StringOrInlayHintLabelParts{} + var vString string if err := json.Unmarshal(data, &vString); err == nil { o.String = &vString @@ -13809,6 +13815,7 @@ func (o StringOrMarkupContent) MarshalJSON() ([]byte, error) { func (o *StringOrMarkupContent) UnmarshalJSON(data []byte) error { *o = StringOrMarkupContent{} + var vString string if err := json.Unmarshal(data, &vString); err == nil { o.String = &vString @@ -13841,6 +13848,7 @@ func (o FullDocumentDiagnosticReportOrUnchangedDocumentDiagnosticReport) Marshal func (o *FullDocumentDiagnosticReportOrUnchangedDocumentDiagnosticReport) UnmarshalJSON(data []byte) error { *o = FullDocumentDiagnosticReportOrUnchangedDocumentDiagnosticReport{} + var vFullDocumentDiagnosticReport FullDocumentDiagnosticReport if err := json.Unmarshal(data, &vFullDocumentDiagnosticReport); err == nil { o.FullDocumentDiagnosticReport = &vFullDocumentDiagnosticReport @@ -13854,6 +13862,39 @@ func (o *FullDocumentDiagnosticReportOrUnchangedDocumentDiagnosticReport) Unmars return fmt.Errorf("invalid FullDocumentDiagnosticReportOrUnchangedDocumentDiagnosticReport: %s", data) } +type WorkspaceFullDocumentDiagnosticReportOrUnchangedDocumentDiagnosticReport struct { + FullDocumentDiagnosticReport *WorkspaceFullDocumentDiagnosticReport + UnchangedDocumentDiagnosticReport *WorkspaceUnchangedDocumentDiagnosticReport +} + +func (o WorkspaceFullDocumentDiagnosticReportOrUnchangedDocumentDiagnosticReport) MarshalJSON() ([]byte, error) { + assertOnlyOne("more than one element of WorkspaceFullDocumentDiagnosticReportOrUnchangedDocumentDiagnosticReport is set", o.FullDocumentDiagnosticReport != nil, o.UnchangedDocumentDiagnosticReport != nil) + + if o.FullDocumentDiagnosticReport != nil { + return json.Marshal(*o.FullDocumentDiagnosticReport) + } + if o.UnchangedDocumentDiagnosticReport != nil { + return json.Marshal(*o.UnchangedDocumentDiagnosticReport) + } + panic("unreachable") +} + +func (o *WorkspaceFullDocumentDiagnosticReportOrUnchangedDocumentDiagnosticReport) UnmarshalJSON(data []byte) error { + *o = WorkspaceFullDocumentDiagnosticReportOrUnchangedDocumentDiagnosticReport{} + + var vFullDocumentDiagnosticReport WorkspaceFullDocumentDiagnosticReport + if err := json.Unmarshal(data, &vFullDocumentDiagnosticReport); err == nil { + o.FullDocumentDiagnosticReport = &vFullDocumentDiagnosticReport + return nil + } + var vUnchangedDocumentDiagnosticReport WorkspaceUnchangedDocumentDiagnosticReport + if err := json.Unmarshal(data, &vUnchangedDocumentDiagnosticReport); err == nil { + o.UnchangedDocumentDiagnosticReport = &vUnchangedDocumentDiagnosticReport + return nil + } + return fmt.Errorf("invalid WorkspaceFullDocumentDiagnosticReportOrUnchangedDocumentDiagnosticReport: %s", data) +} + type StringOrStringValue struct { String *string StringValue *StringValue @@ -13873,6 +13914,7 @@ func (o StringOrStringValue) MarshalJSON() ([]byte, error) { func (o *StringOrStringValue) UnmarshalJSON(data []byte) error { *o = StringOrStringValue{} + var vString string if err := json.Unmarshal(data, &vString); err == nil { o.String = &vString @@ -13905,6 +13947,7 @@ func (o StringOrStrings) MarshalJSON() ([]byte, error) { func (o *StringOrStrings) UnmarshalJSON(data []byte) error { *o = StringOrStrings{} + var vString string if err := json.Unmarshal(data, &vString); err == nil { o.String = &vString @@ -13918,6 +13961,39 @@ func (o *StringOrStrings) UnmarshalJSON(data []byte) error { return fmt.Errorf("invalid StringOrStrings: %s", data) } +type TextDocumentContentChangePartialOrWholeDocument struct { + Partial *TextDocumentContentChangePartial + WholeDocument *TextDocumentContentChangeWholeDocument +} + +func (o TextDocumentContentChangePartialOrWholeDocument) MarshalJSON() ([]byte, error) { + assertOnlyOne("more than one element of TextDocumentContentChangePartialOrWholeDocument is set", o.Partial != nil, o.WholeDocument != nil) + + if o.Partial != nil { + return json.Marshal(*o.Partial) + } + if o.WholeDocument != nil { + return json.Marshal(*o.WholeDocument) + } + panic("unreachable") +} + +func (o *TextDocumentContentChangePartialOrWholeDocument) UnmarshalJSON(data []byte) error { + *o = TextDocumentContentChangePartialOrWholeDocument{} + + var vPartial TextDocumentContentChangePartial + if err := json.Unmarshal(data, &vPartial); err == nil { + o.Partial = &vPartial + return nil + } + var vWholeDocument TextDocumentContentChangeWholeDocument + if err := json.Unmarshal(data, &vWholeDocument); err == nil { + o.WholeDocument = &vWholeDocument + return nil + } + return fmt.Errorf("invalid TextDocumentContentChangePartialOrWholeDocument: %s", data) +} + type TextEditOrInsertReplaceEdit struct { TextEdit *TextEdit InsertReplaceEdit *InsertReplaceEdit @@ -13937,6 +14013,7 @@ func (o TextEditOrInsertReplaceEdit) MarshalJSON() ([]byte, error) { func (o *TextEditOrInsertReplaceEdit) UnmarshalJSON(data []byte) error { *o = TextEditOrInsertReplaceEdit{} + var vTextEdit TextEdit if err := json.Unmarshal(data, &vTextEdit); err == nil { o.TextEdit = &vTextEdit @@ -13950,20 +14027,24 @@ func (o *TextEditOrInsertReplaceEdit) UnmarshalJSON(data []byte) error { return fmt.Errorf("invalid TextEditOrInsertReplaceEdit: %s", data) } -type MarkupContentOrMarkedStringOrMarkedStrings struct { - MarkupContent *MarkupContent - MarkedString *MarkedString - MarkedStrings *[]MarkedString +type MarkupContentOrStringOrMarkedStringWithLanguageOrMarkedStrings struct { + MarkupContent *MarkupContent + String *string + MarkedStringWithLanguage *MarkedStringWithLanguage + MarkedStrings *[]StringOrMarkedStringWithLanguage } -func (o MarkupContentOrMarkedStringOrMarkedStrings) MarshalJSON() ([]byte, error) { - assertOnlyOne("more than one element of MarkupContentOrMarkedStringOrMarkedStrings is set", o.MarkupContent != nil, o.MarkedString != nil, o.MarkedStrings != nil) +func (o MarkupContentOrStringOrMarkedStringWithLanguageOrMarkedStrings) MarshalJSON() ([]byte, error) { + assertOnlyOne("more than one element of MarkupContentOrStringOrMarkedStringWithLanguageOrMarkedStrings is set", o.MarkupContent != nil, o.String != nil, o.MarkedStringWithLanguage != nil, o.MarkedStrings != nil) if o.MarkupContent != nil { return json.Marshal(*o.MarkupContent) } - if o.MarkedString != nil { - return json.Marshal(*o.MarkedString) + if o.String != nil { + return json.Marshal(*o.String) + } + if o.MarkedStringWithLanguage != nil { + return json.Marshal(*o.MarkedStringWithLanguage) } if o.MarkedStrings != nil { return json.Marshal(*o.MarkedStrings) @@ -13971,45 +14052,82 @@ func (o MarkupContentOrMarkedStringOrMarkedStrings) MarshalJSON() ([]byte, error panic("unreachable") } -func (o *MarkupContentOrMarkedStringOrMarkedStrings) UnmarshalJSON(data []byte) error { - *o = MarkupContentOrMarkedStringOrMarkedStrings{} +func (o *MarkupContentOrStringOrMarkedStringWithLanguageOrMarkedStrings) UnmarshalJSON(data []byte) error { + *o = MarkupContentOrStringOrMarkedStringWithLanguageOrMarkedStrings{} + var vMarkupContent MarkupContent if err := json.Unmarshal(data, &vMarkupContent); err == nil { o.MarkupContent = &vMarkupContent return nil } - var vMarkedString MarkedString - if err := json.Unmarshal(data, &vMarkedString); err == nil { - o.MarkedString = &vMarkedString + var vString string + if err := json.Unmarshal(data, &vString); err == nil { + o.String = &vString + return nil + } + var vMarkedStringWithLanguage MarkedStringWithLanguage + if err := json.Unmarshal(data, &vMarkedStringWithLanguage); err == nil { + o.MarkedStringWithLanguage = &vMarkedStringWithLanguage return nil } - var vMarkedStrings []MarkedString + var vMarkedStrings []StringOrMarkedStringWithLanguage if err := json.Unmarshal(data, &vMarkedStrings); err == nil { o.MarkedStrings = &vMarkedStrings return nil } - return fmt.Errorf("invalid MarkupContentOrMarkedStringOrMarkedStrings: %s", data) + return fmt.Errorf("invalid MarkupContentOrStringOrMarkedStringWithLanguageOrMarkedStrings: %s", data) } -type LocationOrLocationUriOnly struct { - Location *Location - LocationUriOnly *LocationUriOnly +type UintegerOrNull struct { + Uinteger *uint32 } -func (o LocationOrLocationUriOnly) MarshalJSON() ([]byte, error) { - assertOnlyOne("more than one element of LocationOrLocationUriOnly is set", o.Location != nil, o.LocationUriOnly != nil) +func (o UintegerOrNull) MarshalJSON() ([]byte, error) { + assertAtMostOne("more than one element of UintegerOrNull is set", o.Uinteger != nil) - if o.Location != nil { - return json.Marshal(*o.Location) - } - if o.LocationUriOnly != nil { - return json.Marshal(*o.LocationUriOnly) + if o.Uinteger != nil { + return json.Marshal(*o.Uinteger) } - panic("unreachable") + // All fields are nil, represent as null + return []byte("null"), nil } -func (o *LocationOrLocationUriOnly) UnmarshalJSON(data []byte) error { +func (o *UintegerOrNull) UnmarshalJSON(data []byte) error { + *o = UintegerOrNull{} + + // Handle null case + if string(data) == "null" { + return nil + } + + var vUinteger uint32 + if err := json.Unmarshal(data, &vUinteger); err == nil { + o.Uinteger = &vUinteger + return nil + } + return fmt.Errorf("invalid UintegerOrNull: %s", data) +} + +type LocationOrLocationUriOnly struct { + Location *Location + LocationUriOnly *LocationUriOnly +} + +func (o LocationOrLocationUriOnly) MarshalJSON() ([]byte, error) { + assertOnlyOne("more than one element of LocationOrLocationUriOnly is set", o.Location != nil, o.LocationUriOnly != nil) + + if o.Location != nil { + return json.Marshal(*o.Location) + } + if o.LocationUriOnly != nil { + return json.Marshal(*o.LocationUriOnly) + } + panic("unreachable") +} + +func (o *LocationOrLocationUriOnly) UnmarshalJSON(data []byte) error { *o = LocationOrLocationUriOnly{} + var vLocation Location if err := json.Unmarshal(data, &vLocation); err == nil { o.Location = &vLocation @@ -14042,6 +14160,7 @@ func (o BooleanOrEmptyObject) MarshalJSON() ([]byte, error) { func (o *BooleanOrEmptyObject) UnmarshalJSON(data []byte) error { *o = BooleanOrEmptyObject{} + var vBoolean bool if err := json.Unmarshal(data, &vBoolean); err == nil { o.Boolean = &vBoolean @@ -14074,6 +14193,7 @@ func (o BooleanOrSemanticTokensFullDelta) MarshalJSON() ([]byte, error) { func (o *BooleanOrSemanticTokensFullDelta) UnmarshalJSON(data []byte) error { *o = BooleanOrSemanticTokensFullDelta{} + var vBoolean bool if err := json.Unmarshal(data, &vBoolean); err == nil { o.Boolean = &vBoolean @@ -14110,6 +14230,7 @@ func (o TextEditOrAnnotatedTextEditOrSnippetTextEdit) MarshalJSON() ([]byte, err func (o *TextEditOrAnnotatedTextEditOrSnippetTextEdit) UnmarshalJSON(data []byte) error { *o = TextEditOrAnnotatedTextEditOrSnippetTextEdit{} + var vTextEdit TextEdit if err := json.Unmarshal(data, &vTextEdit); err == nil { o.TextEdit = &vTextEdit @@ -14128,100 +14249,223 @@ func (o *TextEditOrAnnotatedTextEditOrSnippetTextEdit) UnmarshalJSON(data []byte return fmt.Errorf("invalid TextEditOrAnnotatedTextEditOrSnippetTextEdit: %s", data) } -type NotebookDocumentFilterWithNotebookOrNotebookDocumentFilterWithCells struct { - NotebookDocumentFilterWithNotebook *NotebookDocumentFilterWithNotebook - NotebookDocumentFilterWithCells *NotebookDocumentFilterWithCells +type NotebookDocumentFilterWithNotebookOrCells struct { + Notebook *NotebookDocumentFilterWithNotebook + Cells *NotebookDocumentFilterWithCells } -func (o NotebookDocumentFilterWithNotebookOrNotebookDocumentFilterWithCells) MarshalJSON() ([]byte, error) { - assertOnlyOne("more than one element of NotebookDocumentFilterWithNotebookOrNotebookDocumentFilterWithCells is set", o.NotebookDocumentFilterWithNotebook != nil, o.NotebookDocumentFilterWithCells != nil) +func (o NotebookDocumentFilterWithNotebookOrCells) MarshalJSON() ([]byte, error) { + assertOnlyOne("more than one element of NotebookDocumentFilterWithNotebookOrCells is set", o.Notebook != nil, o.Cells != nil) - if o.NotebookDocumentFilterWithNotebook != nil { - return json.Marshal(*o.NotebookDocumentFilterWithNotebook) + if o.Notebook != nil { + return json.Marshal(*o.Notebook) } - if o.NotebookDocumentFilterWithCells != nil { - return json.Marshal(*o.NotebookDocumentFilterWithCells) + if o.Cells != nil { + return json.Marshal(*o.Cells) } panic("unreachable") } -func (o *NotebookDocumentFilterWithNotebookOrNotebookDocumentFilterWithCells) UnmarshalJSON(data []byte) error { - *o = NotebookDocumentFilterWithNotebookOrNotebookDocumentFilterWithCells{} - var vNotebookDocumentFilterWithNotebook NotebookDocumentFilterWithNotebook - if err := json.Unmarshal(data, &vNotebookDocumentFilterWithNotebook); err == nil { - o.NotebookDocumentFilterWithNotebook = &vNotebookDocumentFilterWithNotebook +func (o *NotebookDocumentFilterWithNotebookOrCells) UnmarshalJSON(data []byte) error { + *o = NotebookDocumentFilterWithNotebookOrCells{} + + var vNotebook NotebookDocumentFilterWithNotebook + if err := json.Unmarshal(data, &vNotebook); err == nil { + o.Notebook = &vNotebook + return nil + } + var vCells NotebookDocumentFilterWithCells + if err := json.Unmarshal(data, &vCells); err == nil { + o.Cells = &vCells + return nil + } + return fmt.Errorf("invalid NotebookDocumentFilterWithNotebookOrCells: %s", data) +} + +type IntegerOrNull struct { + Integer *int32 +} + +func (o IntegerOrNull) MarshalJSON() ([]byte, error) { + assertAtMostOne("more than one element of IntegerOrNull is set", o.Integer != nil) + + if o.Integer != nil { + return json.Marshal(*o.Integer) + } + // All fields are nil, represent as null + return []byte("null"), nil +} + +func (o *IntegerOrNull) UnmarshalJSON(data []byte) error { + *o = IntegerOrNull{} + + // Handle null case + if string(data) == "null" { + return nil + } + + var vInteger int32 + if err := json.Unmarshal(data, &vInteger); err == nil { + o.Integer = &vInteger + return nil + } + return fmt.Errorf("invalid IntegerOrNull: %s", data) +} + +type StringOrNull struct { + String *string +} + +func (o StringOrNull) MarshalJSON() ([]byte, error) { + assertAtMostOne("more than one element of StringOrNull is set", o.String != nil) + + if o.String != nil { + return json.Marshal(*o.String) + } + // All fields are nil, represent as null + return []byte("null"), nil +} + +func (o *StringOrNull) UnmarshalJSON(data []byte) error { + *o = StringOrNull{} + + // Handle null case + if string(data) == "null" { + return nil + } + + var vString string + if err := json.Unmarshal(data, &vString); err == nil { + o.String = &vString + return nil + } + return fmt.Errorf("invalid StringOrNull: %s", data) +} + +type DocumentUriOrNull struct { + DocumentUri *DocumentUri +} + +func (o DocumentUriOrNull) MarshalJSON() ([]byte, error) { + assertAtMostOne("more than one element of DocumentUriOrNull is set", o.DocumentUri != nil) + + if o.DocumentUri != nil { + return json.Marshal(*o.DocumentUri) + } + // All fields are nil, represent as null + return []byte("null"), nil +} + +func (o *DocumentUriOrNull) UnmarshalJSON(data []byte) error { + *o = DocumentUriOrNull{} + + // Handle null case + if string(data) == "null" { + return nil + } + + var vDocumentUri DocumentUri + if err := json.Unmarshal(data, &vDocumentUri); err == nil { + o.DocumentUri = &vDocumentUri + return nil + } + return fmt.Errorf("invalid DocumentUriOrNull: %s", data) +} + +type WorkspaceFoldersOrNull struct { + WorkspaceFolders *[]*WorkspaceFolder +} + +func (o WorkspaceFoldersOrNull) MarshalJSON() ([]byte, error) { + assertAtMostOne("more than one element of WorkspaceFoldersOrNull is set", o.WorkspaceFolders != nil) + + if o.WorkspaceFolders != nil { + return json.Marshal(*o.WorkspaceFolders) + } + // All fields are nil, represent as null + return []byte("null"), nil +} + +func (o *WorkspaceFoldersOrNull) UnmarshalJSON(data []byte) error { + *o = WorkspaceFoldersOrNull{} + + // Handle null case + if string(data) == "null" { return nil } - var vNotebookDocumentFilterWithCells NotebookDocumentFilterWithCells - if err := json.Unmarshal(data, &vNotebookDocumentFilterWithCells); err == nil { - o.NotebookDocumentFilterWithCells = &vNotebookDocumentFilterWithCells + + var vWorkspaceFolders []*WorkspaceFolder + if err := json.Unmarshal(data, &vWorkspaceFolders); err == nil { + o.WorkspaceFolders = &vWorkspaceFolders return nil } - return fmt.Errorf("invalid NotebookDocumentFilterWithNotebookOrNotebookDocumentFilterWithCells: %s", data) + return fmt.Errorf("invalid WorkspaceFoldersOrNull: %s", data) } -type TextDocumentSyncOptionsOrTextDocumentSyncKind struct { - TextDocumentSyncOptions *TextDocumentSyncOptions - TextDocumentSyncKind *TextDocumentSyncKind +type TextDocumentSyncOptionsOrKind struct { + Options *TextDocumentSyncOptions + Kind *TextDocumentSyncKind } -func (o TextDocumentSyncOptionsOrTextDocumentSyncKind) MarshalJSON() ([]byte, error) { - assertOnlyOne("more than one element of TextDocumentSyncOptionsOrTextDocumentSyncKind is set", o.TextDocumentSyncOptions != nil, o.TextDocumentSyncKind != nil) +func (o TextDocumentSyncOptionsOrKind) MarshalJSON() ([]byte, error) { + assertOnlyOne("more than one element of TextDocumentSyncOptionsOrKind is set", o.Options != nil, o.Kind != nil) - if o.TextDocumentSyncOptions != nil { - return json.Marshal(*o.TextDocumentSyncOptions) + if o.Options != nil { + return json.Marshal(*o.Options) } - if o.TextDocumentSyncKind != nil { - return json.Marshal(*o.TextDocumentSyncKind) + if o.Kind != nil { + return json.Marshal(*o.Kind) } panic("unreachable") } -func (o *TextDocumentSyncOptionsOrTextDocumentSyncKind) UnmarshalJSON(data []byte) error { - *o = TextDocumentSyncOptionsOrTextDocumentSyncKind{} - var vTextDocumentSyncOptions TextDocumentSyncOptions - if err := json.Unmarshal(data, &vTextDocumentSyncOptions); err == nil { - o.TextDocumentSyncOptions = &vTextDocumentSyncOptions +func (o *TextDocumentSyncOptionsOrKind) UnmarshalJSON(data []byte) error { + *o = TextDocumentSyncOptionsOrKind{} + + var vOptions TextDocumentSyncOptions + if err := json.Unmarshal(data, &vOptions); err == nil { + o.Options = &vOptions return nil } - var vTextDocumentSyncKind TextDocumentSyncKind - if err := json.Unmarshal(data, &vTextDocumentSyncKind); err == nil { - o.TextDocumentSyncKind = &vTextDocumentSyncKind + var vKind TextDocumentSyncKind + if err := json.Unmarshal(data, &vKind); err == nil { + o.Kind = &vKind return nil } - return fmt.Errorf("invalid TextDocumentSyncOptionsOrTextDocumentSyncKind: %s", data) + return fmt.Errorf("invalid TextDocumentSyncOptionsOrKind: %s", data) } -type NotebookDocumentSyncOptionsOrNotebookDocumentSyncRegistrationOptions struct { - NotebookDocumentSyncOptions *NotebookDocumentSyncOptions - NotebookDocumentSyncRegistrationOptions *NotebookDocumentSyncRegistrationOptions +type NotebookDocumentSyncOptionsOrRegistrationOptions struct { + Options *NotebookDocumentSyncOptions + RegistrationOptions *NotebookDocumentSyncRegistrationOptions } -func (o NotebookDocumentSyncOptionsOrNotebookDocumentSyncRegistrationOptions) MarshalJSON() ([]byte, error) { - assertOnlyOne("more than one element of NotebookDocumentSyncOptionsOrNotebookDocumentSyncRegistrationOptions is set", o.NotebookDocumentSyncOptions != nil, o.NotebookDocumentSyncRegistrationOptions != nil) +func (o NotebookDocumentSyncOptionsOrRegistrationOptions) MarshalJSON() ([]byte, error) { + assertOnlyOne("more than one element of NotebookDocumentSyncOptionsOrRegistrationOptions is set", o.Options != nil, o.RegistrationOptions != nil) - if o.NotebookDocumentSyncOptions != nil { - return json.Marshal(*o.NotebookDocumentSyncOptions) + if o.Options != nil { + return json.Marshal(*o.Options) } - if o.NotebookDocumentSyncRegistrationOptions != nil { - return json.Marshal(*o.NotebookDocumentSyncRegistrationOptions) + if o.RegistrationOptions != nil { + return json.Marshal(*o.RegistrationOptions) } panic("unreachable") } -func (o *NotebookDocumentSyncOptionsOrNotebookDocumentSyncRegistrationOptions) UnmarshalJSON(data []byte) error { - *o = NotebookDocumentSyncOptionsOrNotebookDocumentSyncRegistrationOptions{} - var vNotebookDocumentSyncOptions NotebookDocumentSyncOptions - if err := json.Unmarshal(data, &vNotebookDocumentSyncOptions); err == nil { - o.NotebookDocumentSyncOptions = &vNotebookDocumentSyncOptions +func (o *NotebookDocumentSyncOptionsOrRegistrationOptions) UnmarshalJSON(data []byte) error { + *o = NotebookDocumentSyncOptionsOrRegistrationOptions{} + + var vOptions NotebookDocumentSyncOptions + if err := json.Unmarshal(data, &vOptions); err == nil { + o.Options = &vOptions return nil } - var vNotebookDocumentSyncRegistrationOptions NotebookDocumentSyncRegistrationOptions - if err := json.Unmarshal(data, &vNotebookDocumentSyncRegistrationOptions); err == nil { - o.NotebookDocumentSyncRegistrationOptions = &vNotebookDocumentSyncRegistrationOptions + var vRegistrationOptions NotebookDocumentSyncRegistrationOptions + if err := json.Unmarshal(data, &vRegistrationOptions); err == nil { + o.RegistrationOptions = &vRegistrationOptions return nil } - return fmt.Errorf("invalid NotebookDocumentSyncOptionsOrNotebookDocumentSyncRegistrationOptions: %s", data) + return fmt.Errorf("invalid NotebookDocumentSyncOptionsOrRegistrationOptions: %s", data) } type BooleanOrHoverOptions struct { @@ -14243,6 +14487,7 @@ func (o BooleanOrHoverOptions) MarshalJSON() ([]byte, error) { func (o *BooleanOrHoverOptions) UnmarshalJSON(data []byte) error { *o = BooleanOrHoverOptions{} + var vBoolean bool if err := json.Unmarshal(data, &vBoolean); err == nil { o.Boolean = &vBoolean @@ -14279,6 +14524,7 @@ func (o BooleanOrDeclarationOptionsOrDeclarationRegistrationOptions) MarshalJSON func (o *BooleanOrDeclarationOptionsOrDeclarationRegistrationOptions) UnmarshalJSON(data []byte) error { *o = BooleanOrDeclarationOptionsOrDeclarationRegistrationOptions{} + var vBoolean bool if err := json.Unmarshal(data, &vBoolean); err == nil { o.Boolean = &vBoolean @@ -14316,6 +14562,7 @@ func (o BooleanOrDefinitionOptions) MarshalJSON() ([]byte, error) { func (o *BooleanOrDefinitionOptions) UnmarshalJSON(data []byte) error { *o = BooleanOrDefinitionOptions{} + var vBoolean bool if err := json.Unmarshal(data, &vBoolean); err == nil { o.Boolean = &vBoolean @@ -14352,6 +14599,7 @@ func (o BooleanOrTypeDefinitionOptionsOrTypeDefinitionRegistrationOptions) Marsh func (o *BooleanOrTypeDefinitionOptionsOrTypeDefinitionRegistrationOptions) UnmarshalJSON(data []byte) error { *o = BooleanOrTypeDefinitionOptionsOrTypeDefinitionRegistrationOptions{} + var vBoolean bool if err := json.Unmarshal(data, &vBoolean); err == nil { o.Boolean = &vBoolean @@ -14393,6 +14641,7 @@ func (o BooleanOrImplementationOptionsOrImplementationRegistrationOptions) Marsh func (o *BooleanOrImplementationOptionsOrImplementationRegistrationOptions) UnmarshalJSON(data []byte) error { *o = BooleanOrImplementationOptionsOrImplementationRegistrationOptions{} + var vBoolean bool if err := json.Unmarshal(data, &vBoolean); err == nil { o.Boolean = &vBoolean @@ -14430,6 +14679,7 @@ func (o BooleanOrReferenceOptions) MarshalJSON() ([]byte, error) { func (o *BooleanOrReferenceOptions) UnmarshalJSON(data []byte) error { *o = BooleanOrReferenceOptions{} + var vBoolean bool if err := json.Unmarshal(data, &vBoolean); err == nil { o.Boolean = &vBoolean @@ -14462,6 +14712,7 @@ func (o BooleanOrDocumentHighlightOptions) MarshalJSON() ([]byte, error) { func (o *BooleanOrDocumentHighlightOptions) UnmarshalJSON(data []byte) error { *o = BooleanOrDocumentHighlightOptions{} + var vBoolean bool if err := json.Unmarshal(data, &vBoolean); err == nil { o.Boolean = &vBoolean @@ -14494,6 +14745,7 @@ func (o BooleanOrDocumentSymbolOptions) MarshalJSON() ([]byte, error) { func (o *BooleanOrDocumentSymbolOptions) UnmarshalJSON(data []byte) error { *o = BooleanOrDocumentSymbolOptions{} + var vBoolean bool if err := json.Unmarshal(data, &vBoolean); err == nil { o.Boolean = &vBoolean @@ -14526,6 +14778,7 @@ func (o BooleanOrCodeActionOptions) MarshalJSON() ([]byte, error) { func (o *BooleanOrCodeActionOptions) UnmarshalJSON(data []byte) error { *o = BooleanOrCodeActionOptions{} + var vBoolean bool if err := json.Unmarshal(data, &vBoolean); err == nil { o.Boolean = &vBoolean @@ -14562,6 +14815,7 @@ func (o BooleanOrDocumentColorOptionsOrDocumentColorRegistrationOptions) Marshal func (o *BooleanOrDocumentColorOptionsOrDocumentColorRegistrationOptions) UnmarshalJSON(data []byte) error { *o = BooleanOrDocumentColorOptionsOrDocumentColorRegistrationOptions{} + var vBoolean bool if err := json.Unmarshal(data, &vBoolean); err == nil { o.Boolean = &vBoolean @@ -14599,6 +14853,7 @@ func (o BooleanOrWorkspaceSymbolOptions) MarshalJSON() ([]byte, error) { func (o *BooleanOrWorkspaceSymbolOptions) UnmarshalJSON(data []byte) error { *o = BooleanOrWorkspaceSymbolOptions{} + var vBoolean bool if err := json.Unmarshal(data, &vBoolean); err == nil { o.Boolean = &vBoolean @@ -14631,6 +14886,7 @@ func (o BooleanOrDocumentFormattingOptions) MarshalJSON() ([]byte, error) { func (o *BooleanOrDocumentFormattingOptions) UnmarshalJSON(data []byte) error { *o = BooleanOrDocumentFormattingOptions{} + var vBoolean bool if err := json.Unmarshal(data, &vBoolean); err == nil { o.Boolean = &vBoolean @@ -14663,6 +14919,7 @@ func (o BooleanOrDocumentRangeFormattingOptions) MarshalJSON() ([]byte, error) { func (o *BooleanOrDocumentRangeFormattingOptions) UnmarshalJSON(data []byte) error { *o = BooleanOrDocumentRangeFormattingOptions{} + var vBoolean bool if err := json.Unmarshal(data, &vBoolean); err == nil { o.Boolean = &vBoolean @@ -14695,6 +14952,7 @@ func (o BooleanOrRenameOptions) MarshalJSON() ([]byte, error) { func (o *BooleanOrRenameOptions) UnmarshalJSON(data []byte) error { *o = BooleanOrRenameOptions{} + var vBoolean bool if err := json.Unmarshal(data, &vBoolean); err == nil { o.Boolean = &vBoolean @@ -14731,6 +14989,7 @@ func (o BooleanOrFoldingRangeOptionsOrFoldingRangeRegistrationOptions) MarshalJS func (o *BooleanOrFoldingRangeOptionsOrFoldingRangeRegistrationOptions) UnmarshalJSON(data []byte) error { *o = BooleanOrFoldingRangeOptionsOrFoldingRangeRegistrationOptions{} + var vBoolean bool if err := json.Unmarshal(data, &vBoolean); err == nil { o.Boolean = &vBoolean @@ -14772,6 +15031,7 @@ func (o BooleanOrSelectionRangeOptionsOrSelectionRangeRegistrationOptions) Marsh func (o *BooleanOrSelectionRangeOptionsOrSelectionRangeRegistrationOptions) UnmarshalJSON(data []byte) error { *o = BooleanOrSelectionRangeOptionsOrSelectionRangeRegistrationOptions{} + var vBoolean bool if err := json.Unmarshal(data, &vBoolean); err == nil { o.Boolean = &vBoolean @@ -14813,6 +15073,7 @@ func (o BooleanOrCallHierarchyOptionsOrCallHierarchyRegistrationOptions) Marshal func (o *BooleanOrCallHierarchyOptionsOrCallHierarchyRegistrationOptions) UnmarshalJSON(data []byte) error { *o = BooleanOrCallHierarchyOptionsOrCallHierarchyRegistrationOptions{} + var vBoolean bool if err := json.Unmarshal(data, &vBoolean); err == nil { o.Boolean = &vBoolean @@ -14854,6 +15115,7 @@ func (o BooleanOrLinkedEditingRangeOptionsOrLinkedEditingRangeRegistrationOption func (o *BooleanOrLinkedEditingRangeOptionsOrLinkedEditingRangeRegistrationOptions) UnmarshalJSON(data []byte) error { *o = BooleanOrLinkedEditingRangeOptionsOrLinkedEditingRangeRegistrationOptions{} + var vBoolean bool if err := json.Unmarshal(data, &vBoolean); err == nil { o.Boolean = &vBoolean @@ -14872,36 +15134,37 @@ func (o *BooleanOrLinkedEditingRangeOptionsOrLinkedEditingRangeRegistrationOptio return fmt.Errorf("invalid BooleanOrLinkedEditingRangeOptionsOrLinkedEditingRangeRegistrationOptions: %s", data) } -type SemanticTokensOptionsOrSemanticTokensRegistrationOptions struct { - SemanticTokensOptions *SemanticTokensOptions - SemanticTokensRegistrationOptions *SemanticTokensRegistrationOptions +type SemanticTokensOptionsOrRegistrationOptions struct { + Options *SemanticTokensOptions + RegistrationOptions *SemanticTokensRegistrationOptions } -func (o SemanticTokensOptionsOrSemanticTokensRegistrationOptions) MarshalJSON() ([]byte, error) { - assertOnlyOne("more than one element of SemanticTokensOptionsOrSemanticTokensRegistrationOptions is set", o.SemanticTokensOptions != nil, o.SemanticTokensRegistrationOptions != nil) +func (o SemanticTokensOptionsOrRegistrationOptions) MarshalJSON() ([]byte, error) { + assertOnlyOne("more than one element of SemanticTokensOptionsOrRegistrationOptions is set", o.Options != nil, o.RegistrationOptions != nil) - if o.SemanticTokensOptions != nil { - return json.Marshal(*o.SemanticTokensOptions) + if o.Options != nil { + return json.Marshal(*o.Options) } - if o.SemanticTokensRegistrationOptions != nil { - return json.Marshal(*o.SemanticTokensRegistrationOptions) + if o.RegistrationOptions != nil { + return json.Marshal(*o.RegistrationOptions) } panic("unreachable") } -func (o *SemanticTokensOptionsOrSemanticTokensRegistrationOptions) UnmarshalJSON(data []byte) error { - *o = SemanticTokensOptionsOrSemanticTokensRegistrationOptions{} - var vSemanticTokensOptions SemanticTokensOptions - if err := json.Unmarshal(data, &vSemanticTokensOptions); err == nil { - o.SemanticTokensOptions = &vSemanticTokensOptions +func (o *SemanticTokensOptionsOrRegistrationOptions) UnmarshalJSON(data []byte) error { + *o = SemanticTokensOptionsOrRegistrationOptions{} + + var vOptions SemanticTokensOptions + if err := json.Unmarshal(data, &vOptions); err == nil { + o.Options = &vOptions return nil } - var vSemanticTokensRegistrationOptions SemanticTokensRegistrationOptions - if err := json.Unmarshal(data, &vSemanticTokensRegistrationOptions); err == nil { - o.SemanticTokensRegistrationOptions = &vSemanticTokensRegistrationOptions + var vRegistrationOptions SemanticTokensRegistrationOptions + if err := json.Unmarshal(data, &vRegistrationOptions); err == nil { + o.RegistrationOptions = &vRegistrationOptions return nil } - return fmt.Errorf("invalid SemanticTokensOptionsOrSemanticTokensRegistrationOptions: %s", data) + return fmt.Errorf("invalid SemanticTokensOptionsOrRegistrationOptions: %s", data) } type BooleanOrMonikerOptionsOrMonikerRegistrationOptions struct { @@ -14927,6 +15190,7 @@ func (o BooleanOrMonikerOptionsOrMonikerRegistrationOptions) MarshalJSON() ([]by func (o *BooleanOrMonikerOptionsOrMonikerRegistrationOptions) UnmarshalJSON(data []byte) error { *o = BooleanOrMonikerOptionsOrMonikerRegistrationOptions{} + var vBoolean bool if err := json.Unmarshal(data, &vBoolean); err == nil { o.Boolean = &vBoolean @@ -14968,6 +15232,7 @@ func (o BooleanOrTypeHierarchyOptionsOrTypeHierarchyRegistrationOptions) Marshal func (o *BooleanOrTypeHierarchyOptionsOrTypeHierarchyRegistrationOptions) UnmarshalJSON(data []byte) error { *o = BooleanOrTypeHierarchyOptionsOrTypeHierarchyRegistrationOptions{} + var vBoolean bool if err := json.Unmarshal(data, &vBoolean); err == nil { o.Boolean = &vBoolean @@ -15009,6 +15274,7 @@ func (o BooleanOrInlineValueOptionsOrInlineValueRegistrationOptions) MarshalJSON func (o *BooleanOrInlineValueOptionsOrInlineValueRegistrationOptions) UnmarshalJSON(data []byte) error { *o = BooleanOrInlineValueOptionsOrInlineValueRegistrationOptions{} + var vBoolean bool if err := json.Unmarshal(data, &vBoolean); err == nil { o.Boolean = &vBoolean @@ -15050,6 +15316,7 @@ func (o BooleanOrInlayHintOptionsOrInlayHintRegistrationOptions) MarshalJSON() ( func (o *BooleanOrInlayHintOptionsOrInlayHintRegistrationOptions) UnmarshalJSON(data []byte) error { *o = BooleanOrInlayHintOptionsOrInlayHintRegistrationOptions{} + var vBoolean bool if err := json.Unmarshal(data, &vBoolean); err == nil { o.Boolean = &vBoolean @@ -15068,36 +15335,37 @@ func (o *BooleanOrInlayHintOptionsOrInlayHintRegistrationOptions) UnmarshalJSON( return fmt.Errorf("invalid BooleanOrInlayHintOptionsOrInlayHintRegistrationOptions: %s", data) } -type DiagnosticOptionsOrDiagnosticRegistrationOptions struct { - DiagnosticOptions *DiagnosticOptions - DiagnosticRegistrationOptions *DiagnosticRegistrationOptions +type DiagnosticOptionsOrRegistrationOptions struct { + Options *DiagnosticOptions + RegistrationOptions *DiagnosticRegistrationOptions } -func (o DiagnosticOptionsOrDiagnosticRegistrationOptions) MarshalJSON() ([]byte, error) { - assertOnlyOne("more than one element of DiagnosticOptionsOrDiagnosticRegistrationOptions is set", o.DiagnosticOptions != nil, o.DiagnosticRegistrationOptions != nil) +func (o DiagnosticOptionsOrRegistrationOptions) MarshalJSON() ([]byte, error) { + assertOnlyOne("more than one element of DiagnosticOptionsOrRegistrationOptions is set", o.Options != nil, o.RegistrationOptions != nil) - if o.DiagnosticOptions != nil { - return json.Marshal(*o.DiagnosticOptions) + if o.Options != nil { + return json.Marshal(*o.Options) } - if o.DiagnosticRegistrationOptions != nil { - return json.Marshal(*o.DiagnosticRegistrationOptions) + if o.RegistrationOptions != nil { + return json.Marshal(*o.RegistrationOptions) } panic("unreachable") } -func (o *DiagnosticOptionsOrDiagnosticRegistrationOptions) UnmarshalJSON(data []byte) error { - *o = DiagnosticOptionsOrDiagnosticRegistrationOptions{} - var vDiagnosticOptions DiagnosticOptions - if err := json.Unmarshal(data, &vDiagnosticOptions); err == nil { - o.DiagnosticOptions = &vDiagnosticOptions +func (o *DiagnosticOptionsOrRegistrationOptions) UnmarshalJSON(data []byte) error { + *o = DiagnosticOptionsOrRegistrationOptions{} + + var vOptions DiagnosticOptions + if err := json.Unmarshal(data, &vOptions); err == nil { + o.Options = &vOptions return nil } - var vDiagnosticRegistrationOptions DiagnosticRegistrationOptions - if err := json.Unmarshal(data, &vDiagnosticRegistrationOptions); err == nil { - o.DiagnosticRegistrationOptions = &vDiagnosticRegistrationOptions + var vRegistrationOptions DiagnosticRegistrationOptions + if err := json.Unmarshal(data, &vRegistrationOptions); err == nil { + o.RegistrationOptions = &vRegistrationOptions return nil } - return fmt.Errorf("invalid DiagnosticOptionsOrDiagnosticRegistrationOptions: %s", data) + return fmt.Errorf("invalid DiagnosticOptionsOrRegistrationOptions: %s", data) } type BooleanOrInlineCompletionOptions struct { @@ -15119,6 +15387,7 @@ func (o BooleanOrInlineCompletionOptions) MarshalJSON() ([]byte, error) { func (o *BooleanOrInlineCompletionOptions) UnmarshalJSON(data []byte) error { *o = BooleanOrInlineCompletionOptions{} + var vBoolean bool if err := json.Unmarshal(data, &vBoolean); err == nil { o.Boolean = &vBoolean @@ -15132,6 +15401,39 @@ func (o *BooleanOrInlineCompletionOptions) UnmarshalJSON(data []byte) error { return fmt.Errorf("invalid BooleanOrInlineCompletionOptions: %s", data) } +type PatternOrRelativePattern struct { + Pattern *string + RelativePattern *RelativePattern +} + +func (o PatternOrRelativePattern) MarshalJSON() ([]byte, error) { + assertOnlyOne("more than one element of PatternOrRelativePattern is set", o.Pattern != nil, o.RelativePattern != nil) + + if o.Pattern != nil { + return json.Marshal(*o.Pattern) + } + if o.RelativePattern != nil { + return json.Marshal(*o.RelativePattern) + } + panic("unreachable") +} + +func (o *PatternOrRelativePattern) UnmarshalJSON(data []byte) error { + *o = PatternOrRelativePattern{} + + var vPattern string + if err := json.Unmarshal(data, &vPattern); err == nil { + o.Pattern = &vPattern + return nil + } + var vRelativePattern RelativePattern + if err := json.Unmarshal(data, &vRelativePattern); err == nil { + o.RelativePattern = &vRelativePattern + return nil + } + return fmt.Errorf("invalid PatternOrRelativePattern: %s", data) +} + type RangeOrEditRangeWithInsertReplace struct { Range *Range EditRangeWithInsertReplace *EditRangeWithInsertReplace @@ -15151,6 +15453,7 @@ func (o RangeOrEditRangeWithInsertReplace) MarshalJSON() ([]byte, error) { func (o *RangeOrEditRangeWithInsertReplace) UnmarshalJSON(data []byte) error { *o = RangeOrEditRangeWithInsertReplace{} + var vRange Range if err := json.Unmarshal(data, &vRange); err == nil { o.Range = &vRange @@ -15164,36 +15467,55 @@ func (o *RangeOrEditRangeWithInsertReplace) UnmarshalJSON(data []byte) error { return fmt.Errorf("invalid RangeOrEditRangeWithInsertReplace: %s", data) } -type StringOrNotebookDocumentFilter struct { - String *string - NotebookDocumentFilter *NotebookDocumentFilter +type StringOrNotebookDocumentFilterNotebookTypeOrNotebookDocumentFilterSchemeOrNotebookDocumentFilterPattern struct { + String *string + NotebookDocumentFilterNotebookType *NotebookDocumentFilterNotebookType + NotebookDocumentFilterScheme *NotebookDocumentFilterScheme + NotebookDocumentFilterPattern *NotebookDocumentFilterPattern } -func (o StringOrNotebookDocumentFilter) MarshalJSON() ([]byte, error) { - assertOnlyOne("more than one element of StringOrNotebookDocumentFilter is set", o.String != nil, o.NotebookDocumentFilter != nil) +func (o StringOrNotebookDocumentFilterNotebookTypeOrNotebookDocumentFilterSchemeOrNotebookDocumentFilterPattern) MarshalJSON() ([]byte, error) { + assertOnlyOne("more than one element of StringOrNotebookDocumentFilterNotebookTypeOrNotebookDocumentFilterSchemeOrNotebookDocumentFilterPattern is set", o.String != nil, o.NotebookDocumentFilterNotebookType != nil, o.NotebookDocumentFilterScheme != nil, o.NotebookDocumentFilterPattern != nil) if o.String != nil { return json.Marshal(*o.String) } - if o.NotebookDocumentFilter != nil { - return json.Marshal(*o.NotebookDocumentFilter) + if o.NotebookDocumentFilterNotebookType != nil { + return json.Marshal(*o.NotebookDocumentFilterNotebookType) + } + if o.NotebookDocumentFilterScheme != nil { + return json.Marshal(*o.NotebookDocumentFilterScheme) + } + if o.NotebookDocumentFilterPattern != nil { + return json.Marshal(*o.NotebookDocumentFilterPattern) } panic("unreachable") } -func (o *StringOrNotebookDocumentFilter) UnmarshalJSON(data []byte) error { - *o = StringOrNotebookDocumentFilter{} +func (o *StringOrNotebookDocumentFilterNotebookTypeOrNotebookDocumentFilterSchemeOrNotebookDocumentFilterPattern) UnmarshalJSON(data []byte) error { + *o = StringOrNotebookDocumentFilterNotebookTypeOrNotebookDocumentFilterSchemeOrNotebookDocumentFilterPattern{} + var vString string if err := json.Unmarshal(data, &vString); err == nil { o.String = &vString return nil } - var vNotebookDocumentFilter NotebookDocumentFilter - if err := json.Unmarshal(data, &vNotebookDocumentFilter); err == nil { - o.NotebookDocumentFilter = &vNotebookDocumentFilter + var vNotebookDocumentFilterNotebookType NotebookDocumentFilterNotebookType + if err := json.Unmarshal(data, &vNotebookDocumentFilterNotebookType); err == nil { + o.NotebookDocumentFilterNotebookType = &vNotebookDocumentFilterNotebookType + return nil + } + var vNotebookDocumentFilterScheme NotebookDocumentFilterScheme + if err := json.Unmarshal(data, &vNotebookDocumentFilterScheme); err == nil { + o.NotebookDocumentFilterScheme = &vNotebookDocumentFilterScheme return nil } - return fmt.Errorf("invalid StringOrNotebookDocumentFilter: %s", data) + var vNotebookDocumentFilterPattern NotebookDocumentFilterPattern + if err := json.Unmarshal(data, &vNotebookDocumentFilterPattern); err == nil { + o.NotebookDocumentFilterPattern = &vNotebookDocumentFilterPattern + return nil + } + return fmt.Errorf("invalid StringOrNotebookDocumentFilterNotebookTypeOrNotebookDocumentFilterSchemeOrNotebookDocumentFilterPattern: %s", data) } type BooleanOrSaveOptions struct { @@ -15215,6 +15537,7 @@ func (o BooleanOrSaveOptions) MarshalJSON() ([]byte, error) { func (o *BooleanOrSaveOptions) UnmarshalJSON(data []byte) error { *o = BooleanOrSaveOptions{} + var vBoolean bool if err := json.Unmarshal(data, &vBoolean); err == nil { o.Boolean = &vBoolean @@ -15228,36 +15551,37 @@ func (o *BooleanOrSaveOptions) UnmarshalJSON(data []byte) error { return fmt.Errorf("invalid BooleanOrSaveOptions: %s", data) } -type TextDocumentContentOptionsOrTextDocumentContentRegistrationOptions struct { - TextDocumentContentOptions *TextDocumentContentOptions - TextDocumentContentRegistrationOptions *TextDocumentContentRegistrationOptions +type TextDocumentContentOptionsOrRegistrationOptions struct { + Options *TextDocumentContentOptions + RegistrationOptions *TextDocumentContentRegistrationOptions } -func (o TextDocumentContentOptionsOrTextDocumentContentRegistrationOptions) MarshalJSON() ([]byte, error) { - assertOnlyOne("more than one element of TextDocumentContentOptionsOrTextDocumentContentRegistrationOptions is set", o.TextDocumentContentOptions != nil, o.TextDocumentContentRegistrationOptions != nil) +func (o TextDocumentContentOptionsOrRegistrationOptions) MarshalJSON() ([]byte, error) { + assertOnlyOne("more than one element of TextDocumentContentOptionsOrRegistrationOptions is set", o.Options != nil, o.RegistrationOptions != nil) - if o.TextDocumentContentOptions != nil { - return json.Marshal(*o.TextDocumentContentOptions) + if o.Options != nil { + return json.Marshal(*o.Options) } - if o.TextDocumentContentRegistrationOptions != nil { - return json.Marshal(*o.TextDocumentContentRegistrationOptions) + if o.RegistrationOptions != nil { + return json.Marshal(*o.RegistrationOptions) } panic("unreachable") } -func (o *TextDocumentContentOptionsOrTextDocumentContentRegistrationOptions) UnmarshalJSON(data []byte) error { - *o = TextDocumentContentOptionsOrTextDocumentContentRegistrationOptions{} - var vTextDocumentContentOptions TextDocumentContentOptions - if err := json.Unmarshal(data, &vTextDocumentContentOptions); err == nil { - o.TextDocumentContentOptions = &vTextDocumentContentOptions +func (o *TextDocumentContentOptionsOrRegistrationOptions) UnmarshalJSON(data []byte) error { + *o = TextDocumentContentOptionsOrRegistrationOptions{} + + var vOptions TextDocumentContentOptions + if err := json.Unmarshal(data, &vOptions); err == nil { + o.Options = &vOptions return nil } - var vTextDocumentContentRegistrationOptions TextDocumentContentRegistrationOptions - if err := json.Unmarshal(data, &vTextDocumentContentRegistrationOptions); err == nil { - o.TextDocumentContentRegistrationOptions = &vTextDocumentContentRegistrationOptions + var vRegistrationOptions TextDocumentContentRegistrationOptions + if err := json.Unmarshal(data, &vRegistrationOptions); err == nil { + o.RegistrationOptions = &vRegistrationOptions return nil } - return fmt.Errorf("invalid TextDocumentContentOptionsOrTextDocumentContentRegistrationOptions: %s", data) + return fmt.Errorf("invalid TextDocumentContentOptionsOrRegistrationOptions: %s", data) } type StringOrTuple struct { @@ -15279,6 +15603,7 @@ func (o StringOrTuple) MarshalJSON() ([]byte, error) { func (o *StringOrTuple) UnmarshalJSON(data []byte) error { *o = StringOrTuple{} + var vString string if err := json.Unmarshal(data, &vString); err == nil { o.String = &vString @@ -15311,6 +15636,7 @@ func (o StringOrBoolean) MarshalJSON() ([]byte, error) { func (o *StringOrBoolean) UnmarshalJSON(data []byte) error { *o = StringOrBoolean{} + var vString string if err := json.Unmarshal(data, &vString); err == nil { o.String = &vString @@ -15343,6 +15669,7 @@ func (o WorkspaceFolderOrURI) MarshalJSON() ([]byte, error) { func (o *WorkspaceFolderOrURI) UnmarshalJSON(data []byte) error { *o = WorkspaceFolderOrURI{} + var vWorkspaceFolder WorkspaceFolder if err := json.Unmarshal(data, &vWorkspaceFolder); err == nil { o.WorkspaceFolder = &vWorkspaceFolder @@ -15375,6 +15702,7 @@ func (o BooleanOrClientSemanticTokensRequestFullDelta) MarshalJSON() ([]byte, er func (o *BooleanOrClientSemanticTokensRequestFullDelta) UnmarshalJSON(data []byte) error { *o = BooleanOrClientSemanticTokensRequestFullDelta{} + var vBoolean bool if err := json.Unmarshal(data, &vBoolean); err == nil { o.Boolean = &vBoolean @@ -15388,6 +15716,489 @@ func (o *BooleanOrClientSemanticTokensRequestFullDelta) UnmarshalJSON(data []byt return fmt.Errorf("invalid BooleanOrClientSemanticTokensRequestFullDelta: %s", data) } +type LocationOrLocationsOrDefinitionLinks struct { + Location *Location + Locations *[]Location + DefinitionLinks *[]*LocationLink +} + +func (o LocationOrLocationsOrDefinitionLinks) MarshalJSON() ([]byte, error) { + assertOnlyOne("more than one element of LocationOrLocationsOrDefinitionLinks is set", o.Location != nil, o.Locations != nil, o.DefinitionLinks != nil) + + if o.Location != nil { + return json.Marshal(*o.Location) + } + if o.Locations != nil { + return json.Marshal(*o.Locations) + } + if o.DefinitionLinks != nil { + return json.Marshal(*o.DefinitionLinks) + } + panic("unreachable") +} + +func (o *LocationOrLocationsOrDefinitionLinks) UnmarshalJSON(data []byte) error { + *o = LocationOrLocationsOrDefinitionLinks{} + + var vLocation Location + if err := json.Unmarshal(data, &vLocation); err == nil { + o.Location = &vLocation + return nil + } + var vLocations []Location + if err := json.Unmarshal(data, &vLocations); err == nil { + o.Locations = &vLocations + return nil + } + var vDefinitionLinks []*LocationLink + if err := json.Unmarshal(data, &vDefinitionLinks); err == nil { + o.DefinitionLinks = &vDefinitionLinks + return nil + } + return fmt.Errorf("invalid LocationOrLocationsOrDefinitionLinks: %s", data) +} + +type LocationOrLocationsOrDeclarationLinks struct { + Location *Location + Locations *[]Location + DeclarationLinks *[]*LocationLink +} + +func (o LocationOrLocationsOrDeclarationLinks) MarshalJSON() ([]byte, error) { + assertOnlyOne("more than one element of LocationOrLocationsOrDeclarationLinks is set", o.Location != nil, o.Locations != nil, o.DeclarationLinks != nil) + + if o.Location != nil { + return json.Marshal(*o.Location) + } + if o.Locations != nil { + return json.Marshal(*o.Locations) + } + if o.DeclarationLinks != nil { + return json.Marshal(*o.DeclarationLinks) + } + panic("unreachable") +} + +func (o *LocationOrLocationsOrDeclarationLinks) UnmarshalJSON(data []byte) error { + *o = LocationOrLocationsOrDeclarationLinks{} + + var vLocation Location + if err := json.Unmarshal(data, &vLocation); err == nil { + o.Location = &vLocation + return nil + } + var vLocations []Location + if err := json.Unmarshal(data, &vLocations); err == nil { + o.Locations = &vLocations + return nil + } + var vDeclarationLinks []*LocationLink + if err := json.Unmarshal(data, &vDeclarationLinks); err == nil { + o.DeclarationLinks = &vDeclarationLinks + return nil + } + return fmt.Errorf("invalid LocationOrLocationsOrDeclarationLinks: %s", data) +} + +type SemanticTokensOrSemanticTokensDelta struct { + SemanticTokens *SemanticTokens + SemanticTokensDelta *SemanticTokensDelta +} + +func (o SemanticTokensOrSemanticTokensDelta) MarshalJSON() ([]byte, error) { + assertOnlyOne("more than one element of SemanticTokensOrSemanticTokensDelta is set", o.SemanticTokens != nil, o.SemanticTokensDelta != nil) + + if o.SemanticTokens != nil { + return json.Marshal(*o.SemanticTokens) + } + if o.SemanticTokensDelta != nil { + return json.Marshal(*o.SemanticTokensDelta) + } + panic("unreachable") +} + +func (o *SemanticTokensOrSemanticTokensDelta) UnmarshalJSON(data []byte) error { + *o = SemanticTokensOrSemanticTokensDelta{} + + var vSemanticTokens SemanticTokens + if err := json.Unmarshal(data, &vSemanticTokens); err == nil { + o.SemanticTokens = &vSemanticTokens + return nil + } + var vSemanticTokensDelta SemanticTokensDelta + if err := json.Unmarshal(data, &vSemanticTokensDelta); err == nil { + o.SemanticTokensDelta = &vSemanticTokensDelta + return nil + } + return fmt.Errorf("invalid SemanticTokensOrSemanticTokensDelta: %s", data) +} + +type InlineValueTextOrVariableLookupOrEvaluatableExpression struct { + Text *InlineValueText + VariableLookup *InlineValueVariableLookup + EvaluatableExpression *InlineValueEvaluatableExpression +} + +func (o InlineValueTextOrVariableLookupOrEvaluatableExpression) MarshalJSON() ([]byte, error) { + assertOnlyOne("more than one element of InlineValueTextOrVariableLookupOrEvaluatableExpression is set", o.Text != nil, o.VariableLookup != nil, o.EvaluatableExpression != nil) + + if o.Text != nil { + return json.Marshal(*o.Text) + } + if o.VariableLookup != nil { + return json.Marshal(*o.VariableLookup) + } + if o.EvaluatableExpression != nil { + return json.Marshal(*o.EvaluatableExpression) + } + panic("unreachable") +} + +func (o *InlineValueTextOrVariableLookupOrEvaluatableExpression) UnmarshalJSON(data []byte) error { + *o = InlineValueTextOrVariableLookupOrEvaluatableExpression{} + + var vText InlineValueText + if err := json.Unmarshal(data, &vText); err == nil { + o.Text = &vText + return nil + } + var vVariableLookup InlineValueVariableLookup + if err := json.Unmarshal(data, &vVariableLookup); err == nil { + o.VariableLookup = &vVariableLookup + return nil + } + var vEvaluatableExpression InlineValueEvaluatableExpression + if err := json.Unmarshal(data, &vEvaluatableExpression); err == nil { + o.EvaluatableExpression = &vEvaluatableExpression + return nil + } + return fmt.Errorf("invalid InlineValueTextOrVariableLookupOrEvaluatableExpression: %s", data) +} + +type RelatedFullDocumentDiagnosticReportOrUnchangedDocumentDiagnosticReport struct { + FullDocumentDiagnosticReport *RelatedFullDocumentDiagnosticReport + UnchangedDocumentDiagnosticReport *RelatedUnchangedDocumentDiagnosticReport +} + +func (o RelatedFullDocumentDiagnosticReportOrUnchangedDocumentDiagnosticReport) MarshalJSON() ([]byte, error) { + assertOnlyOne("more than one element of RelatedFullDocumentDiagnosticReportOrUnchangedDocumentDiagnosticReport is set", o.FullDocumentDiagnosticReport != nil, o.UnchangedDocumentDiagnosticReport != nil) + + if o.FullDocumentDiagnosticReport != nil { + return json.Marshal(*o.FullDocumentDiagnosticReport) + } + if o.UnchangedDocumentDiagnosticReport != nil { + return json.Marshal(*o.UnchangedDocumentDiagnosticReport) + } + panic("unreachable") +} + +func (o *RelatedFullDocumentDiagnosticReportOrUnchangedDocumentDiagnosticReport) UnmarshalJSON(data []byte) error { + *o = RelatedFullDocumentDiagnosticReportOrUnchangedDocumentDiagnosticReport{} + + var vFullDocumentDiagnosticReport RelatedFullDocumentDiagnosticReport + if err := json.Unmarshal(data, &vFullDocumentDiagnosticReport); err == nil { + o.FullDocumentDiagnosticReport = &vFullDocumentDiagnosticReport + return nil + } + var vUnchangedDocumentDiagnosticReport RelatedUnchangedDocumentDiagnosticReport + if err := json.Unmarshal(data, &vUnchangedDocumentDiagnosticReport); err == nil { + o.UnchangedDocumentDiagnosticReport = &vUnchangedDocumentDiagnosticReport + return nil + } + return fmt.Errorf("invalid RelatedFullDocumentDiagnosticReportOrUnchangedDocumentDiagnosticReport: %s", data) +} + +type InlineCompletionListOrItems struct { + List *InlineCompletionList + Items *[]*InlineCompletionItem +} + +func (o InlineCompletionListOrItems) MarshalJSON() ([]byte, error) { + assertOnlyOne("more than one element of InlineCompletionListOrItems is set", o.List != nil, o.Items != nil) + + if o.List != nil { + return json.Marshal(*o.List) + } + if o.Items != nil { + return json.Marshal(*o.Items) + } + panic("unreachable") +} + +func (o *InlineCompletionListOrItems) UnmarshalJSON(data []byte) error { + *o = InlineCompletionListOrItems{} + + var vList InlineCompletionList + if err := json.Unmarshal(data, &vList); err == nil { + o.List = &vList + return nil + } + var vItems []*InlineCompletionItem + if err := json.Unmarshal(data, &vItems); err == nil { + o.Items = &vItems + return nil + } + return fmt.Errorf("invalid InlineCompletionListOrItems: %s", data) +} + +type CompletionItemsOrList struct { + Items *[]*CompletionItem + List *CompletionList +} + +func (o CompletionItemsOrList) MarshalJSON() ([]byte, error) { + assertOnlyOne("more than one element of CompletionItemsOrList is set", o.Items != nil, o.List != nil) + + if o.Items != nil { + return json.Marshal(*o.Items) + } + if o.List != nil { + return json.Marshal(*o.List) + } + panic("unreachable") +} + +func (o *CompletionItemsOrList) UnmarshalJSON(data []byte) error { + *o = CompletionItemsOrList{} + + var vItems []*CompletionItem + if err := json.Unmarshal(data, &vItems); err == nil { + o.Items = &vItems + return nil + } + var vList CompletionList + if err := json.Unmarshal(data, &vList); err == nil { + o.List = &vList + return nil + } + return fmt.Errorf("invalid CompletionItemsOrList: %s", data) +} + +type SymbolInformationsOrDocumentSymbols struct { + SymbolInformations *[]*SymbolInformation + DocumentSymbols *[]*DocumentSymbol +} + +func (o SymbolInformationsOrDocumentSymbols) MarshalJSON() ([]byte, error) { + assertOnlyOne("more than one element of SymbolInformationsOrDocumentSymbols is set", o.SymbolInformations != nil, o.DocumentSymbols != nil) + + if o.SymbolInformations != nil { + return json.Marshal(*o.SymbolInformations) + } + if o.DocumentSymbols != nil { + return json.Marshal(*o.DocumentSymbols) + } + panic("unreachable") +} + +func (o *SymbolInformationsOrDocumentSymbols) UnmarshalJSON(data []byte) error { + *o = SymbolInformationsOrDocumentSymbols{} + + var vSymbolInformations []*SymbolInformation + if err := json.Unmarshal(data, &vSymbolInformations); err == nil { + o.SymbolInformations = &vSymbolInformations + return nil + } + var vDocumentSymbols []*DocumentSymbol + if err := json.Unmarshal(data, &vDocumentSymbols); err == nil { + o.DocumentSymbols = &vDocumentSymbols + return nil + } + return fmt.Errorf("invalid SymbolInformationsOrDocumentSymbols: %s", data) +} + +type CommandOrCodeAction struct { + Command *Command + CodeAction *CodeAction +} + +func (o CommandOrCodeAction) MarshalJSON() ([]byte, error) { + assertOnlyOne("more than one element of CommandOrCodeAction is set", o.Command != nil, o.CodeAction != nil) + + if o.Command != nil { + return json.Marshal(*o.Command) + } + if o.CodeAction != nil { + return json.Marshal(*o.CodeAction) + } + panic("unreachable") +} + +func (o *CommandOrCodeAction) UnmarshalJSON(data []byte) error { + *o = CommandOrCodeAction{} + + var vCommand Command + if err := json.Unmarshal(data, &vCommand); err == nil { + o.Command = &vCommand + return nil + } + var vCodeAction CodeAction + if err := json.Unmarshal(data, &vCodeAction); err == nil { + o.CodeAction = &vCodeAction + return nil + } + return fmt.Errorf("invalid CommandOrCodeAction: %s", data) +} + +type SymbolInformationsOrWorkspaceSymbols struct { + SymbolInformations *[]*SymbolInformation + WorkspaceSymbols *[]*WorkspaceSymbol +} + +func (o SymbolInformationsOrWorkspaceSymbols) MarshalJSON() ([]byte, error) { + assertOnlyOne("more than one element of SymbolInformationsOrWorkspaceSymbols is set", o.SymbolInformations != nil, o.WorkspaceSymbols != nil) + + if o.SymbolInformations != nil { + return json.Marshal(*o.SymbolInformations) + } + if o.WorkspaceSymbols != nil { + return json.Marshal(*o.WorkspaceSymbols) + } + panic("unreachable") +} + +func (o *SymbolInformationsOrWorkspaceSymbols) UnmarshalJSON(data []byte) error { + *o = SymbolInformationsOrWorkspaceSymbols{} + + var vSymbolInformations []*SymbolInformation + if err := json.Unmarshal(data, &vSymbolInformations); err == nil { + o.SymbolInformations = &vSymbolInformations + return nil + } + var vWorkspaceSymbols []*WorkspaceSymbol + if err := json.Unmarshal(data, &vWorkspaceSymbols); err == nil { + o.WorkspaceSymbols = &vWorkspaceSymbols + return nil + } + return fmt.Errorf("invalid SymbolInformationsOrWorkspaceSymbols: %s", data) +} + +type RangeOrPrepareRenamePlaceholderOrPrepareRenameDefaultBehavior struct { + Range *Range + PrepareRenamePlaceholder *PrepareRenamePlaceholder + PrepareRenameDefaultBehavior *PrepareRenameDefaultBehavior +} + +func (o RangeOrPrepareRenamePlaceholderOrPrepareRenameDefaultBehavior) MarshalJSON() ([]byte, error) { + assertOnlyOne("more than one element of RangeOrPrepareRenamePlaceholderOrPrepareRenameDefaultBehavior is set", o.Range != nil, o.PrepareRenamePlaceholder != nil, o.PrepareRenameDefaultBehavior != nil) + + if o.Range != nil { + return json.Marshal(*o.Range) + } + if o.PrepareRenamePlaceholder != nil { + return json.Marshal(*o.PrepareRenamePlaceholder) + } + if o.PrepareRenameDefaultBehavior != nil { + return json.Marshal(*o.PrepareRenameDefaultBehavior) + } + panic("unreachable") +} + +func (o *RangeOrPrepareRenamePlaceholderOrPrepareRenameDefaultBehavior) UnmarshalJSON(data []byte) error { + *o = RangeOrPrepareRenamePlaceholderOrPrepareRenameDefaultBehavior{} + + var vRange Range + if err := json.Unmarshal(data, &vRange); err == nil { + o.Range = &vRange + return nil + } + var vPrepareRenamePlaceholder PrepareRenamePlaceholder + if err := json.Unmarshal(data, &vPrepareRenamePlaceholder); err == nil { + o.PrepareRenamePlaceholder = &vPrepareRenamePlaceholder + return nil + } + var vPrepareRenameDefaultBehavior PrepareRenameDefaultBehavior + if err := json.Unmarshal(data, &vPrepareRenameDefaultBehavior); err == nil { + o.PrepareRenameDefaultBehavior = &vPrepareRenameDefaultBehavior + return nil + } + return fmt.Errorf("invalid RangeOrPrepareRenamePlaceholderOrPrepareRenameDefaultBehavior: %s", data) +} + +type TextDocumentFilterLanguageOrTextDocumentFilterSchemeOrTextDocumentFilterPatternOrNotebookCellTextDocumentFilter struct { + TextDocumentFilterLanguage *TextDocumentFilterLanguage + TextDocumentFilterScheme *TextDocumentFilterScheme + TextDocumentFilterPattern *TextDocumentFilterPattern + NotebookCellTextDocumentFilter *NotebookCellTextDocumentFilter +} + +func (o TextDocumentFilterLanguageOrTextDocumentFilterSchemeOrTextDocumentFilterPatternOrNotebookCellTextDocumentFilter) MarshalJSON() ([]byte, error) { + assertOnlyOne("more than one element of TextDocumentFilterLanguageOrTextDocumentFilterSchemeOrTextDocumentFilterPatternOrNotebookCellTextDocumentFilter is set", o.TextDocumentFilterLanguage != nil, o.TextDocumentFilterScheme != nil, o.TextDocumentFilterPattern != nil, o.NotebookCellTextDocumentFilter != nil) + + if o.TextDocumentFilterLanguage != nil { + return json.Marshal(*o.TextDocumentFilterLanguage) + } + if o.TextDocumentFilterScheme != nil { + return json.Marshal(*o.TextDocumentFilterScheme) + } + if o.TextDocumentFilterPattern != nil { + return json.Marshal(*o.TextDocumentFilterPattern) + } + if o.NotebookCellTextDocumentFilter != nil { + return json.Marshal(*o.NotebookCellTextDocumentFilter) + } + panic("unreachable") +} + +func (o *TextDocumentFilterLanguageOrTextDocumentFilterSchemeOrTextDocumentFilterPatternOrNotebookCellTextDocumentFilter) UnmarshalJSON(data []byte) error { + *o = TextDocumentFilterLanguageOrTextDocumentFilterSchemeOrTextDocumentFilterPatternOrNotebookCellTextDocumentFilter{} + + var vTextDocumentFilterLanguage TextDocumentFilterLanguage + if err := json.Unmarshal(data, &vTextDocumentFilterLanguage); err == nil { + o.TextDocumentFilterLanguage = &vTextDocumentFilterLanguage + return nil + } + var vTextDocumentFilterScheme TextDocumentFilterScheme + if err := json.Unmarshal(data, &vTextDocumentFilterScheme); err == nil { + o.TextDocumentFilterScheme = &vTextDocumentFilterScheme + return nil + } + var vTextDocumentFilterPattern TextDocumentFilterPattern + if err := json.Unmarshal(data, &vTextDocumentFilterPattern); err == nil { + o.TextDocumentFilterPattern = &vTextDocumentFilterPattern + return nil + } + var vNotebookCellTextDocumentFilter NotebookCellTextDocumentFilter + if err := json.Unmarshal(data, &vNotebookCellTextDocumentFilter); err == nil { + o.NotebookCellTextDocumentFilter = &vNotebookCellTextDocumentFilter + return nil + } + return fmt.Errorf("invalid TextDocumentFilterLanguageOrTextDocumentFilterSchemeOrTextDocumentFilterPatternOrNotebookCellTextDocumentFilter: %s", data) +} + +type StringOrMarkedStringWithLanguage struct { + String *string + MarkedStringWithLanguage *MarkedStringWithLanguage +} + +func (o StringOrMarkedStringWithLanguage) MarshalJSON() ([]byte, error) { + assertOnlyOne("more than one element of StringOrMarkedStringWithLanguage is set", o.String != nil, o.MarkedStringWithLanguage != nil) + + if o.String != nil { + return json.Marshal(*o.String) + } + if o.MarkedStringWithLanguage != nil { + return json.Marshal(*o.MarkedStringWithLanguage) + } + panic("unreachable") +} + +func (o *StringOrMarkedStringWithLanguage) UnmarshalJSON(data []byte) error { + *o = StringOrMarkedStringWithLanguage{} + + var vString string + if err := json.Unmarshal(data, &vString); err == nil { + o.String = &vString + return nil + } + var vMarkedStringWithLanguage MarkedStringWithLanguage + if err := json.Unmarshal(data, &vMarkedStringWithLanguage); err == nil { + o.MarkedStringWithLanguage = &vMarkedStringWithLanguage + return nil + } + return fmt.Errorf("invalid StringOrMarkedStringWithLanguage: %s", data) +} + // Literal types // StringLiteralBegin is a literal type for "begin" diff --git a/internal/lsp/server.go b/internal/lsp/server.go index 51cdd08bd9..32c114b53f 100644 --- a/internal/lsp/server.go +++ b/internal/lsp/server.go @@ -290,7 +290,11 @@ func (s *Server) readLoop(ctx context.Context) error { if s.initializeParams == nil && msg.Kind == lsproto.MessageKindRequest { req := msg.AsRequest() if req.Method == lsproto.MethodInitialize { - s.handleInitialize(req) + resp, err := s.handleInitialize(ctx, req.Params.(*lsproto.InitializeParams)) + if err != nil { + return err + } + s.sendResult(req.ID, resp) } else { s.sendError(req.ID, lsproto.ErrServerNotInitialized) } @@ -459,71 +463,81 @@ func (s *Server) sendResponse(resp *lsproto.ResponseMessage) { } func (s *Server) handleRequestOrNotification(ctx context.Context, req *lsproto.RequestMessage) error { - params := req.Params - switch params.(type) { - case *lsproto.InitializeParams: + if handler := handlers()[req.Method]; handler != nil { + return handler(s, ctx, req) + } + s.Log("unknown method", req.Method) + if req.ID != nil { s.sendError(req.ID, lsproto.ErrInvalidRequest) - return nil - case *lsproto.InitializedParams: - return s.handleInitialized(ctx, req) - case *lsproto.DidOpenTextDocumentParams: - return s.handleDidOpen(ctx, req) - case *lsproto.DidChangeTextDocumentParams: - return s.handleDidChange(ctx, req) - case *lsproto.DidSaveTextDocumentParams: - return s.handleDidSave(ctx, req) - case *lsproto.DidCloseTextDocumentParams: - return s.handleDidClose(ctx, req) - case *lsproto.DidChangeWatchedFilesParams: - return s.handleDidChangeWatchedFiles(ctx, req) - case *lsproto.DocumentDiagnosticParams: - return s.handleDocumentDiagnostic(ctx, req) - case *lsproto.HoverParams: - return s.handleHover(ctx, req) - case *lsproto.DefinitionParams: - return s.handleDefinition(ctx, req) - case *lsproto.TypeDefinitionParams: - return s.handleTypeDefinition(ctx, req) - case *lsproto.CompletionParams: - return s.handleCompletion(ctx, req) - case *lsproto.ReferenceParams: - return s.handleReferences(ctx, req) - case *lsproto.ImplementationParams: - return s.handleImplementations(ctx, req) - case *lsproto.SignatureHelpParams: - return s.handleSignatureHelp(ctx, req) - case *lsproto.DocumentFormattingParams: - return s.handleDocumentFormat(ctx, req) - case *lsproto.DocumentRangeFormattingParams: - return s.handleDocumentRangeFormat(ctx, req) - case *lsproto.DocumentOnTypeFormattingParams: - return s.handleDocumentOnTypeFormat(ctx, req) - case *lsproto.WorkspaceSymbolParams: - return s.handleWorkspaceSymbol(ctx, req) - case *lsproto.DocumentSymbolParams: - return s.handleDocumentSymbol(ctx, req) - case *lsproto.CompletionItem: - return s.handleCompletionItemResolve(ctx, req) - default: - switch req.Method { - case lsproto.MethodShutdown: - s.projectService.Close() - s.sendResult(req.ID, nil) - return nil - case lsproto.MethodExit: - return io.EOF - default: - s.Log("unknown method", req.Method) - if req.ID != nil { - s.sendError(req.ID, lsproto.ErrInvalidRequest) - } - return nil + } + return nil +} + +type handlerMap map[lsproto.Method]func(*Server, context.Context, *lsproto.RequestMessage) error + +var handlers = sync.OnceValue(func() handlerMap { + handlers := make(handlerMap) + + registerRequestHandler(handlers, lsproto.InitializeInfo, (*Server).handleInitialize) + registerNotificationHandler(handlers, lsproto.InitializedInfo, (*Server).handleInitialized) + registerRequestHandler(handlers, lsproto.ShutdownInfo, (*Server).handleShutdown) + registerNotificationHandler(handlers, lsproto.ExitInfo, (*Server).handleExit) + + registerNotificationHandler(handlers, lsproto.TextDocumentDidOpenInfo, (*Server).handleDidOpen) + registerNotificationHandler(handlers, lsproto.TextDocumentDidChangeInfo, (*Server).handleDidChange) + registerNotificationHandler(handlers, lsproto.TextDocumentDidSaveInfo, (*Server).handleDidSave) + registerNotificationHandler(handlers, lsproto.TextDocumentDidCloseInfo, (*Server).handleDidClose) + registerNotificationHandler(handlers, lsproto.WorkspaceDidChangeWatchedFilesInfo, (*Server).handleDidChangeWatchedFiles) + + registerRequestHandler(handlers, lsproto.TextDocumentDiagnosticInfo, (*Server).handleDocumentDiagnostic) + registerRequestHandler(handlers, lsproto.TextDocumentHoverInfo, (*Server).handleHover) + registerRequestHandler(handlers, lsproto.TextDocumentDefinitionInfo, (*Server).handleDefinition) + registerRequestHandler(handlers, lsproto.TextDocumentTypeDefinitionInfo, (*Server).handleTypeDefinition) + registerRequestHandler(handlers, lsproto.TextDocumentCompletionInfo, (*Server).handleCompletion) + registerRequestHandler(handlers, lsproto.TextDocumentReferencesInfo, (*Server).handleReferences) + registerRequestHandler(handlers, lsproto.TextDocumentImplementationInfo, (*Server).handleImplementations) + registerRequestHandler(handlers, lsproto.TextDocumentSignatureHelpInfo, (*Server).handleSignatureHelp) + registerRequestHandler(handlers, lsproto.TextDocumentFormattingInfo, (*Server).handleDocumentFormat) + registerRequestHandler(handlers, lsproto.TextDocumentRangeFormattingInfo, (*Server).handleDocumentRangeFormat) + registerRequestHandler(handlers, lsproto.TextDocumentOnTypeFormattingInfo, (*Server).handleDocumentOnTypeFormat) + registerRequestHandler(handlers, lsproto.WorkspaceSymbolInfo, (*Server).handleWorkspaceSymbol) + registerRequestHandler(handlers, lsproto.TextDocumentDocumentSymbolInfo, (*Server).handleDocumentSymbol) + registerRequestHandler(handlers, lsproto.CompletionItemResolveInfo, (*Server).handleCompletionItemResolve) + + return handlers +}) + +func registerNotificationHandler[Req any](handlers handlerMap, info lsproto.NotificationInfo[Req], fn func(*Server, context.Context, Req) error) { + handlers[info.Method] = func(s *Server, ctx context.Context, req *lsproto.RequestMessage) error { + params := req.Params.(Req) + if err := fn(s, ctx, params); err != nil { + return err + } + return ctx.Err() + } +} + +func registerRequestHandler[Req, Resp any](handlers handlerMap, info lsproto.RequestInfo[Req, Resp], fn func(*Server, context.Context, Req) (Resp, error)) { + handlers[info.Method] = func(s *Server, ctx context.Context, req *lsproto.RequestMessage) error { + params := req.Params.(Req) + resp, err := fn(s, ctx, params) + if err != nil { + return err + } + if ctx.Err() != nil { + return ctx.Err() } + s.sendResult(req.ID, resp) + return nil } } -func (s *Server) handleInitialize(req *lsproto.RequestMessage) { - s.initializeParams = req.Params.(*lsproto.InitializeParams) +func (s *Server) handleInitialize(ctx context.Context, params *lsproto.InitializeParams) (lsproto.InitializeResponse, error) { + if s.initializeParams != nil { + return nil, lsproto.ErrInvalidRequest + } + + s.initializeParams = params s.positionEncoding = lsproto.PositionEncodingKindUTF16 if genCapabilities := s.initializeParams.Capabilities.General; genCapabilities != nil && genCapabilities.PositionEncodings != nil { @@ -532,15 +546,15 @@ func (s *Server) handleInitialize(req *lsproto.RequestMessage) { } } - s.sendResult(req.ID, &lsproto.InitializeResult{ + response := &lsproto.InitializeResult{ ServerInfo: &lsproto.ServerInfo{ Name: "typescript-go", Version: ptrTo(core.Version()), }, Capabilities: &lsproto.ServerCapabilities{ PositionEncoding: ptrTo(s.positionEncoding), - TextDocumentSync: &lsproto.TextDocumentSyncOptionsOrTextDocumentSyncKind{ - TextDocumentSyncOptions: &lsproto.TextDocumentSyncOptions{ + TextDocumentSync: &lsproto.TextDocumentSyncOptionsOrKind{ + Options: &lsproto.TextDocumentSyncOptions{ OpenClose: ptrTo(true), Change: ptrTo(lsproto.TextDocumentSyncKindIncremental), Save: &lsproto.BooleanOrSaveOptions{ @@ -565,8 +579,8 @@ func (s *Server) handleInitialize(req *lsproto.RequestMessage) { ImplementationProvider: &lsproto.BooleanOrImplementationOptionsOrImplementationRegistrationOptions{ Boolean: ptrTo(true), }, - DiagnosticProvider: &lsproto.DiagnosticOptionsOrDiagnosticRegistrationOptions{ - DiagnosticOptions: &lsproto.DiagnosticOptions{ + DiagnosticProvider: &lsproto.DiagnosticOptionsOrRegistrationOptions{ + Options: &lsproto.DiagnosticOptions{ InterFileDependencies: true, }, }, @@ -595,10 +609,12 @@ func (s *Server) handleInitialize(req *lsproto.RequestMessage) { Boolean: ptrTo(true), }, }, - }) + } + + return response, nil } -func (s *Server) handleInitialized(ctx context.Context, req *lsproto.RequestMessage) error { +func (s *Server) handleInitialized(ctx context.Context, params *lsproto.InitializedParams) error { if shouldEnableWatch(s.initializeParams) { s.watchEnabled = true } @@ -622,127 +638,101 @@ func (s *Server) handleInitialized(ctx context.Context, req *lsproto.RequestMess return nil } -func (s *Server) handleDidOpen(ctx context.Context, req *lsproto.RequestMessage) error { - params := req.Params.(*lsproto.DidOpenTextDocumentParams) +func (s *Server) handleShutdown(ctx context.Context, params any) (lsproto.ShutdownResponse, error) { + s.projectService.Close() + return nil, nil +} + +func (s *Server) handleExit(ctx context.Context, params any) error { + return io.EOF +} + +func (s *Server) handleDidOpen(ctx context.Context, params *lsproto.DidOpenTextDocumentParams) error { s.projectService.OpenFile(ls.DocumentURIToFileName(params.TextDocument.Uri), params.TextDocument.Text, ls.LanguageKindToScriptKind(params.TextDocument.LanguageId), "") return nil } -func (s *Server) handleDidChange(ctx context.Context, req *lsproto.RequestMessage) error { - params := req.Params.(*lsproto.DidChangeTextDocumentParams) +func (s *Server) handleDidChange(ctx context.Context, params *lsproto.DidChangeTextDocumentParams) error { return s.projectService.ChangeFile(params.TextDocument, params.ContentChanges) } -func (s *Server) handleDidSave(ctx context.Context, req *lsproto.RequestMessage) error { - params := req.Params.(*lsproto.DidSaveTextDocumentParams) +func (s *Server) handleDidSave(ctx context.Context, params *lsproto.DidSaveTextDocumentParams) error { s.projectService.MarkFileSaved(ls.DocumentURIToFileName(params.TextDocument.Uri), *params.Text) return nil } -func (s *Server) handleDidClose(ctx context.Context, req *lsproto.RequestMessage) error { - params := req.Params.(*lsproto.DidCloseTextDocumentParams) +func (s *Server) handleDidClose(ctx context.Context, params *lsproto.DidCloseTextDocumentParams) error { s.projectService.CloseFile(ls.DocumentURIToFileName(params.TextDocument.Uri)) return nil } -func (s *Server) handleDidChangeWatchedFiles(ctx context.Context, req *lsproto.RequestMessage) error { - params := req.Params.(*lsproto.DidChangeWatchedFilesParams) +func (s *Server) handleDidChangeWatchedFiles(ctx context.Context, params *lsproto.DidChangeWatchedFilesParams) error { return s.projectService.OnWatchedFilesChanged(ctx, params.Changes) } -func (s *Server) handleDocumentDiagnostic(ctx context.Context, req *lsproto.RequestMessage) error { - params := req.Params.(*lsproto.DocumentDiagnosticParams) +func (s *Server) handleDocumentDiagnostic(ctx context.Context, params *lsproto.DocumentDiagnosticParams) (lsproto.DocumentDiagnosticResponse, error) { project := s.projectService.EnsureDefaultProjectForURI(params.TextDocument.Uri) languageService, done := project.GetLanguageServiceForRequest(ctx) defer done() - diagnostics, err := languageService.GetDocumentDiagnostics(ctx, params.TextDocument.Uri) - if err != nil { - return err - } - s.sendResult(req.ID, diagnostics) - return nil + return languageService.ProvideDiagnostics(ctx, params.TextDocument.Uri) } -func (s *Server) handleHover(ctx context.Context, req *lsproto.RequestMessage) error { - params := req.Params.(*lsproto.HoverParams) +func (s *Server) handleHover(ctx context.Context, params *lsproto.HoverParams) (lsproto.HoverResponse, error) { project := s.projectService.EnsureDefaultProjectForURI(params.TextDocument.Uri) languageService, done := project.GetLanguageServiceForRequest(ctx) defer done() - hover, err := languageService.ProvideHover(ctx, params.TextDocument.Uri, params.Position) - if err != nil { - return err - } - s.sendResult(req.ID, hover) - return nil + return languageService.ProvideHover(ctx, params.TextDocument.Uri, params.Position) } -func (s *Server) handleSignatureHelp(ctx context.Context, req *lsproto.RequestMessage) error { - params := req.Params.(*lsproto.SignatureHelpParams) +func (s *Server) handleSignatureHelp(ctx context.Context, params *lsproto.SignatureHelpParams) (lsproto.SignatureHelpResponse, error) { project := s.projectService.EnsureDefaultProjectForURI(params.TextDocument.Uri) languageService, done := project.GetLanguageServiceForRequest(ctx) defer done() - signatureHelp := languageService.ProvideSignatureHelp( + return languageService.ProvideSignatureHelp( ctx, params.TextDocument.Uri, params.Position, params.Context, s.initializeParams.Capabilities.TextDocument.SignatureHelp, &ls.UserPreferences{}, - ) - s.sendResult(req.ID, signatureHelp) - return nil + ), nil } -func (s *Server) handleDefinition(ctx context.Context, req *lsproto.RequestMessage) error { - params := req.Params.(*lsproto.DefinitionParams) +func (s *Server) handleDefinition(ctx context.Context, params *lsproto.DefinitionParams) (lsproto.DefinitionResponse, error) { project := s.projectService.EnsureDefaultProjectForURI(params.TextDocument.Uri) languageService, done := project.GetLanguageServiceForRequest(ctx) defer done() - definition, err := languageService.ProvideDefinition(ctx, params.TextDocument.Uri, params.Position) - if err != nil { - return err - } - s.sendResult(req.ID, definition) - return nil + return languageService.ProvideDefinition(ctx, params.TextDocument.Uri, params.Position) } -func (s *Server) handleTypeDefinition(ctx context.Context, req *lsproto.RequestMessage) error { - params := req.Params.(*lsproto.TypeDefinitionParams) +func (s *Server) handleTypeDefinition(ctx context.Context, params *lsproto.TypeDefinitionParams) (lsproto.TypeDefinitionResponse, error) { project := s.projectService.EnsureDefaultProjectForURI(params.TextDocument.Uri) languageService, done := project.GetLanguageServiceForRequest(ctx) defer done() - definition, err := languageService.ProvideTypeDefinition(ctx, params.TextDocument.Uri, params.Position) - if err != nil { - return err - } - s.sendResult(req.ID, definition) - return nil + return languageService.ProvideTypeDefinition(ctx, params.TextDocument.Uri, params.Position) } -func (s *Server) handleReferences(ctx context.Context, req *lsproto.RequestMessage) error { +func (s *Server) handleReferences(ctx context.Context, params *lsproto.ReferenceParams) (lsproto.ReferencesResponse, error) { // findAllReferences - params := req.Params.(*lsproto.ReferenceParams) project := s.projectService.EnsureDefaultProjectForURI(params.TextDocument.Uri) languageService, done := project.GetLanguageServiceForRequest(ctx) defer done() locations := languageService.ProvideReferences(params) - s.sendResult(req.ID, locations) - return nil + return &locations, nil } -func (s *Server) handleImplementations(ctx context.Context, req *lsproto.RequestMessage) error { +func (s *Server) handleImplementations(ctx context.Context, params *lsproto.ImplementationParams) (lsproto.ImplementationResponse, error) { // goToImplementation - params := req.Params.(*lsproto.ImplementationParams) project := s.projectService.EnsureDefaultProjectForURI(params.TextDocument.Uri) languageService, done := project.GetLanguageServiceForRequest(ctx) defer done() locations := languageService.ProvideImplementations(params) - s.sendResult(req.ID, locations) - return nil + return &lsproto.LocationOrLocationsOrDefinitionLinks{ + Locations: &locations, + }, nil } -func (s *Server) handleCompletion(ctx context.Context, req *lsproto.RequestMessage) error { - params := req.Params.(*lsproto.CompletionParams) +func (s *Server) handleCompletion(ctx context.Context, params *lsproto.CompletionParams) (lsproto.CompletionResponse, error) { project := s.projectService.EnsureDefaultProjectForURI(params.TextDocument.Uri) languageService, done := project.GetLanguageServiceForRequest(ctx) defer done() @@ -755,37 +745,31 @@ func (s *Server) handleCompletion(ctx context.Context, req *lsproto.RequestMessa getCompletionClientCapabilities(s.initializeParams), &ls.UserPreferences{}) if err != nil { - return err + return nil, err } - s.sendResult(req.ID, list) - return nil + return &lsproto.CompletionItemsOrList{ + List: list, + }, nil } -func (s *Server) handleCompletionItemResolve(ctx context.Context, req *lsproto.RequestMessage) error { - params := req.Params.(*lsproto.CompletionItem) +func (s *Server) handleCompletionItemResolve(ctx context.Context, params *lsproto.CompletionItem) (lsproto.CompletionResolveResponse, error) { data, err := ls.GetCompletionItemData(params) if err != nil { - return err + return nil, err } _, project := s.projectService.EnsureDefaultProjectForFile(data.FileName) languageService, done := project.GetLanguageServiceForRequest(ctx) defer done() - resolvedItem, err := languageService.ResolveCompletionItem( + return languageService.ResolveCompletionItem( ctx, params, data, getCompletionClientCapabilities(s.initializeParams), &ls.UserPreferences{}, ) - if err != nil { - return err - } - s.sendResult(req.ID, resolvedItem) - return nil } -func (s *Server) handleDocumentFormat(ctx context.Context, req *lsproto.RequestMessage) error { - params := req.Params.(*lsproto.DocumentFormattingParams) +func (s *Server) handleDocumentFormat(ctx context.Context, params *lsproto.DocumentFormattingParams) (lsproto.DocumentFormattingResponse, error) { project := s.projectService.EnsureDefaultProjectForURI(params.TextDocument.Uri) languageService, done := project.GetLanguageServiceForRequest(ctx) defer done() @@ -795,14 +779,12 @@ func (s *Server) handleDocumentFormat(ctx context.Context, req *lsproto.RequestM params.Options, ) if err != nil { - return err + return nil, err } - s.sendResult(req.ID, res) - return nil + return &res, nil } -func (s *Server) handleDocumentRangeFormat(ctx context.Context, req *lsproto.RequestMessage) error { - params := req.Params.(*lsproto.DocumentRangeFormattingParams) +func (s *Server) handleDocumentRangeFormat(ctx context.Context, params *lsproto.DocumentRangeFormattingParams) (lsproto.DocumentRangeFormattingResponse, error) { project := s.projectService.EnsureDefaultProjectForURI(params.TextDocument.Uri) languageService, done := project.GetLanguageServiceForRequest(ctx) defer done() @@ -813,14 +795,12 @@ func (s *Server) handleDocumentRangeFormat(ctx context.Context, req *lsproto.Req params.Range, ) if err != nil { - return err + return nil, err } - s.sendResult(req.ID, res) - return nil + return &res, nil } -func (s *Server) handleDocumentOnTypeFormat(ctx context.Context, req *lsproto.RequestMessage) error { - params := req.Params.(*lsproto.DocumentOnTypeFormattingParams) +func (s *Server) handleDocumentOnTypeFormat(ctx context.Context, params *lsproto.DocumentOnTypeFormattingParams) (lsproto.DocumentOnTypeFormattingResponse, error) { project := s.projectService.EnsureDefaultProjectForURI(params.TextDocument.Uri) languageService, done := project.GetLanguageServiceForRequest(ctx) defer done() @@ -832,34 +812,33 @@ func (s *Server) handleDocumentOnTypeFormat(ctx context.Context, req *lsproto.Re params.Ch, ) if err != nil { - return err + return nil, err } - s.sendResult(req.ID, res) - return nil + return &res, nil } -func (s *Server) handleWorkspaceSymbol(ctx context.Context, req *lsproto.RequestMessage) error { +func (s *Server) handleWorkspaceSymbol(ctx context.Context, params *lsproto.WorkspaceSymbolParams) (lsproto.WorkspaceSymbolResponse, error) { programs := core.Map(s.projectService.Projects(), (*project.Project).GetProgram) - params := req.Params.(*lsproto.WorkspaceSymbolParams) symbols, err := ls.ProvideWorkspaceSymbols(ctx, programs, s.projectService.Converters(), params.Query) if err != nil { - return err + return nil, err } - s.sendResult(req.ID, symbols) - return nil + return &lsproto.SymbolInformationsOrWorkspaceSymbols{ + SymbolInformations: &symbols, + }, nil } -func (s *Server) handleDocumentSymbol(ctx context.Context, req *lsproto.RequestMessage) error { - params := req.Params.(*lsproto.DocumentSymbolParams) +func (s *Server) handleDocumentSymbol(ctx context.Context, params *lsproto.DocumentSymbolParams) (lsproto.DocumentSymbolResponse, error) { project := s.projectService.EnsureDefaultProjectForURI(params.TextDocument.Uri) languageService, done := project.GetLanguageServiceForRequest(ctx) defer done() - hover, err := languageService.ProvideDocumentSymbols(ctx, params.TextDocument.Uri) + symbols, err := languageService.ProvideDocumentSymbols(ctx, params.TextDocument.Uri) if err != nil { - return err + return nil, err } - s.sendResult(req.ID, hover) - return nil + return &lsproto.SymbolInformationsOrDocumentSymbols{ + DocumentSymbols: &symbols, + }, nil } func (s *Server) Log(msg ...any) { diff --git a/internal/project/service.go b/internal/project/service.go index a6b6c70e47..9fbf1c5ed4 100644 --- a/internal/project/service.go +++ b/internal/project/service.go @@ -224,7 +224,7 @@ func (s *Service) OpenFile(fileName string, fileContent string, scriptKind core. s.printProjects() } -func (s *Service) ChangeFile(document lsproto.VersionedTextDocumentIdentifier, changes []lsproto.TextDocumentContentChangeEvent) error { +func (s *Service) ChangeFile(document lsproto.VersionedTextDocumentIdentifier, changes []lsproto.TextDocumentContentChangePartialOrWholeDocument) error { fileName := ls.DocumentURIToFileName(document.Uri) path := s.toPath(fileName) scriptInfo := s.documentStore.GetScriptInfoByPath(path) @@ -234,9 +234,9 @@ func (s *Service) ChangeFile(document lsproto.VersionedTextDocumentIdentifier, c textChanges := make([]core.TextChange, len(changes)) for i, change := range changes { - if partialChange := change.TextDocumentContentChangePartial; partialChange != nil { + if partialChange := change.Partial; partialChange != nil { textChanges[i] = s.converters.FromLSPTextChange(scriptInfo, partialChange) - } else if wholeChange := change.TextDocumentContentChangeWholeDocument; wholeChange != nil { + } else if wholeChange := change.WholeDocument; wholeChange != nil { textChanges[i] = core.TextChange{ TextRange: core.NewTextRange(0, len(scriptInfo.Text())), NewText: wholeChange.Text, diff --git a/internal/project/service_test.go b/internal/project/service_test.go index be56f6c930..2848a78cf1 100644 --- a/internal/project/service_test.go +++ b/internal/project/service_test.go @@ -100,9 +100,9 @@ func TestService(t *testing.T) { }, Version: 1, }, - []lsproto.TextDocumentContentChangeEvent{ - lsproto.TextDocumentContentChangePartialOrTextDocumentContentChangeWholeDocument{ - TextDocumentContentChangePartial: ptrTo(lsproto.TextDocumentContentChangePartial{ + []lsproto.TextDocumentContentChangePartialOrWholeDocument{ + { + Partial: ptrTo(lsproto.TextDocumentContentChangePartial{ Range: lsproto.Range{ Start: lsproto.Position{ Line: 0, @@ -139,9 +139,9 @@ func TestService(t *testing.T) { }, Version: 1, }, - []lsproto.TextDocumentContentChangeEvent{ - lsproto.TextDocumentContentChangePartialOrTextDocumentContentChangeWholeDocument{ - TextDocumentContentChangePartial: ptrTo(lsproto.TextDocumentContentChangePartial{ + []lsproto.TextDocumentContentChangePartialOrWholeDocument{ + { + Partial: ptrTo(lsproto.TextDocumentContentChangePartial{ Range: lsproto.Range{ Start: lsproto.Position{ Line: 0, @@ -178,9 +178,9 @@ func TestService(t *testing.T) { }, Version: 1, }, - []lsproto.TextDocumentContentChangeEvent{ - lsproto.TextDocumentContentChangePartialOrTextDocumentContentChangeWholeDocument{ - TextDocumentContentChangePartial: ptrTo(lsproto.TextDocumentContentChangePartial{ + []lsproto.TextDocumentContentChangePartialOrWholeDocument{ + { + Partial: ptrTo(lsproto.TextDocumentContentChangePartial{ Range: lsproto.Range{ Start: lsproto.Position{ Line: 0, @@ -226,9 +226,9 @@ func TestService(t *testing.T) { }, Version: 1, }, - []lsproto.TextDocumentContentChangeEvent{ - lsproto.TextDocumentContentChangePartialOrTextDocumentContentChangeWholeDocument{ - TextDocumentContentChangePartial: ptrTo(lsproto.TextDocumentContentChangePartial{ + []lsproto.TextDocumentContentChangePartialOrWholeDocument{ + { + Partial: ptrTo(lsproto.TextDocumentContentChangePartial{ Range: lsproto.Range{ Start: lsproto.Position{ Line: 0, @@ -562,19 +562,19 @@ func TestService(t *testing.T) { assert.DeepEqual(t, host.ClientMock.WatchFilesCalls()[0].Watchers, []*lsproto.FileSystemWatcher{ { Kind: ptrTo(lsproto.WatchKindCreate | lsproto.WatchKindChange | lsproto.WatchKindDelete), - GlobPattern: lsproto.GlobPattern{ + GlobPattern: lsproto.PatternOrRelativePattern{ Pattern: ptrTo("/home/projects/TS/p1/src/index.ts"), }, }, { Kind: ptrTo(lsproto.WatchKindCreate | lsproto.WatchKindChange | lsproto.WatchKindDelete), - GlobPattern: lsproto.GlobPattern{ + GlobPattern: lsproto.PatternOrRelativePattern{ Pattern: ptrTo("/home/projects/TS/p1/src/y.ts"), }, }, { Kind: ptrTo(lsproto.WatchKindCreate | lsproto.WatchKindChange | lsproto.WatchKindDelete), - GlobPattern: lsproto.GlobPattern{ + GlobPattern: lsproto.PatternOrRelativePattern{ Pattern: ptrTo("/home/projects/TS/p1/tsconfig.json"), }, },