| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
package main |
| 6 |
|
| 7 |
import "log" |
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
type prop [2]string |
| 12 |
|
| 13 |
const ( |
| 14 |
nothing = iota |
| 15 |
wantOpt |
| 16 |
wantOptStar |
| 17 |
) |
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
var goplsStar = map[prop]int{ |
| 24 |
{"AnnotatedTextEdit", "annotationId"}: wantOptStar, |
| 25 |
{"ClientCapabilities", "textDocument"}: wantOpt, |
| 26 |
{"ClientCapabilities", "window"}: wantOpt, |
| 27 |
{"ClientCapabilities", "workspace"}: wantOpt, |
| 28 |
{"CodeAction", "kind"}: wantOpt, |
| 29 |
|
| 30 |
{"CodeActionClientCapabilities", "codeActionLiteralSupport"}: wantOpt, |
| 31 |
|
| 32 |
{"CompletionClientCapabilities", "completionItem"}: wantOpt, |
| 33 |
{"CompletionClientCapabilities", "insertTextMode"}: wantOpt, |
| 34 |
{"CompletionItem", "kind"}: wantOpt, |
| 35 |
{"CompletionParams", "context"}: wantOpt, |
| 36 |
|
| 37 |
{"Diagnostic", "severity"}: wantOpt, |
| 38 |
{"DidSaveTextDocumentParams", "text"}: wantOptStar, |
| 39 |
{"DocumentHighlight", "kind"}: wantOpt, |
| 40 |
|
| 41 |
{"FoldingRange", "startLine"}: wantOptStar, |
| 42 |
{"FoldingRange", "startCharacter"}: wantOptStar, |
| 43 |
{"FoldingRange", "endLine"}: wantOptStar, |
| 44 |
{"FoldingRange", "endCharacter"}: wantOptStar, |
| 45 |
|
| 46 |
{"Hover", "range"}: wantOpt, |
| 47 |
{"InlayHint", "kind"}: wantOpt, |
| 48 |
|
| 49 |
{"PublishDiagnosticsParams", "version"}: wantOpt, |
| 50 |
{"SignatureHelp", "activeParameter"}: wantOptStar, |
| 51 |
{"SignatureInformation", "activeParameter"}: wantOptStar, |
| 52 |
{"TextDocumentClientCapabilities", "codeAction"}: wantOpt, |
| 53 |
{"TextDocumentClientCapabilities", "completion"}: wantOpt, |
| 54 |
{"TextDocumentClientCapabilities", "documentSymbol"}: wantOpt, |
| 55 |
{"TextDocumentClientCapabilities", "publishDiagnostics"}: wantOpt, |
| 56 |
{"TextDocumentClientCapabilities", "semanticTokens"}: wantOpt, |
| 57 |
{"TextDocumentContentChangePartial", "range"}: wantOptStar, |
| 58 |
{"TextDocumentContentChangePartial", "rangeLength"}: wantOptStar, |
| 59 |
{"TextDocumentSyncOptions", "change"}: wantOpt, |
| 60 |
{"WorkDoneProgressBegin", "percentage"}: wantOptStar, |
| 61 |
{"WorkDoneProgressParams", "workDoneToken"}: wantOpt, |
| 62 |
{"WorkDoneProgressReport", "percentage"}: wantOptStar, |
| 63 |
{"WorkspaceClientCapabilities", "didChangeConfiguration"}: wantOpt, |
| 64 |
{"WorkspaceClientCapabilities", "didChangeWatchedFiles"}: wantOpt, |
| 65 |
} |
| 66 |
|
| 67 |
|
| 68 |
var usedGoplsStar = make(map[prop]bool) |
| 69 |
|
| 70 |
|
| 71 |
var renameProp = map[prop]string{ |
| 72 |
{"CancelParams", "id"}: "any", |
| 73 |
{"Command", "arguments"}: "[]json.RawMessage", |
| 74 |
{"CodeAction", "data"}: "json.RawMessage", |
| 75 |
{"Diagnostic", "code"}: "any", |
| 76 |
{"Diagnostic", "data"}: "json.RawMessage", |
| 77 |
|
| 78 |
{"DocumentDiagnosticReportPartialResult", "relatedDocuments"}: "map[DocumentURI]any", |
| 79 |
|
| 80 |
{"ExecuteCommandParams", "arguments"}: "[]json.RawMessage", |
| 81 |
{"FileCreate", "uri"}: "DocumentURI", |
| 82 |
{"FileDelete", "uri"}: "DocumentURI", |
| 83 |
{"FileRename", "oldUri"}: "DocumentURI", |
| 84 |
{"FileRename", "newUri"}: "DocumentURI", |
| 85 |
{"FoldingRange", "kind"}: "string", |
| 86 |
{"Hover", "contents"}: "MarkupContent", |
| 87 |
{"InlayHint", "label"}: "[]InlayHintLabelPart", |
| 88 |
|
| 89 |
{"RelatedFullDocumentDiagnosticReport", "relatedDocuments"}: "map[DocumentURI]any", |
| 90 |
{"RelatedUnchangedDocumentDiagnosticReport", "relatedDocuments"}: "map[DocumentURI]any", |
| 91 |
|
| 92 |
|
| 93 |
{"ServerCapabilities", "codeActionProvider"}: "any", |
| 94 |
|
| 95 |
{"ServerCapabilities", "inlayHintProvider"}: "any", |
| 96 |
|
| 97 |
{"ServerCapabilities", "renameProvider"}: "any", |
| 98 |
|
| 99 |
{"ServerCapabilities", "semanticTokensProvider"}: "any", |
| 100 |
|
| 101 |
{"ServerCapabilities", "textDocumentSync"}: "any", |
| 102 |
{"TextDocumentSyncOptions", "save"}: "SaveOptions", |
| 103 |
{"WorkspaceEdit", "documentChanges"}: "[]DocumentChange", |
| 104 |
} |
| 105 |
|
| 106 |
|
| 107 |
var usedRenameProp = make(map[prop]bool) |
| 108 |
|
| 109 |
type adjust struct { |
| 110 |
prefix, suffix string |
| 111 |
} |
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
var disambiguate = map[string]adjust{ |
| 116 |
"CodeActionTriggerKind": {"CodeAction", ""}, |
| 117 |
"CompletionItemKind": {"", "Completion"}, |
| 118 |
"CompletionItemTag": {"Compl", ""}, |
| 119 |
"DiagnosticSeverity": {"Severity", ""}, |
| 120 |
"DocumentDiagnosticReportKind": {"Diagnostic", ""}, |
| 121 |
"FileOperationPatternKind": {"", "Pattern"}, |
| 122 |
"InlineCompletionTriggerKind": {"Inline", ""}, |
| 123 |
"InsertTextFormat": {"", "TextFormat"}, |
| 124 |
"LanguageKind": {"Lang", ""}, |
| 125 |
"SemanticTokenModifiers": {"Mod", ""}, |
| 126 |
"SemanticTokenTypes": {"", "Type"}, |
| 127 |
"SignatureHelpTriggerKind": {"Sig", ""}, |
| 128 |
"SymbolTag": {"", "Symbol"}, |
| 129 |
"WatchKind": {"Watch", ""}, |
| 130 |
} |
| 131 |
|
| 132 |
|
| 133 |
var usedDisambiguate = make(map[string]bool) |
| 134 |
|
| 135 |
|
| 136 |
var goplsType = map[string]string{ |
| 137 |
"And_RegOpt_textDocument_colorPresentation": "WorkDoneProgressOptionsAndTextDocumentRegistrationOptions", |
| 138 |
"ConfigurationParams": "ParamConfiguration", |
| 139 |
"DocumentUri": "DocumentURI", |
| 140 |
"InitializeParams": "ParamInitialize", |
| 141 |
"LSPAny": "any", |
| 142 |
|
| 143 |
"Lit_SemanticTokensOptions_range_Item1": "PRangeESemanticTokensOptions", |
| 144 |
|
| 145 |
"Or_Declaration": "[]Location", |
| 146 |
"Or_DidChangeConfigurationRegistrationOptions_section": "OrPSection_workspace_didChangeConfiguration", |
| 147 |
"Or_InlayHintLabelPart_tooltip": "OrPTooltipPLabel", |
| 148 |
"Or_InlayHint_tooltip": "OrPTooltip_textDocument_inlayHint", |
| 149 |
"Or_LSPAny": "any", |
| 150 |
|
| 151 |
"Or_ParameterInformation_documentation": "string", |
| 152 |
"Or_ParameterInformation_label": "string", |
| 153 |
"Or_PrepareRenameResult": "PrepareRenamePlaceholder", |
| 154 |
"Or_ProgressToken": "any", |
| 155 |
"Or_Result_textDocument_completion": "CompletionList", |
| 156 |
"Or_Result_textDocument_declaration": "Or_textDocument_declaration", |
| 157 |
"Or_Result_textDocument_definition": "[]Location", |
| 158 |
"Or_Result_textDocument_documentSymbol": "[]any", |
| 159 |
"Or_Result_textDocument_implementation": "[]Location", |
| 160 |
"Or_Result_textDocument_semanticTokens_full_delta": "any", |
| 161 |
"Or_Result_textDocument_typeDefinition": "[]Location", |
| 162 |
"Or_Result_workspace_symbol": "[]SymbolInformation", |
| 163 |
"Or_TextDocumentContentChangeEvent": "TextDocumentContentChangePartial", |
| 164 |
"Or_RelativePattern_baseUri": "DocumentURI", |
| 165 |
|
| 166 |
"Or_WorkspaceFoldersServerCapabilities_changeNotifications": "string", |
| 167 |
"Or_WorkspaceSymbol_location": "OrPLocation_workspace_symbol", |
| 168 |
|
| 169 |
"Tuple_ParameterInformation_label_Item1": "UIntCommaUInt", |
| 170 |
"WorkspaceFoldersServerCapabilities": "WorkspaceFolders5Gn", |
| 171 |
"[]LSPAny": "[]any", |
| 172 |
|
| 173 |
"[]Or_Result_textDocument_codeAction_Item0_Elem": "[]CodeAction", |
| 174 |
"[]PreviousResultId": "[]PreviousResultID", |
| 175 |
"[]uinteger": "[]uint32", |
| 176 |
"boolean": "bool", |
| 177 |
"decimal": "float64", |
| 178 |
"integer": "int32", |
| 179 |
"map[DocumentUri][]TextEdit": "map[DocumentURI][]TextEdit", |
| 180 |
"uinteger": "uint32", |
| 181 |
} |
| 182 |
|
| 183 |
var usedGoplsType = make(map[string]bool) |
| 184 |
|
| 185 |
|
| 186 |
var methodNames = map[string]string{ |
| 187 |
"$/cancelRequest": "CancelRequest", |
| 188 |
"$/logTrace": "LogTrace", |
| 189 |
"$/progress": "Progress", |
| 190 |
"$/setTrace": "SetTrace", |
| 191 |
"callHierarchy/incomingCalls": "IncomingCalls", |
| 192 |
"callHierarchy/outgoingCalls": "OutgoingCalls", |
| 193 |
"client/registerCapability": "RegisterCapability", |
| 194 |
"client/unregisterCapability": "UnregisterCapability", |
| 195 |
"codeAction/resolve": "ResolveCodeAction", |
| 196 |
"codeLens/resolve": "ResolveCodeLens", |
| 197 |
"completionItem/resolve": "ResolveCompletionItem", |
| 198 |
"command/resolve": "ResolveCommand", |
| 199 |
"documentLink/resolve": "ResolveDocumentLink", |
| 200 |
"exit": "Exit", |
| 201 |
"initialize": "Initialize", |
| 202 |
"initialized": "Initialized", |
| 203 |
"inlayHint/resolve": "Resolve", |
| 204 |
"interactive/listEnum": "InteractiveListEnum", |
| 205 |
"notebookDocument/didChange": "DidChangeNotebookDocument", |
| 206 |
"notebookDocument/didClose": "DidCloseNotebookDocument", |
| 207 |
"notebookDocument/didOpen": "DidOpenNotebookDocument", |
| 208 |
"notebookDocument/didSave": "DidSaveNotebookDocument", |
| 209 |
"shutdown": "Shutdown", |
| 210 |
"telemetry/event": "Event", |
| 211 |
"textDocument/codeAction": "CodeAction", |
| 212 |
"textDocument/codeLens": "CodeLens", |
| 213 |
"textDocument/colorPresentation": "ColorPresentation", |
| 214 |
"textDocument/completion": "Completion", |
| 215 |
"textDocument/declaration": "Declaration", |
| 216 |
"textDocument/definition": "Definition", |
| 217 |
"textDocument/diagnostic": "Diagnostic", |
| 218 |
"textDocument/didChange": "DidChange", |
| 219 |
"textDocument/didClose": "DidClose", |
| 220 |
"textDocument/didOpen": "DidOpen", |
| 221 |
"textDocument/didSave": "DidSave", |
| 222 |
"textDocument/documentColor": "DocumentColor", |
| 223 |
"textDocument/documentHighlight": "DocumentHighlight", |
| 224 |
"textDocument/documentLink": "DocumentLink", |
| 225 |
"textDocument/documentSymbol": "DocumentSymbol", |
| 226 |
"textDocument/foldingRange": "FoldingRange", |
| 227 |
"textDocument/formatting": "Formatting", |
| 228 |
"textDocument/hover": "Hover", |
| 229 |
"textDocument/implementation": "Implementation", |
| 230 |
"textDocument/inlayHint": "InlayHint", |
| 231 |
"textDocument/inlineCompletion": "InlineCompletion", |
| 232 |
"textDocument/inlineValue": "InlineValue", |
| 233 |
"textDocument/linkedEditingRange": "LinkedEditingRange", |
| 234 |
"textDocument/moniker": "Moniker", |
| 235 |
"textDocument/onTypeFormatting": "OnTypeFormatting", |
| 236 |
"textDocument/prepareCallHierarchy": "PrepareCallHierarchy", |
| 237 |
"textDocument/prepareRename": "PrepareRename", |
| 238 |
"textDocument/prepareTypeHierarchy": "PrepareTypeHierarchy", |
| 239 |
"textDocument/publishDiagnostics": "PublishDiagnostics", |
| 240 |
"textDocument/rangeFormatting": "RangeFormatting", |
| 241 |
"textDocument/rangesFormatting": "RangesFormatting", |
| 242 |
"textDocument/references": "References", |
| 243 |
"textDocument/rename": "Rename", |
| 244 |
"textDocument/selectionRange": "SelectionRange", |
| 245 |
"textDocument/semanticTokens/full": "SemanticTokensFull", |
| 246 |
"textDocument/semanticTokens/full/delta": "SemanticTokensFullDelta", |
| 247 |
"textDocument/semanticTokens/range": "SemanticTokensRange", |
| 248 |
"textDocument/signatureHelp": "SignatureHelp", |
| 249 |
"textDocument/typeDefinition": "TypeDefinition", |
| 250 |
"textDocument/willSave": "WillSave", |
| 251 |
"textDocument/willSaveWaitUntil": "WillSaveWaitUntil", |
| 252 |
"typeHierarchy/subtypes": "Subtypes", |
| 253 |
"typeHierarchy/supertypes": "Supertypes", |
| 254 |
"window/logMessage": "LogMessage", |
| 255 |
"window/showDocument": "ShowDocument", |
| 256 |
"window/showMessage": "ShowMessage", |
| 257 |
"window/showMessageRequest": "ShowMessageRequest", |
| 258 |
"window/workDoneProgress/cancel": "WorkDoneProgressCancel", |
| 259 |
"window/workDoneProgress/create": "WorkDoneProgressCreate", |
| 260 |
"workspace/applyEdit": "ApplyEdit", |
| 261 |
"workspace/codeLens/refresh": "CodeLensRefresh", |
| 262 |
"workspace/configuration": "Configuration", |
| 263 |
"workspace/diagnostic": "DiagnosticWorkspace", |
| 264 |
"workspace/diagnostic/refresh": "DiagnosticRefresh", |
| 265 |
"workspace/didChangeConfiguration": "DidChangeConfiguration", |
| 266 |
"workspace/didChangeWatchedFiles": "DidChangeWatchedFiles", |
| 267 |
"workspace/didChangeWorkspaceFolders": "DidChangeWorkspaceFolders", |
| 268 |
"workspace/didCreateFiles": "DidCreateFiles", |
| 269 |
"workspace/didDeleteFiles": "DidDeleteFiles", |
| 270 |
"workspace/didRenameFiles": "DidRenameFiles", |
| 271 |
"workspace/executeCommand": "ExecuteCommand", |
| 272 |
"workspace/foldingRange/refresh": "FoldingRangeRefresh", |
| 273 |
"workspace/inlayHint/refresh": "InlayHintRefresh", |
| 274 |
"workspace/inlineValue/refresh": "InlineValueRefresh", |
| 275 |
"workspace/semanticTokens/refresh": "SemanticTokensRefresh", |
| 276 |
"workspace/symbol": "Symbol", |
| 277 |
"workspace/textDocumentContent": "TextDocumentContent", |
| 278 |
"workspace/textDocumentContent/refresh": "TextDocumentContentRefresh", |
| 279 |
"workspace/willCreateFiles": "WillCreateFiles", |
| 280 |
"workspace/willDeleteFiles": "WillDeleteFiles", |
| 281 |
"workspace/willRenameFiles": "WillRenameFiles", |
| 282 |
"workspace/workspaceFolders": "WorkspaceFolders", |
| 283 |
"workspaceSymbol/resolve": "ResolveWorkspaceSymbol", |
| 284 |
} |
| 285 |
|
| 286 |
func methodName(method string) string { |
| 287 |
ans := methodNames[method] |
| 288 |
if ans == "" { |
| 289 |
log.Fatalf("unknown method %q", method) |
| 290 |
} |
| 291 |
return ans |
| 292 |
} |
| 293 |
|
| 294 |
|
| 295 |
|
| 296 |
var prependMethodDocComments = map[string]string{ |
| 297 |
"ResolveCommand": `// ResolveCommand handles the interactive resolution of a command prior to |
| 298 |
// its execution. |
| 299 |
// |
| 300 |
// It processes an [ExecuteCommandParams] to determine if the command requires |
| 301 |
// interactive input, or to validate user-provided answers submitted via the |
| 302 |
// embedded [InteractiveParams]. |
| 303 |
// |
| 304 |
// If the command requires user input (e.g., the initial probe) or if the |
| 305 |
// provided answers are invalid, it returns a modified [ExecuteCommandParams] |
| 306 |
// populated with FormFields to prompt the user. If the input is valid and |
| 307 |
// complete, or if the command requires no interaction at all, it returns an |
| 308 |
// [ExecuteCommandParams] with an empty form, signaling the client to proceed |
| 309 |
// with execution. |
| 310 |
// |
| 311 |
// See [InteractiveParams] for the complete multi-step client-server handshake |
| 312 |
// and the architectural reasoning behind dedicated ResolveXXX methods.`, |
| 313 |
"InteractiveListEnum": `// InteractiveListEnum is the request handler for fetching dynamic enum options. |
| 314 |
// |
| 315 |
// This method is called by the client when the user interacts with a |
| 316 |
// FormFieldTypeLazyEnum field (e.g., typing in a combo box). The server |
| 317 |
// uses the provided Action and Params to determine the context (e.g., |
| 318 |
// "search workspace symbols for interfaces") and returns a filtered list |
| 319 |
// of matching entries.`, |
| 320 |
} |
| 321 |
|
| 322 |
|
| 323 |
|
| 324 |
var appendTypePropDocComments = map[string]map[string]string{ |
| 325 |
"TextDocumentPositionParams": {"position": ` // |
| 326 |
// Deprecated: gopls should use [TextDocumentPositionParams.Range] instead. |
| 327 |
`}, |
| 328 |
} |
| 329 |
|
| 330 |
|
| 331 |
|
| 332 |
var appendTypeProp = map[string]string{ |
| 333 |
"ExecuteCommandParams": ` |
| 334 |
// Support interactive command execution. |
| 335 |
// |
| 336 |
// Note: This is a non-standard protocol extension. See golang/go#76331. |
| 337 |
InteractiveParams |
| 338 |
`, |
| 339 |
} |