mirror of
https://github.com/golang/go
synced 2024-11-18 19:24:39 -07:00
internal/lsp/cmd: fix a nil pointer and some minor clean-up
This change fixes a nil error, in addition to cleaning up a spacing error and a typo. It also fixes the golint errors in internal/lsp/cmd. Updates golang/go#30091 Change-Id: I24867bb878fda4e341f87d31bbec701a3814a341 Reviewed-on: https://go-review.googlesource.com/c/161220 Reviewed-by: Ian Cottrell <iancottrell@google.com> Run-TryBot: Rebecca Stambler <rstambler@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
279ab8e001
commit
40960b6deb
@ -12,6 +12,7 @@ import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"go/token"
|
||||
|
||||
"golang.org/x/tools/go/packages"
|
||||
"golang.org/x/tools/internal/tool"
|
||||
)
|
||||
|
@ -99,43 +99,43 @@ func parseLocation(value string) (Location, error) {
|
||||
}
|
||||
loc.Filename = m[posReFile]
|
||||
if m[posReSLine] != "" {
|
||||
if v, err := strconv.ParseInt(m[posReSLine], 10, 32); err != nil {
|
||||
v, err := strconv.ParseInt(m[posReSLine], 10, 32)
|
||||
if err != nil {
|
||||
return loc, err
|
||||
} else {
|
||||
loc.Start.Line = int(v)
|
||||
}
|
||||
if v, err := strconv.ParseInt(m[posReSCol], 10, 32); err != nil {
|
||||
loc.Start.Line = int(v)
|
||||
v, err = strconv.ParseInt(m[posReSCol], 10, 32)
|
||||
if err != nil {
|
||||
return loc, err
|
||||
} else {
|
||||
loc.Start.Column = int(v)
|
||||
}
|
||||
loc.Start.Column = int(v)
|
||||
} else {
|
||||
if v, err := strconv.ParseInt(m[posReSOff], 10, 32); err != nil {
|
||||
v, err := strconv.ParseInt(m[posReSOff], 10, 32)
|
||||
if err != nil {
|
||||
return loc, err
|
||||
} else {
|
||||
loc.Start.Offset = int(v)
|
||||
}
|
||||
loc.Start.Offset = int(v)
|
||||
}
|
||||
if m[posReEnd] == "" {
|
||||
loc.End = loc.Start
|
||||
} else {
|
||||
if m[posReELine] != "" {
|
||||
if v, err := strconv.ParseInt(m[posReELine], 10, 32); err != nil {
|
||||
v, err := strconv.ParseInt(m[posReELine], 10, 32)
|
||||
if err != nil {
|
||||
return loc, err
|
||||
} else {
|
||||
loc.End.Line = int(v)
|
||||
}
|
||||
if v, err := strconv.ParseInt(m[posReECol], 10, 32); err != nil {
|
||||
loc.End.Line = int(v)
|
||||
v, err = strconv.ParseInt(m[posReECol], 10, 32)
|
||||
if err != nil {
|
||||
return loc, err
|
||||
} else {
|
||||
loc.End.Column = int(v)
|
||||
}
|
||||
loc.End.Column = int(v)
|
||||
} else {
|
||||
if v, err := strconv.ParseInt(m[posReEOff], 10, 32); err != nil {
|
||||
v, err := strconv.ParseInt(m[posReEOff], 10, 32)
|
||||
if err != nil {
|
||||
return loc, err
|
||||
} else {
|
||||
loc.End.Offset = int(v)
|
||||
}
|
||||
loc.End.Offset = int(v)
|
||||
}
|
||||
}
|
||||
return loc, nil
|
||||
|
@ -24,7 +24,7 @@ const (
|
||||
// query implements the query command.
|
||||
type query struct {
|
||||
JSON bool `flag:"json" help:"emit output in JSON format"`
|
||||
Emulate string `flag:"emulate" help:"compatability mode, causes gopls to emulate another tool.\nvalues depend on the operation being performed"`
|
||||
Emulate string `flag:"emulate" help:"compatibility mode, causes gopls to emulate another tool.\nvalues depend on the operation being performed"`
|
||||
|
||||
app *Application
|
||||
}
|
||||
|
@ -101,7 +101,10 @@ func (s *Server) Run(ctx context.Context, args ...string) error {
|
||||
msec := int(elapsed.Round(time.Millisecond) / time.Millisecond)
|
||||
fmt.Fprintf(outx, " in %dms", msec)
|
||||
}
|
||||
params := string(*payload)
|
||||
params := "null"
|
||||
if payload != nil {
|
||||
params = string(*payload)
|
||||
}
|
||||
if params == "null" {
|
||||
params = "{}"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user