diff --git a/internal/lsp/lsproto/_generate/generate.mjs b/internal/lsp/lsproto/_generate/generate.mjs index 4526824a31..14df597cf9 100644 --- a/internal/lsp/lsproto/_generate/generate.mjs +++ b/internal/lsp/lsproto/_generate/generate.mjs @@ -58,21 +58,38 @@ function writeLine(s) { write("\n"); } +/** + * @param {{ + * documentation?: string, + * proposed?: boolean, + * since?: string, + * sinceTags?: string[], + * deprecated?: string + * }} data + */ +function writeDocumentation(data) { + writeDescription(data.documentation); + writeSince(data.since, data.sinceTags); + writeProposed(data.proposed); + writeDeprecation(data.deprecated, data.documentation); +} + /** * @param {string | undefined} doc */ -function writeDocumentation(doc) { +function writeDescription(doc) { if (doc) { const lines = doc.split("\n"); for (let line of lines) { line = line.replace(/(\w ) +/g, "$1"); line = line.replace(/\{@link(?:code)?.*?([^} ]+)\}/g, "$1"); - line = line.replace(/@since (.*)/g, "Since: $1\n//"); - if (line.startsWith("@deprecated")) { - continue; - } - if (line.startsWith("@proposed")) { - line = "Proposed.\n//"; + + if ( + line.includes("@since") || + line.startsWith("@deprecated") || + line.startsWith("@proposed") + ) { + break; } write("// "); @@ -81,15 +98,71 @@ function writeDocumentation(doc) { } } +/** + * @param {boolean | undefined} proposed + */ +function writeProposed(proposed) { + if (proposed) { + writeLine("// "); + writeLine("// Proposed."); + } +} + +/** + * @param {string | undefined} since + * @param {string[] | undefined} sinceTags + */ +function writeSince(since, sinceTags) { + if (since && !sinceTags) { + const sinceLines = since.split("\n"); + writeSinceLines(sinceLines); + } + else if (sinceTags) { + for (const [idx, sinceTag] of sinceTags.entries()) { + const sinceLines = sinceTag.split("\n"); + writeSinceLines(sinceLines); + + if (idx !== sinceTags.length - 1) { + writeLine("// "); + } + } + } +} + +/** + * @param {string[]} sinceLines + */ +function writeSinceLines(sinceLines) { + writeLine(`// Since: ${sinceLines[0]}`); + + for (let i = 1; i < sinceLines.length; i++) { + writeLine(`// ${sinceLines[i]}`); + } +} + /** * @param {string | undefined} deprecated + * @param {string | undefined} doc */ -function writeDeprecation(deprecated) { +function writeDeprecation(deprecated, doc) { + const inlineDeprecation = "is deprecated @since"; + if (deprecated) { - writeLine("//"); + writeLine("// "); write("// Deprecated: "); writeLine(deprecated); } + else if (doc?.includes(inlineDeprecation)) { + const lines = doc.split("\n"); + const matchingLine = lines.find(x => x.includes(inlineDeprecation)); + + if (matchingLine) { + const deprecationMessage = matchingLine.split(" @since")[0]; + writeLine("// "); + write("// Deprecated: "); + writeLine(deprecationMessage); + } + } } /** @@ -301,8 +374,7 @@ writeLine(""); writeLine("// Structures\n"); for (const t of model.structures) { - writeDocumentation(t.documentation); - writeDeprecation(t.deprecated); + writeDocumentation(t); writeLine("type " + t.name + " struct {"); @@ -324,8 +396,7 @@ for (const t of model.structures) { } for (const p of t.properties) { - writeDocumentation(p.documentation); - writeDeprecation(p.deprecated); + writeDocumentation(p); write(titleCase(p.name) + " "); @@ -350,8 +421,7 @@ for (const t of model.structures) { writeLine("// Enumerations\n"); for (const t of model.enumerations) { - writeDocumentation(t.documentation); - writeDeprecation(t.deprecated); + writeDocumentation(t); /** @type {string} */ let underlyingType; @@ -380,8 +450,7 @@ for (const t of model.enumerations) { writeLine("const ("); for (const v of t.values) { - writeDocumentation(v.documentation); - writeDeprecation(v.deprecated); + writeDocumentation(v); write(t.name); write(v.name); @@ -408,8 +477,7 @@ for (const t of model.enumerations) { writeLine("// Type aliases\n"); for (const t of model.typeAliases) { - writeDocumentation(t.documentation); - writeDeprecation(t.deprecated); + writeDocumentation(t); if (t.name === "LSPAny") { writeLine("type LSPAny = any\n"); @@ -452,8 +520,7 @@ writeLine("}"); writeLine("// Requests"); writeLine("const ("); for (const t of model.requests) { - writeDocumentation(t.documentation); - writeDeprecation(t.deprecated); + writeDocumentation(t); writeLine("Method" + methodNameToIdentifier(t.method) + ' Method = "' + t.method + '"'); } writeLine(")\n"); @@ -461,8 +528,7 @@ writeLine(")\n"); writeLine("// Notifications"); writeLine("const ("); for (const t of model.notifications) { - writeDocumentation(t.documentation); - writeDeprecation(t.deprecated); + writeDocumentation(t); writeLine("Method" + methodNameToIdentifier(t.method) + ' Method = "' + t.method + '"'); } writeLine(")\n"); diff --git a/internal/lsp/lsproto/lsp_generated.go b/internal/lsp/lsproto/lsp_generated.go index 89efd78676..1db874a269 100644 --- a/internal/lsp/lsproto/lsp_generated.go +++ b/internal/lsp/lsproto/lsp_generated.go @@ -821,14 +821,14 @@ type DidChangeNotebookDocumentParams struct { // The changes describe single state changes to the notebook document. // So if there are two changes c1 (at array index 0) and c2 (at array // index 1) for a notebook in state S then c1 moves the notebook from - // S to S' and c2 from S' to S”. So c1 is computed on the state S and + // S to S' and c2 from S' to S''. So c1 is computed on the state S and // c2 is computed on the state S'. // // To mirror the content of a notebook using change events use the following approach: - // - start with the same initial content - // - apply the 'notebookDocument/didChange' notifications in the order you receive them. - // - apply the `NotebookChangeEvent`s in a single notification in the order - // you receive them. + // - start with the same initial content + // - apply the 'notebookDocument/didChange' notifications in the order you receive them. + // - apply the `NotebookChangeEvent`s in a single notification in the order + // you receive them. Change NotebookDocumentChangeEvent `json:"change"` } @@ -1046,14 +1046,14 @@ type DidChangeTextDocumentParams struct { // The actual content changes. The content changes describe single state changes // to the document. So if there are two content changes c1 (at array index 0) and // c2 (at array index 1) for a document in state S then c1 moves the document from - // S to S' and c2 from S' to S”. So c1 is computed on the state S and c2 is computed + // S to S' and c2 from S' to S''. So c1 is computed on the state S and c2 is computed // on the state S'. // // To mirror the content of a document using change events use the following approach: - // - start with the same initial content - // - 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. + // - start with the same initial content + // - 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"` } @@ -1485,6 +1485,7 @@ type SymbolInformation struct { // Indicates if this symbol is deprecated. // + // // Deprecated: Use tags instead Deprecated *bool `json:"deprecated,omitempty"` @@ -1522,6 +1523,7 @@ type DocumentSymbol struct { // Indicates if this symbol is deprecated. // + // // Deprecated: Use tags instead Deprecated *bool `json:"deprecated,omitempty"` @@ -2056,12 +2058,10 @@ type LocationLink struct { // character(s) then use an end position denoting the start of the next line. // For example: // ```ts -// -// { -// start: { line: 5, character: 23 } -// end : { line 6, character : 0 } -// } -// +// { +// start: { line: 5, character: 23 } +// end : { line 6, character : 0 } +// } // ``` type Range struct { // The range's start position. @@ -2236,11 +2236,9 @@ type TextDocumentEdit struct { // The edits to be applied. // // Since: 3.16.0 - support for AnnotatedTextEdit. This is guarded using a - // // client capability. // // Since: 3.18.0 - support for SnippetTextEdit. This is guarded using a - // // client capability. Edits []TextEditOrAnnotatedTextEditOrSnippetTextEdit `json:"edits"` } @@ -2449,18 +2447,16 @@ type InlayHintLabelPart struct { // // Here is an example how such a string can be constructed using JavaScript / TypeScript: // ```ts -// -// let markdown: MarkdownContent = { -// kind: MarkupKind.Markdown, -// value: [ -// '# Header', -// 'Some text', -// '```typescript', -// 'someCode();', -// '```' -// ].join('\n') -// }; -// +// let markdown: MarkdownContent = { +// kind: MarkupKind.Markdown, +// value: [ +// '# Header', +// 'Some text', +// '```typescript', +// 'someCode();', +// '```' +// ].join('\n') +// }; // ``` // // *Please Note* that clients might sanitize the return markdown. A client could decide to @@ -2778,6 +2774,7 @@ type _InitializeParams struct { // The rootPath of the workspace. Is null // if no folder is open. // + // // Deprecated: in favour of rootUri. RootPath *Nullable[string] `json:"rootPath,omitempty"` @@ -2785,6 +2782,7 @@ type _InitializeParams struct { // folder is open. If both `rootPath` and `rootUri` are set // `rootUri` wins. // + // // Deprecated: in favour of workspaceFolders. RootUri *DocumentUri `json:"rootUri"` @@ -3176,13 +3174,13 @@ type CompletionItemApplyKinds struct { // `completionList.itemDefaults.data` and the completion's own data // using the following rules: // - // - If a completion's `data` field is not provided (or `null`), the - // entire `data` field from `completionList.itemDefaults.data` will be - // used as-is. - // - If a completion's `data` field is provided, each field will - // overwrite the field of the same name in - // `completionList.itemDefaults.data` but no merging of nested fields - // within that value will occur. + // - If a completion's `data` field is not provided (or `null`), the + // entire `data` field from `completionList.itemDefaults.data` will be + // used as-is. + // - If a completion's `data` field is provided, each field will + // overwrite the field of the same name in + // `completionList.itemDefaults.data` but no merging of nested fields + // within that value will occur. // // Since: 3.18.0 Data *ApplyKind `json:"data,omitempty"` @@ -3397,10 +3395,10 @@ type CodeActionOptions struct { // // Documentation from the provider should be shown in the code actions menu if either: // - // - Code actions of `kind` are requested by the editor. In this case, the editor will show the documentation that - // most closely matches the requested code action kind. For example, if a provider has documentation for - // both `Refactor` and `RefactorExtract`, when the user requests code actions for `RefactorExtract`, - // the editor will use the documentation for `RefactorExtract` instead of the documentation for `Refactor`. + // - Code actions of `kind` are requested by the editor. In this case, the editor will show the documentation that + // most closely matches the requested code action kind. For example, if a provider has documentation for + // both `Refactor` and `RefactorExtract`, when the user requests code actions for `RefactorExtract`, + // the editor will use the documentation for `RefactorExtract` instead of the documentation for `Refactor`. // // - Any code actions of `kind` are returned by the provider. // @@ -3851,6 +3849,7 @@ type TextDocumentContentChangePartial struct { // The optional length of the range that got replaced. // + // // Deprecated: use range instead. RangeLength *uint32 `json:"rangeLength,omitempty"` @@ -4373,7 +4372,6 @@ type TextDocumentFilterLanguage struct { // A glob pattern, like **​/*.{ts,js}. See TextDocumentFilter for examples. // // 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"` @@ -4392,7 +4390,6 @@ type TextDocumentFilterScheme struct { // A glob pattern, like **​/*.{ts,js}. See TextDocumentFilter for examples. // // 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"` @@ -4411,7 +4408,6 @@ type TextDocumentFilterPattern struct { // A glob pattern, like **​/*.{ts,js}. See TextDocumentFilter for examples. // // 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"` @@ -6733,7 +6729,9 @@ type PrepareRenameResult = RangeOrPrepareRenamePlaceholderOrPrepareRenameDefault // // @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. +// Since: 3.16.0. +// +// Deprecated: The use of a string as a document filter is deprecated type DocumentSelector = []DocumentFilter type ProgressToken = IntegerOrString @@ -7152,9 +7150,8 @@ const ( // resolves to such. // // Since: 3.17.0 - support for WorkspaceSymbol in the returned data. Clients - // - // need to advertise support for WorkspaceSymbols via the client capability - // `workspace.symbol.resolveSupport`. + // need to advertise support for WorkspaceSymbols via the client capability + // `workspace.symbol.resolveSupport`. MethodWorkspaceSymbol Method = "workspace/symbol" // A request to resolve the range inside the workspace // symbol's location.