1
0
mirror of https://github.com/golang/go synced 2024-11-18 16:04:44 -07:00

internal/lsp: expose option to disable timeouts for completion

This is useful for integration testing.

Fixes golang/go#36142

Change-Id: I175510df19f384a0a027267337925ebae15ef827
Reviewed-on: https://go-review.googlesource.com/c/tools/+/211584
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
This commit is contained in:
Rebecca Stambler 2019-12-16 19:35:09 -05:00
parent 621d4eef75
commit c39ce2148d

View File

@ -250,6 +250,10 @@ func (o *Options) set(name string, value interface{}) OptionResult {
result.setBool(&o.Completion.CaseSensitive)
case "completeUnimported":
result.setBool(&o.Completion.Unimported)
case "completionTimeout":
if v, ok := result.asInt(); ok {
o.Completion.Budget = time.Duration(v) * time.Second
}
case "hoverKind":
hoverKind, ok := value.(string)
@ -347,6 +351,15 @@ func (r *OptionResult) asBool() (bool, bool) {
return b, true
}
func (r *OptionResult) asInt() (int, bool) {
b, ok := r.Value.(int)
if !ok {
r.errorf("Invalid type %T for int option %q", r.Value, r.Name)
return 0, false
}
return b, true
}
func (r *OptionResult) setBool(b *bool) {
if v, ok := r.asBool(); ok {
*b = v