Skip to content

Commit 5c88785

Browse files
committed
WIP10
Signed-off-by: Koichi Shiraishi <zchee.io@gmail.com>
1 parent 79f6e43 commit 5c88785

File tree

14 files changed

+42
-35
lines changed

14 files changed

+42
-35
lines changed

base.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2024 The Go Language Server Authors
1+
// Copyright 2025 The Go Language Server Authors
22
// SPDX-License-Identifier: BSD-3-Clause
33

44
package protocol

basic.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2024 The Go Language Server Authors
1+
// Copyright 2025 The Go Language Server Authors
22
// SPDX-License-Identifier: BSD-3-Clause
33

44
package protocol

document.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2024 The Go Language Server Authors
1+
// Copyright 2025 The Go Language Server Authors
22
// SPDX-License-Identifier: BSD-3-Clause
33

44
package protocol

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ go 1.22.2
44

55
require (
66
github.com/google/go-cmp v0.6.0
7-
github.com/segmentio/encoding v0.4.0
87
go.lsp.dev/jsonrpc2 v0.10.0
98
go.lsp.dev/uri v0.3.0
109
go.uber.org/zap v1.27.0
1110
)
1211

1312
require (
1413
github.com/segmentio/asm v1.1.3 // indirect
14+
github.com/segmentio/encoding v0.4.0 // indirect
1515
go.uber.org/multierr v1.10.0 // indirect
1616
golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8 // indirect
1717
)

language.go

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2024 The Go Language Server Authors
1+
// Copyright 2025 The Go Language Server Authors
22
// SPDX-License-Identifier: BSD-3-Clause
33

