diff --git a/gopls/internal/lsp/protocol/generate/output.go b/gopls/internal/lsp/protocol/generate/output.go index df7cc9c8257..e61bd0d9c1d 100644 --- a/gopls/internal/lsp/protocol/generate/output.go +++ b/gopls/internal/lsp/protocol/generate/output.go @@ -239,8 +239,30 @@ func genStructs(model Model) { types[nm] = out.String() } // base types - types["DocumentURI"] = "type DocumentURI string\n" - types["URI"] = "type URI = string\n" + types["DocumentURI"] = ` +// A DocumentURI is the URI of a client editor document. +// +// Care should be taken to handle encoding in URIs. For +// example, some clients (such as VS Code) may encode colons +// in drive letters while others do not. The URIs below are +// both valid, but clients and servers should be consistent +// with the form they use themselves to ensure the other party +// doesn’t interpret them as distinct URIs. Clients and +// servers should not assume that each other are encoding the +// same way (for example a client encoding colons in drive +// letters cannot assume server responses will have encoded +// colons). The same applies to casing of drive letters - one +// party should not assume the other party will return paths +// with drive letters cased the same as it. +// +// file:///c:/project/readme.md +// file:///C%3A/project/readme.md +// +type DocumentURI string +` + types["URI"] = `// A URI is an arbitrary URL (e.g. https), not necessarily a file. +type URI = string +` types["LSPAny"] = "type LSPAny = interface{}\n" // A special case, the only previously existing Or type diff --git a/gopls/internal/lsp/protocol/tsprotocol.go b/gopls/internal/lsp/protocol/tsprotocol.go index f571be379a8..57e54c62e02 100644 --- a/gopls/internal/lsp/protocol/tsprotocol.go +++ b/gopls/internal/lsp/protocol/tsprotocol.go @@ -1458,6 +1458,24 @@ type DocumentSymbolRegistrationOptions struct { TextDocumentRegistrationOptions DocumentSymbolOptions } + +// A DocumentURI is the URI of a client editor document. +// +// Care should be taken to handle encoding in URIs. For +// example, some clients (such as VS Code) may encode colons +// in drive letters while others do not. The URIs below are +// both valid, but clients and servers should be consistent +// with the form they use themselves to ensure the other party +// doesn’t interpret them as distinct URIs. Clients and +// servers should not assume that each other are encoding the +// same way (for example a client encoding colons in drive +// letters cannot assume server responses will have encoded +// colons). The same applies to casing of drive letters - one +// party should not assume the other party will return paths +// with drive letters cased the same as it. +// +// file:///c:/project/readme.md +// file:///C%3A/project/readme.md type DocumentURI string // Predefined error codes. @@ -4660,6 +4678,8 @@ type UIntCommaUInt struct { Fld0 uint32 `json:"fld0"` Fld1 uint32 `json:"fld1"` } + +// A URI is an arbitrary URL (e.g. https), not necessarily a file. type URI = string // A diagnostic report indicating that the last returned