Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update go #85

Merged
merged 1 commit into from
May 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/kitagry/regols

go 1.19
go 1.22

require (
github.com/google/go-cmp v0.6.0
Expand Down
2 changes: 1 addition & 1 deletion langserver/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/sourcegraph/jsonrpc2"
)

func (h *handler) handleTextDocumentCompletion(ctx context.Context, conn *jsonrpc2.Conn, req *jsonrpc2.Request) (result interface{}, err error) {
func (h *handler) handleTextDocumentCompletion(ctx context.Context, conn *jsonrpc2.Conn, req *jsonrpc2.Request) (result any, err error) {
if req.Params == nil {
return nil, &jsonrpc2.Error{Code: jsonrpc2.CodeInvalidParams}
}
Expand Down
4 changes: 2 additions & 2 deletions langserver/definition.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/sourcegraph/jsonrpc2"
)

func (h *handler) handleTextDocumentDefinition(ctx context.Context, conn *jsonrpc2.Conn, req *jsonrpc2.Request) (result interface{}, err error) {
func (h *handler) handleTextDocumentDefinition(ctx context.Context, _ *jsonrpc2.Conn, req *jsonrpc2.Request) (result any, err error) {
if req.Params == nil {
return nil, &jsonrpc2.Error{Code: jsonrpc2.CodeInvalidParams}
}
Expand All @@ -23,7 +23,7 @@ func (h *handler) handleTextDocumentDefinition(ctx context.Context, conn *jsonrp
return h.lookupIdent(ctx, params.TextDocument.URI, params.Position)
}

func (h *handler) lookupIdent(ctx context.Context, uri lsp.DocumentURI, position lsp.Position) ([]lsp.Location, error) {
func (h *handler) lookupIdent(_ context.Context, uri lsp.DocumentURI, position lsp.Position) ([]lsp.Location, error) {
loc := h.toOPALocation(position, uri)
lookupResults, err := h.project.LookupDefinition(loc)
if err != nil {
Expand Down
11 changes: 3 additions & 8 deletions langserver/diagnostic.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,7 @@ import (
func (h *handler) diagnostic() {
running := make(map[lsp.DocumentURI]context.CancelFunc)

for {
uri, ok := <-h.diagnosticRequest
if !ok {
break
}

for uri := range h.diagnosticRequest {
cancel, ok := running[uri]
if ok {
cancel()
Expand All @@ -25,7 +20,7 @@ func (h *handler) diagnostic() {
running[uri] = cancel

go func() {
diagnostics, err := h.diagnose(ctx, uri)
diagnostics, err := h.diagnose(uri)
if err != nil {
h.logger.Println(err)
return
Expand All @@ -41,7 +36,7 @@ func (h *handler) diagnostic() {
}
}

func (h *handler) diagnose(ctx context.Context, uri lsp.DocumentURI) (map[lsp.DocumentURI][]lsp.Diagnostic, error) {
func (h *handler) diagnose(uri lsp.DocumentURI) (map[lsp.DocumentURI][]lsp.Diagnostic, error) {
result := make(map[lsp.DocumentURI][]lsp.Diagnostic)

pathToErrs := h.project.GetErrors(documentURIToURI(uri))
Expand Down
2 changes: 1 addition & 1 deletion langserver/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/sourcegraph/jsonrpc2"
)

func (h *handler) handleTextDocumentFormatting(ctx context.Context, conn *jsonrpc2.Conn, req *jsonrpc2.Request) (result interface{}, err error) {
func (h *handler) handleTextDocumentFormatting(_ context.Context, _ *jsonrpc2.Conn, req *jsonrpc2.Request) (result any, err error) {
if req.Params == nil {
return nil, &jsonrpc2.Error{Code: jsonrpc2.CodeInvalidParams}
}
Expand Down
4 changes: 2 additions & 2 deletions langserver/hover.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/sourcegraph/jsonrpc2"
)

func (h *handler) handleTextDocumentHover(ctx context.Context, conn *jsonrpc2.Conn, req *jsonrpc2.Request) (result interface{}, err error) {
func (h *handler) handleTextDocumentHover(ctx context.Context, _ *jsonrpc2.Conn, req *jsonrpc2.Request) (result any, err error) {
if req.Params == nil {
return nil, &jsonrpc2.Error{Code: jsonrpc2.CodeInvalidParams}
}
Expand All @@ -21,7 +21,7 @@ func (h *handler) handleTextDocumentHover(ctx context.Context, conn *jsonrpc2.Co
return h.documentIdent(ctx, params.TextDocument.URI, params.Position)
}

func (h *handler) documentIdent(ctx context.Context, uri lsp.DocumentURI, position lsp.Position) (lsp.Hover, error) {
func (h *handler) documentIdent(_ context.Context, uri lsp.DocumentURI, position lsp.Position) (lsp.Hover, error) {
loc := h.toOPALocation(position, uri)
documentResults, err := h.project.TermDocument(loc)
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions langserver/initialize.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/sourcegraph/jsonrpc2"
)

func (h *handler) handleInitialize(ctx context.Context, conn *jsonrpc2.Conn, req *jsonrpc2.Request) (result interface{}, err error) {
func (h *handler) handleInitialize(_ context.Context, conn *jsonrpc2.Conn, req *jsonrpc2.Request) (result any, err error) {
if req.Params == nil {
return nil, &jsonrpc2.Error{Code: jsonrpc2.CodeInvalidParams}
}
Expand All @@ -31,7 +31,7 @@ func (h *handler) handleInitialize(ctx context.Context, conn *jsonrpc2.Conn, req
return lsp.InitializeResult{
Capabilities: lsp.ServerCapabilities{
TextDocumentSync: &lsp.TextDocumentSyncOptionsOrKind{
Kind: tdskToPTr(lsp.TDSKFull),
Kind: toPtr(lsp.TDSKFull),
},
DocumentFormattingProvider: true,
DefinitionProvider: true,
Expand All @@ -45,6 +45,6 @@ func (h *handler) handleInitialize(ctx context.Context, conn *jsonrpc2.Conn, req
}, nil
}

func tdskToPTr(s lsp.TextDocumentSyncKind) *lsp.TextDocumentSyncKind {
return &s
func toPtr[T any](t T) *T {
return &t
}
26 changes: 13 additions & 13 deletions langserver/internal/lsp/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type InitializeParams struct {
RootURI DocumentURI `json:"rootUri,omitempty"`
ClientInfo ClientInfo `json:"clientInfo,omitempty"`
Trace Trace `json:"trace,omitempty"`
InitializationOptions interface{} `json:"initializationOptions,omitempty"`
InitializationOptions any `json:"initializationOptions,omitempty"`
Capabilities ClientCapabilities `json:"capabilities"`

WorkDoneToken string `json:"workDoneToken,omitempty"`
Expand Down Expand Up @@ -54,7 +54,7 @@ type ClientCapabilities struct {
Workspace WorkspaceClientCapabilities `json:"workspace,omitempty"`
TextDocument TextDocumentClientCapabilities `json:"textDocument,omitempty"`
Window WindowClientCapabilities `json:"window,omitempty"`
Experimental interface{} `json:"experimental,omitempty"`
Experimental any `json:"experimental,omitempty"`

// Below are Sourcegraph extensions. They do not live in lspext since
// they are extending the field InitializeParams.Capabilities
Expand Down Expand Up @@ -196,7 +196,7 @@ type TextDocumentClientCapabilities struct {
FoldingRange *struct {
DynamicRegistration bool `json:"dynamicRegistration,omitempty"`

RangeLimit interface{} `json:"rangeLimit,omitempty"`
RangeLimit any `json:"rangeLimit,omitempty"`

LineFoldingOnly bool `json:"lineFoldingOnly,omitempty"`
} `json:"foldingRange,omitempty"`
Expand Down Expand Up @@ -334,7 +334,7 @@ type ServerCapabilities struct {
// is a Sourcegraph extension.
XWorkspaceSymbolByProperties bool `json:"xworkspaceSymbolByProperties,omitempty"`

Experimental interface{} `json:"experimental,omitempty"`
Experimental any `json:"experimental,omitempty"`
}

type CompletionOptions struct {
Expand All @@ -360,8 +360,8 @@ type ExecuteCommandOptions struct {
}

type ExecuteCommandParams struct {
Command string `json:"command"`
Arguments []interface{} `json:"arguments,omitempty"`
Command string `json:"command"`
Arguments []any `json:"arguments,omitempty"`
}

type SemanticHighlightingOptions struct {
Expand Down Expand Up @@ -442,7 +442,7 @@ type CompletionItem struct {
InsertTextFormat InsertTextFormat `json:"insertTextFormat,omitempty"`
TextEdit *TextEdit `json:"textEdit,omitempty"`
AdditionalTextEdits []TextEdit `json:"additionalTextEdits,omitempty"`
Data interface{} `json:"data,omitempty"`
Data any `json:"data,omitempty"`
}

type CompletionList struct {
Expand Down Expand Up @@ -480,7 +480,7 @@ type InsertTextFormat int

const (
ITFPlainText InsertTextFormat = 1
ITFSnippet = 2
ITFSnippet InsertTextFormat = 2
)

type CompletionContext struct {
Expand Down Expand Up @@ -680,7 +680,7 @@ type ConfigurationItem struct {
Section string `json:"section,omitempty"`
}

type ConfigurationResult []interface{}
type ConfigurationResult []any

type CodeActionContext struct {
Diagnostics []Diagnostic `json:"diagnostics"`
Expand All @@ -697,9 +697,9 @@ type CodeLensParams struct {
}

type CodeLens struct {
Range Range `json:"range"`
Command Command `json:"command,omitempty"`
Data interface{} `json:"data,omitempty"`
Range Range `json:"range"`
Command Command `json:"command,omitempty"`
Data any `json:"data,omitempty"`
}

type DocumentFormattingParams struct {
Expand Down Expand Up @@ -772,7 +772,7 @@ type LogMessageParams struct {
}

type DidChangeConfigurationParams struct {
Settings interface{} `json:"settings"`
Settings any `json:"settings"`
}

type FileChangeType int
Expand Down
2 changes: 1 addition & 1 deletion langserver/internal/lsp/structure.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ type Command struct {
* Arguments that the command handler should be
* invoked with.
*/
Arguments []interface{} `json:"arguments"`
Arguments []any `json:"arguments"`
}

type TextEdit struct {
Expand Down
2 changes: 1 addition & 1 deletion langserver/langserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func NewHandler() jsonrpc2.Handler {
return jsonrpc2.HandlerWithError(handler.handle)
}

func (h *handler) handle(ctx context.Context, conn *jsonrpc2.Conn, req *jsonrpc2.Request) (result interface{}, err error) {
func (h *handler) handle(ctx context.Context, conn *jsonrpc2.Conn, req *jsonrpc2.Request) (result any, err error) {
switch req.Method {
case "initialize":
return h.handleInitialize(ctx, conn, req)
Expand Down
4 changes: 2 additions & 2 deletions langserver/reference.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/sourcegraph/jsonrpc2"
)

func (h *handler) handleTextDocumentReferences(ctx context.Context, conn *jsonrpc2.Conn, req *jsonrpc2.Request) (result interface{}, err error) {
func (h *handler) handleTextDocumentReferences(ctx context.Context, _ *jsonrpc2.Conn, req *jsonrpc2.Request) (result any, err error) {
if req.Params == nil {
return nil, &jsonrpc2.Error{Code: jsonrpc2.CodeInvalidParams}
}
Expand All @@ -21,7 +21,7 @@ func (h *handler) handleTextDocumentReferences(ctx context.Context, conn *jsonrp
return h.lookupReferences(ctx, params.TextDocument.URI, params.Position)
}

func (h *handler) lookupReferences(ctx context.Context, uri lsp.DocumentURI, position lsp.Position) ([]lsp.Location, error) {
func (h *handler) lookupReferences(_ context.Context, uri lsp.DocumentURI, position lsp.Position) ([]lsp.Location, error) {
loc := h.toOPALocation(position, uri)
locations, err := h.project.LookupReferences(loc)
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions langserver/text_document.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/sourcegraph/jsonrpc2"
)

func (h *handler) handleTextDocumentDidOpen(ctx context.Context, conn *jsonrpc2.Conn, req *jsonrpc2.Request) (result interface{}, err error) {
func (h *handler) handleTextDocumentDidOpen(_ context.Context, _ *jsonrpc2.Conn, req *jsonrpc2.Request) (result any, err error) {
if req.Params == nil {
return nil, &jsonrpc2.Error{Code: jsonrpc2.CodeInvalidParams}
}
Expand All @@ -23,7 +23,7 @@ func (h *handler) handleTextDocumentDidOpen(ctx context.Context, conn *jsonrpc2.
return nil, nil
}

func (h *handler) handleTextDocumentDidChange(ctx context.Context, conn *jsonrpc2.Conn, req *jsonrpc2.Request) (result interface{}, err error) {
func (h *handler) handleTextDocumentDidChange(_ context.Context, _ *jsonrpc2.Conn, req *jsonrpc2.Request) (result any, err error) {
if req.Params == nil {
return nil, &jsonrpc2.Error{Code: jsonrpc2.CodeInvalidParams}
}
Expand All @@ -38,7 +38,7 @@ func (h *handler) handleTextDocumentDidChange(ctx context.Context, conn *jsonrpc
return nil, nil
}

func (h *handler) handleTextDocumentDidClose(ctx context.Context, conn *jsonrpc2.Conn, req *jsonrpc2.Request) (result interface{}, err error) {
func (h *handler) handleTextDocumentDidClose(_ context.Context, _ *jsonrpc2.Conn, req *jsonrpc2.Request) (result any, err error) {
if req.Params == nil {
return nil, &jsonrpc2.Error{Code: jsonrpc2.CodeInvalidParams}
}
Expand All @@ -53,7 +53,7 @@ func (h *handler) handleTextDocumentDidClose(ctx context.Context, conn *jsonrpc2
return nil, nil
}

func (h *handler) handleTextDocumentDidSave(ctx context.Context, conn *jsonrpc2.Conn, req *jsonrpc2.Request) (result interface{}, err error) {
func (h *handler) handleTextDocumentDidSave(_ context.Context, _ *jsonrpc2.Conn, req *jsonrpc2.Request) (result any, err error) {
if req.Params == nil {
return nil, &jsonrpc2.Error{Code: jsonrpc2.CodeInvalidParams}
}
Expand Down
Loading