44
package protocol
@@ -432,14 +432,14 @@ const (
432432
// ApplyKind defines how values from a set of defaults and an individual item will be merged.
433433
//
434434
// @since 3.18.0
435-
type ApplyKind string
435+
type ApplyKind uint32
436436

437437
const (
438438
// ReplaceApplyKind the value from the individual item (if provided and not `null`) will be used instead of the default.
439-
ReplaceApplyKind ApplyKind = "replace"
439+
ReplaceApplyKind ApplyKind = 1
440440

441441
// MergeApplyKind the value from the item will be merged with the default. The specific rules for mergeing values are defined against each field that supports merging.
442-
MergeApplyKind ApplyKind = "merge"
442+
MergeApplyKind ApplyKind = 2
443443
)
444444

445445
// SignatureHelpTriggerKind how a signature help was triggered.
@@ -1607,6 +1607,11 @@ type InlineCompletionRegistrationOptions struct {
16071607
StaticRegistrationOptions
16081608
}
16091609

1610+
type TextDocumentFilterClientCapabilities struct {
1611+
// RelativePatternSupport the client supports Relative Patterns.
1612+
RelativePatternSupport bool `json:"relativePatternSupport,omitempty"`
1613+
}
1614+
16101615
// CodeActionTagOptions.
16111616
//
16121617
// @since 3.18.0 - proposed
@@ -1935,7 +1940,7 @@ type EditRangeWithInsertReplace struct {
19351940
Replace Range `json:"replace"`
19361941
}
19371942

1938-
// CompletionItemDefaults in many cases the items of an actual completion result share the same value for properties like `commitCharacters` or the range of a text edit. A completion list can therefore define item defaults which will be used if a completion item itself doesn't specify the value. If a completion list specifies a default value and a completion item also specifies a corresponding value, the rules for combining these are defined by `applyKinds` (if the client supports it), defaulting to "replace". Servers are only allowed to return default values if the client signals support for this via the `completionList.itemDefaults` capability.
1943+
// CompletionItemDefaults in many cases the items of an actual completion result share the same value for properties like `commitCharacters` or the range of a text edit. A completion list can therefore define item defaults which will be used if a completion item itself doesn't specify the value. If a completion list specifies a default value and a completion item also specifies a corresponding value, the rules for combining these are defined by `applyKinds` (if the client supports it), defaulting to ApplyKind.Replace. Servers are only allowed to return default values if the client signals support for this via the `completionList.itemDefaults` capability.
19391944
//
19401945
// @since 3.17.0
19411946
type CompletionItemDefaults struct {
@@ -1960,16 +1965,16 @@ type CompletionItemDefaults struct {
19601965
Data any `json:"data,omitempty"`
19611966
}
19621967

1963-
// CompletionItemApplyKinds specifies how fields from a completion item should be combined with those from `completionList.itemDefaults`. If unspecified, all fields will be treated as "replace". If a field's value is "replace", the value from a completion item (if provided and not `null`) will always be used instead of the value from `completionItem.itemDefaults`. If a field's value is "merge", the values will be merged using the rules defined against each field below. Servers are only allowed to return `applyKind` if the client signals support for this via the `completionList.applyKindSupport` capability.
1968+
// CompletionItemApplyKinds specifies how fields from a completion item should be combined with those from `completionList.itemDefaults`. If unspecified, all fields will be treated as ApplyKind.Replace. If a field's value is ApplyKind.Replace, the value from a completion item (if provided and not `null`) will always be used instead of the value from `completionItem.itemDefaults`. If a field's value is ApplyKind.Merge, the values will be merged using the rules defined against each field below. Servers are only allowed to return `applyKind` if the client signals support for this via the `completionList.applyKindSupport` capability.
19641969
//
19651970
// @since 3.18.0
19661971
type CompletionItemApplyKinds struct {
1967-
// CommitCharacters specifies whether commitCharacters on a completion will replace or be merged with those in `completionList.itemDefaults.commitCharacters`. If "replace", the commit characters from the completion item will always be used unless not provided, in which case those from `completionList.itemDefaults.commitCharacters` will be used. An empty list can be used if a completion item does not have any commit characters and also should not use those from `completionList.itemDefaults.commitCharacters`. If "merge" the commitCharacters for the completion will be the union of all values in both `completionList.itemDefaults.commitCharacters` and the completion's own `commitCharacters`.
1972+
// CommitCharacters specifies whether commitCharacters on a completion will replace or be merged with those in `completionList.itemDefaults.commitCharacters`. If ApplyKind.Replace, the commit characters from the completion item will always be used unless not provided, in which case those from `completionList.itemDefaults.commitCharacters` will be used. An empty list can be used if a completion item does not have any commit characters and also should not use those from `completionList.itemDefaults.commitCharacters`.
1973+
// If ApplyKind.Merge the commitCharacters for the completion will be the union of all values in both `completionList.itemDefaults.commitCharacters` and the completion's own `commitCharacters`.
19681974
// @since 3.18.0
19691975
CommitCharacters ApplyKind `json:"commitCharacters,omitempty"`
19701976

1971-
// Data specifies whether the `data` field on a completion will replace or be merged with data from `completionList.itemDefaults.data`. If "replace", the data from the completion item will be used if provided
1972-
// (and not `null`), otherwise `completionList.itemDefaults.data` will be used. An empty object can be used if a completion item does not have any data but also should not use the value from `completionList.itemDefaults.data`. If "merge", a shallow merge will be performed between `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.
1977+
// Data specifies whether the `data` field on a completion will replace or be merged with data from `completionList.itemDefaults.data`. If ApplyKind.Replace, the data from the completion item will be used if provided (and not `null`), otherwise `completionList.itemDefaults.data` will be used. An empty object can be used if a completion item does not have any data but also should not use the value from `completionList.itemDefaults.data`. If ApplyKind.Merge, a shallow merge will be performed between `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.
19731978
// @since 3.18.0
19741979
Data ApplyKind `json:"data,omitempty"`
19751980
}
@@ -1979,10 +1984,10 @@ type CompletionList struct {
19791984
// IsIncomplete this list it not complete. Further typing results in recomputing this list. Recomputed lists have all their items replaced (not appended) in the incomplete completion sessions.
19801985
IsIncomplete bool `json:"isIncomplete"`
19811986

1982-
// ItemDefaults in many cases the items of an actual completion result share the same value for properties like `commitCharacters` or the range of a text edit. A completion list can therefore define item defaults which will be used if a completion item itself doesn't specify the value. If a completion list specifies a default value and a completion item also specifies a corresponding value, the rules for combining these are defined by `applyKinds` (if the client supports it), defaulting to "replace". Servers are only allowed to return default values if the client signals support for this via the `completionList.itemDefaults` capability.
1987+
// ItemDefaults in many cases the items of an actual completion result share the same value for properties like `commitCharacters` or the range of a text edit. A completion list can therefore define item defaults which will be used if a completion item itself doesn't specify the value. If a completion list specifies a default value and a completion item also specifies a corresponding value, the rules for combining these are defined by `applyKinds` (if the client supports it), defaulting to ApplyKind.Replace. Servers are only allowed to return default values if the client signals support for this via the `completionList.itemDefaults` capability.
19831988
ItemDefaults *CompletionItemDefaults `json:"itemDefaults,omitempty"`
19841989

1985-
// ApplyKind specifies how fields from a completion item should be combined with those from `completionList.itemDefaults`. If unspecified, all fields will be treated as "replace". If a field's value is "replace", the value from a completion item (if provided and not `null`) will always be used instead of the value from `completionItem.itemDefaults`. If a field's value is "merge", the values will be merged using the rules defined against each field below. Servers are only allowed to return `applyKind` if the client signals support for this via the `completionList.applyKindSupport` capability.
1990+
// ApplyKind specifies how fields from a completion item should be combined with those from `completionList.itemDefaults`. If unspecified, all fields will be treated as ApplyKind.Replace. If a field's value is ApplyKind.Replace, the value from a completion item (if provided and not `null`) will always be used instead of the value from `completionItem.itemDefaults`. If a field's value is ApplyKind.Merge, the values will be merged using the rules defined against each field below. Servers are only allowed to return `applyKind` if the client signals support for this via the `completionList.applyKindSupport` capability.
19861991
ApplyKind *CompletionItemApplyKinds `json:"applyKind,omitempty"`
19871992

19881993
// Items the completion items.
@@ -2745,7 +2750,7 @@ type TextDocumentFilterLanguage struct {
27452750
// @since 3.18.0
27462751
Scheme string `json:"scheme,omitempty"`
27472752

2748-
// Pattern a glob pattern, like **​/*.{ts,js}. See TextDocumentFilter for examples. 3.18.0 - support for relative patterns.
2753+
// Pattern a glob pattern, like **​/*.{ts,js}. See TextDocumentFilter for examples. 3.18.0 - support for relative patterns. Whether clients support relative patterns depends on the client capability `textDocuments.filters.relativePatternSupport`.
27492754
// @since 3.18.0
27502755
Pattern *GlobPattern `json:"pattern,omitempty"`
27512756
}
@@ -2764,7 +2769,7 @@ type TextDocumentFilterScheme struct {
27642769
// @since 3.18.0
27652770
Scheme string `json:"scheme"`
27662771

2767-
// Pattern a glob pattern, like **​/*.{ts,js}. See TextDocumentFilter for examples. 3.18.0 - support for relative patterns.
2772+
// Pattern a glob pattern, like **​/*.{ts,js}. See TextDocumentFilter for examples. 3.18.0 - support for relative patterns. Whether clients support relative patterns depends on the client capability `textDocuments.filters.relativePatternSupport`.
27682773
// @since 3.18.0
27692774
Pattern *GlobPattern `json:"pattern,omitempty"`
27702775
}
@@ -2783,7 +2788,7 @@ type TextDocumentFilterPattern struct {
27832788
// @since 3.18.0
27842789
Scheme string `json:"scheme,omitempty"`
27852790

2786-
// Pattern a glob pattern, like **​/*.{ts,js}. See TextDocumentFilter for examples. 3.18.0 - support for relative patterns.
2791+
// Pattern a glob pattern, like **​/*.{ts,js}. See TextDocumentFilter for examples. 3.18.0 - support for relative patterns. Whether clients support relative patterns depends on the client capability `textDocuments.filters.relativePatternSupport`.
27872792
// @since 3.18.0
27882793
Pattern GlobPattern `json:"pattern"`
27892794
}

lifecycle.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2024 The Go Language Server Authors
1+
// Copyright 2025 The Go Language Server Authors
22
// SPDX-License-Identifier: BSD-3-Clause
33

44
package protocol
@@ -883,6 +883,9 @@ type TextDocumentClientCapabilities struct {
883883
// Synchronization defines which synchronization capabilities the client supports.
884884
Synchronization *TextDocumentSyncClientCapabilities `json:"synchronization,omitempty"`
885885

886+
// Filters defines which filters the client supports.
887+
Filters *TextDocumentFilterClientCapabilities `json:"filters,omitempty"`
888+
886889
// Completion capabilities specific to the `textDocument/completion` request.
887890
Completion *CompletionClientCapabilities `json:"completion,omitempty"`
888891

tools/protocol-gen/generator/generator.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ func (gen *Generator) writeTo(pp []Printer) (err error) {
118118
gen.files[filename] = f
119119

120120
// Writes header content to the file at first
121-
f.WriteString(`// Copyright 2024 The Go Language Server Authors` + "\n")
121+
f.WriteString(`// Copyright 2025 The Go Language Server Authors` + "\n")
122122
f.WriteString(`// SPDX-License-Identifier: BSD-3-Clause` + "\n")
123123
f.WriteString("\n")
124124
f.WriteString(`package protocol` + "\n")
@@ -238,8 +238,7 @@ func (p *printer) WriteTo() (err error) {
238238
}
239239

240240
func normalizeMethodName(methName string) (methIdent string) {
241-
pairs := strings.Split(methName, "/")
242-
for _, s := range pairs {
241+
for s := range strings.SplitSeq(methName, "/") {
243242
methIdent += flect.Pascalize(s)
244243
}
245244

tools/protocol-gen/generator/structure.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,7 @@ var structureNames = map[string]string{
384384
"TextDocumentFilterLanguage": "language",
385385
"TextDocumentFilterScheme": "language",
386386
"TextDocumentFilterPattern": "language",
387+
"TextDocumentFilterClientCapabilities": "language",
387388
"NotebookDocumentFilterNotebookType": "document",
388389
"NotebookDocumentFilterScheme": "document",
389390
"NotebookDocumentFilterPattern": "document",

tools/protocol-gen/go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
module go.lsp.dev/protocol/tools/protocol-gen
22

3-
go 1.23
3+
go 1.24
44

55
require (
6-
github.com/gobuffalo/flect v1.0.2
6+
github.com/gobuffalo/flect v1.0.3
77
github.com/kortschak/utter v1.7.0
8-
golang.org/x/text v0.14.0
8+
golang.org/x/text v0.22.0
99
)

tools/protocol-gen/go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
22
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
33
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
4-
github.com/gobuffalo/flect v1.0.2 h1:eqjPGSo2WmjgY2XlpGwo2NXgL3RucAKo4k4qQMNA5sA=
5-
github.com/gobuffalo/flect v1.0.2/go.mod h1:A5msMlrHtLqh9umBSnvabjsMrCcCpAyzglnDvkbYKHs=
4+
github.com/gobuffalo/flect v1.0.3 h1:xeWBM2nui+qnVvNM4S3foBhCAL2XgPU+a7FdpelbTq4=
5+
github.com/gobuffalo/flect v1.0.3/go.mod h1:A5msMlrHtLqh9umBSnvabjsMrCcCpAyzglnDvkbYKHs=
66
github.com/kortschak/utter v1.7.0 h1:6NKMynvGUyqfeMTawfah4zyInlrgwzjkDAHrT+skx/w=
77
github.com/kortschak/utter v1.7.0/go.mod h1:vSmSjbyrlKjjsL71193LmzBOKgwePk9DH6uFaWHIInc=
88
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
@@ -14,8 +14,8 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
1414
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
1515
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
1616
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
17-
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
18-
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
17+
golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM=
18+
golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY=
1919
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
2020
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
2121
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=

0 commit comments

Comments
 (0)