Skip to content

Commit 14e4460

Browse files
committed
upg to use new()
1 parent 41e4dfe commit 14e4460

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

lsp.go

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func initialize(context *glsp.Context, params *protocol.InitializeParams) (any,
3030
TriggerCharacters: []string{",", ".", " ", "(", "\"", "="},
3131
}
3232
capabilities.TextDocumentSync = protocol.TextDocumentSyncOptions{
33-
Change: ptr(protocol.TextDocumentSyncKindFull),
33+
Change: new(protocol.TextDocumentSyncKindFull),
3434
Save: true,
3535
}
3636
capabilities.DocumentFormattingProvider = true
@@ -575,9 +575,9 @@ func textDocumentCompletion(context *glsp.Context, params *protocol.CompletionPa
575575
for _, col := range columns {
576576
items = append(items, protocol.CompletionItem{
577577
Label: col,
578-
Kind: ptr(protocol.CompletionItemKindField),
579-
Detail: ptr("Column"),
580-
InsertText: ptr(col),
578+
Kind: new(protocol.CompletionItemKindField),
579+
Detail: new("Column"),
580+
InsertText: new(col),
581581
})
582582
}
583583
return items, nil
@@ -606,7 +606,7 @@ func textDocumentCompletion(context *glsp.Context, params *protocol.CompletionPa
606606
for table := range dbSchemaCache {
607607
items = append(items, protocol.CompletionItem{
608608
Label: table,
609-
Kind: ptr(protocol.CompletionItemKindClass),
609+
Kind: new(protocol.CompletionItemKindClass),
610610
})
611611
}
612612
return items, nil
@@ -623,8 +623,8 @@ func textDocumentCompletion(context *glsp.Context, params *protocol.CompletionPa
623623
if !seen[alias] {
624624
items = append(items, protocol.CompletionItem{
625625
Label: alias,
626-
Kind: ptr(protocol.CompletionItemKindClass),
627-
Detail: ptr("Table/Alias"),
626+
Kind: new(protocol.CompletionItemKindClass),
627+
Detail: new("Table/Alias"),
628628
})
629629
seen[alias] = true
630630
}
@@ -635,9 +635,9 @@ func textDocumentCompletion(context *glsp.Context, params *protocol.CompletionPa
635635
for _, col := range columns {
636636
items = append(items, protocol.CompletionItem{
637637
Label: col,
638-
Kind: ptr(protocol.CompletionItemKindField),
639-
Detail: ptr("Column from " + realName),
640-
InsertText: ptr(col),
638+
Kind: new(protocol.CompletionItemKindField),
639+
Detail: new("Column from " + realName),
640+
InsertText: new(col),
641641
})
642642
}
643643
}
@@ -647,8 +647,8 @@ func textDocumentCompletion(context *glsp.Context, params *protocol.CompletionPa
647647
if !seen[table] {
648648
items = append(items, protocol.CompletionItem{
649649
Label: table,
650-
Kind: ptr(protocol.CompletionItemKindClass),
651-
Detail: ptr("Table"),
650+
Kind: new(protocol.CompletionItemKindClass),
651+
Detail: new("Table"),
652652
})
653653
}
654654
}
@@ -689,8 +689,9 @@ func toOffset(content string, position protocol.Position) int {
689689
return offset
690690
}
691691

692+
//go:fix inline
692693
func ptr[T any](v T) *T {
693-
return &v
694+
return new(v)
694695
}
695696

696697
func createCompletions(keys ...string) []protocol.CompletionItem {
@@ -699,9 +700,9 @@ func createCompletions(keys ...string) []protocol.CompletionItem {
699700
if snippet, ok := CompletionItems[key]; ok {
700701
items = append(items, protocol.CompletionItem{
701702
Label: snippet.Label,
702-
Kind: ptr(snippet.Kind),
703-
InsertTextFormat: ptr(snippet.InsertTextFormat),
704-
InsertText: ptr(snippet.InsertText),
703+
Kind: new(snippet.Kind),
704+
InsertTextFormat: new(snippet.InsertTextFormat),
705+
InsertText: new(snippet.InsertText),
705706
})
706707
}
707708
}

0 commit comments

Comments
 (0)