Skip to content

Commit dd2e1a6

Browse files
authored
Merge pull request #8 from myleshyson/bugfix/fix-double-pointer
fix: dont make a property a pointer if it already is one.
2 parents 6a5d00d + 21318fd commit dd2e1a6

File tree

3 files changed

+26
-19
lines changed

3 files changed

+26
-19
lines changed

lspgenerator/go/enums.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,14 @@ def generate_enums(
2929
string += f"\t{enum.name}{capitalize(value.name)} {enum.name} = {raw_value}\n"
3030
string += ")\n"
3131
if not enum.supportsCustomValues:
32+
enum_cases = list(set(raw_values))
33+
enum_cases.sort()
34+
3235
string += join(
3336
[
3437
f"func (t {enum.name}) validate() error {{",
3538
" switch t {",
36-
f" case {join(list(set(raw_values)), ',')}:",
39+
f" case {join(enum_cases, ',')}:",
3740
" return nil",
3841
" }",
3942
f' return fmt.Errorf("invalid {enum.name}: %v", t)',

lspgenerator/go/structs.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,11 @@ def generate_structs(
6060
struct.name,
6161
)
6262

63-
property_type = f"*{property_type}" if is_pointer else property_type
63+
property_type = (
64+
f"*{property_type}"
65+
if is_pointer and "*" not in property_type
66+
else property_type
67+
)
6468

6569
json_mapping = type_resolver.json_mapping(
6670
property_type,

protocol/types.go

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6173,7 +6173,7 @@ type InitializeParams struct {
61736173
// if no folder is open.
61746174
//
61756175
// @deprecated in favour of rootUri.
6176-
RootPath **string `json:"rootPath,omitzero"`
6176+
RootPath *string `json:"rootPath,omitzero"`
61776177
// The rootUri of the workspace. Is null if no
61786178
// folder is open. If both `rootPath` and `rootUri` are set
61796179
// `rootUri` wins.
@@ -10274,7 +10274,7 @@ type SignatureHelp struct {
1027410274
// In future version of the protocol this property might become
1027510275
// mandatory (but still nullable) to better express the active parameter if
1027610276
// the active signature does have any.
10277-
ActiveParameter **uint32 `json:"activeParameter,omitzero"`
10277+
ActiveParameter *uint32 `json:"activeParameter,omitzero"`
1027810278
// The active signature. If omitted or the value lies outside the
1027910279
// range of `signatures` the value defaults to zero or is ignored if
1028010280
// the `SignatureHelp` has no signatures.
@@ -10500,7 +10500,7 @@ type SignatureInformation struct {
1050010500
// `SignatureHelp.activeParameter`.
1050110501
//
1050210502
// @since 3.16.0
10503-
ActiveParameter **uint32 `json:"activeParameter,omitzero"`
10503+
ActiveParameter *uint32 `json:"activeParameter,omitzero"`
1050410504
// The human-readable doc-comment of this signature. Will be shown
1050510505
// in the UI but can be omitted.
1050610506
Documentation *Or2[string, MarkupContent] `json:"documentation,omitzero"`
@@ -13012,7 +13012,7 @@ type _InitializeParams struct {
1301213012
// if no folder is open.
1301313013
//
1301413014
// @deprecated in favour of rootUri.
13015-
RootPath **string `json:"rootPath,omitzero"`
13015+
RootPath *string `json:"rootPath,omitzero"`
1301613016
// The rootUri of the workspace. Is null if no
1301713017
// folder is open. If both `rootPath` and `rootUri` are set
1301813018
// `rootUri` wins.
@@ -18620,7 +18620,7 @@ const (
1862018620
)
1862118621
func (t CompletionItemKind) validate() error {
1862218622
switch t {
18623-
case 14,13,1,23,21,18,2,24,22,3,8,16,4,6,25,11,5,17,12,10,15,20,9,7,19:
18623+
case 1,10,11,12,13,14,15,16,17,18,19,2,20,21,22,23,24,25,3,4,5,6,7,8,9:
1862418624
return nil
1862518625
}
1862618626
return fmt.Errorf("invalid CompletionItemKind: %v", t)
@@ -18724,7 +18724,7 @@ const (
1872418724
)
1872518725
func (t DiagnosticSeverity) validate() error {
1872618726
switch t {
18727-
case 1,2,4,3:
18727+
case 1,2,3,4:
1872818728
return nil
1872918729
}
1873018730
return fmt.Errorf("invalid DiagnosticSeverity: %v", t)
@@ -18794,7 +18794,7 @@ const (
1879418794
)
1879518795
func (t DocumentDiagnosticReportKind) validate() error {
1879618796
switch t {
18797-
case "unchanged","full":
18797+
case "full","unchanged":
1879818798
return nil
1879918799
}
1880018800
return fmt.Errorf("invalid DocumentDiagnosticReportKind: %v", t)
@@ -18874,7 +18874,7 @@ const (
1887418874
)
1887518875
func (t FailureHandlingKind) validate() error {
1887618876
switch t {
18877-
case "abort","transactional","textOnlyTransactional","undo":
18877+
case "abort","textOnlyTransactional","transactional","undo":
1887818878
return nil
1887918879
}
1888018880
return fmt.Errorf("invalid FailureHandlingKind: %v", t)
@@ -18944,7 +18944,7 @@ const (
1894418944
)
1894518945
func (t FileOperationPatternKind) validate() error {
1894618946
switch t {
18947-
case "folder","file":
18947+
case "file","folder":
1894818948
return nil
1894918949
}
1895018950
return fmt.Errorf("invalid FileOperationPatternKind: %v", t)
@@ -19205,7 +19205,7 @@ const (
1920519205
)
1920619206
func (t MarkupKind) validate() error {
1920719207
switch t {
19208-
case "plaintext","markdown":
19208+
case "markdown","plaintext":
1920919209
return nil
1921019210
}
1921119211
return fmt.Errorf("invalid MarkupKind: %v", t)
@@ -19241,7 +19241,7 @@ const (
1924119241
)
1924219242
func (t MessageType) validate() error {
1924319243
switch t {
19244-
case 4,3,1,5,2:
19244+
case 1,2,3,4,5:
1924519245
return nil
1924619246
}
1924719247
return fmt.Errorf("invalid MessageType: %v", t)
@@ -19277,7 +19277,7 @@ const (
1927719277
)
1927819278
func (t MonikerKind) validate() error {
1927919279
switch t {
19280-
case "local","import","export":
19280+
case "export","import","local":
1928119281
return nil
1928219282
}
1928319283
return fmt.Errorf("invalid MonikerKind: %v", t)
@@ -19386,7 +19386,7 @@ const (
1938619386
)
1938719387
func (t ResourceOperationKind) validate() error {
1938819388
switch t {
19389-
case "rename","create","delete":
19389+
case "create","delete","rename":
1939019390
return nil
1939119391
}
1939219392
return fmt.Errorf("invalid ResourceOperationKind: %v", t)
@@ -19531,7 +19531,7 @@ const (
1953119531
)
1953219532
func (t SymbolKind) validate() error {
1953319533
switch t {
19534-
case 14,13,1,23,21,2,18,24,22,3,8,16,4,6,25,11,5,17,12,10,15,26,20,9,7,19:
19534+
case 1,10,11,12,13,14,15,16,17,18,19,2,20,21,22,23,24,25,26,3,4,5,6,7,8,9:
1953519535
return nil
1953619536
}
1953719537
return fmt.Errorf("invalid SymbolKind: %v", t)
@@ -19634,7 +19634,7 @@ const (
1963419634
)
1963519635
func (t TextDocumentSyncKind) validate() error {
1963619636
switch t {
19637-
case 1,2,0:
19637+
case 0,1,2:
1963819638
return nil
1963919639
}
1964019640
return fmt.Errorf("invalid TextDocumentSyncKind: %v", t)
@@ -19698,7 +19698,7 @@ const (
1969819698
)
1969919699
func (t TraceValue) validate() error {
1970019700
switch t {
19701-
case "verbose","off","messages":
19701+
case "messages","off","verbose":
1970219702
return nil
1970319703
}
1970419704
return fmt.Errorf("invalid TraceValue: %v", t)
@@ -19736,7 +19736,7 @@ const (
1973619736
)
1973719737
func (t UniquenessLevel) validate() error {
1973819738
switch t {
19739-
case "document","global","project","group","scheme":
19739+
case "document","global","group","project","scheme":
1974019740
return nil
1974119741
}
1974219742
return fmt.Errorf("invalid UniquenessLevel: %v", t)

0 commit comments

Comments
 (0)