mirror of
https://github.com/golang/go.git
synced 2025-05-05 23:53:05 +00: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"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"go/token"
|
"go/token"
|
||||||
|
|
||||||
"golang.org/x/tools/go/packages"
|
"golang.org/x/tools/go/packages"
|
||||||
"golang.org/x/tools/internal/tool"
|
"golang.org/x/tools/internal/tool"
|
||||||
)
|
)
|
||||||
|
@ -99,43 +99,43 @@ func parseLocation(value string) (Location, error) {
|
|||||||
}
|
}
|
||||||
loc.Filename = m[posReFile]
|
loc.Filename = m[posReFile]
|
||||||
if m[posReSLine] != "" {
|
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
|
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
|
return loc, err
|
||||||
} else {
|
|
||||||
loc.Start.Column = int(v)
|
|
||||||
}
|
}
|
||||||
|
loc.Start.Column = int(v)
|
||||||
} else {
|
} 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
|
return loc, err
|
||||||
} else {
|
|
||||||
loc.Start.Offset = int(v)
|
|
||||||
}
|
}
|
||||||
|
loc.Start.Offset = int(v)
|
||||||
}
|
}
|
||||||
if m[posReEnd] == "" {
|
if m[posReEnd] == "" {
|
||||||
loc.End = loc.Start
|
loc.End = loc.Start
|
||||||
} else {
|
} else {
|
||||||
if m[posReELine] != "" {
|
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
|
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
|
return loc, err
|
||||||
} else {
|
|
||||||
loc.End.Column = int(v)
|
|
||||||
}
|
}
|
||||||
|
loc.End.Column = int(v)
|
||||||
} else {
|
} 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
|
return loc, err
|
||||||
} else {
|
|
||||||
loc.End.Offset = int(v)
|
|
||||||
}
|
}
|
||||||
|
loc.End.Offset = int(v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return loc, nil
|
return loc, nil
|
||||||
|
@ -24,7 +24,7 @@ const (
|
|||||||
// query implements the query command.
|
// query implements the query command.
|
||||||
type query struct {
|
type query struct {
|
||||||
JSON bool `flag:"json" help:"emit output in JSON format"`
|
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
|
app *Application
|
||||||
}
|
}
|
||||||
|
@ -101,7 +101,10 @@ func (s *Server) Run(ctx context.Context, args ...string) error {
|
|||||||
msec := int(elapsed.Round(time.Millisecond) / time.Millisecond)
|
msec := int(elapsed.Round(time.Millisecond) / time.Millisecond)
|
||||||
fmt.Fprintf(outx, " in %dms", msec)
|
fmt.Fprintf(outx, " in %dms", msec)
|
||||||
}
|
}
|
||||||
params := string(*payload)
|
params := "null"
|
||||||
|
if payload != nil {
|
||||||
|
params = string(*payload)
|
||||||
|
}
|
||||||
if params == "null" {
|
if params == "null" {
|
||||||
params = "{}"
|
params = "{}"
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user