Skip to content

Commit 8e68113

Browse files
authored
doc(command): follow rename of module.tofu (#112)
Signed-off-by: bill fumerola <bill@fumerola.com>
1 parent f9e700f commit 8e68113

3 files changed

Lines changed: 7 additions & 21 deletions

File tree

docs/commands.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ installed version.
185185
}
186186
```
187187

188-
### `module.tofu`
188+
### `module.opentofu`
189189

190190
Provides information about the tofu binary version for the current module.
191191

internal/langserver/handlers/execute_command.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ func cmdHandlers(svc *service) cmd.Handlers {
3333
cmd.Name("module.calls"): cmdHandler.ModuleCallsHandler,
3434
cmd.Name("module.providers"): cmdHandler.ModuleProvidersHandler,
3535
cmd.Name("module.opentofu"): cmdHandler.TofuVersionRequestHandler,
36+
cmd.Name("module.tofu"): removedHandler("use module.opentofu instead"),
3637
}
3738
}
3839

internal/langserver/handlers/service.go

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"fmt"
1212
"io"
1313
"log"
14+
"maps"
1415
"time"
1516

1617
"github.com/creachadair/jrpc2"
@@ -81,7 +82,7 @@ type service struct {
8182
features *Features
8283

8384
walkerCollector *walker.WalkerCollector
84-
additionalHandlers map[string]rpch.Func
85+
additionalHandlers rpch.Map
8586

8687
singleFileMode bool
8788
}
@@ -127,7 +128,7 @@ func (svc *service) Assigner() (jrpc2.Assigner, error) {
127128
var expFeatures settings.ExperimentalFeatures
128129
var validationOptions settings.ValidationOptions
129130

130-
m := map[string]rpch.Func{
131+
m := rpch.Map{
131132
"initialize": func(ctx context.Context, req *jrpc2.Request) (interface{}, error) {
132133
err := session.Initialize(req)
133134
if err != nil {
@@ -402,13 +403,9 @@ func (svc *service) Assigner() (jrpc2.Assigner, error) {
402403
}
403404

404405
// For use in tests, e.g. to test request cancellation
405-
if len(svc.additionalHandlers) > 0 {
406-
for methodName, handlerFunc := range svc.additionalHandlers {
407-
m[methodName] = handlerFunc
408-
}
409-
}
406+
maps.Copy(m, svc.additionalHandlers)
410407

411-
return convertMap(m), nil
408+
return m, nil
412409
}
413410

414411
func (svc *service) configureSessionDependencies(ctx context.Context, cfgOpts *settings.Options) error {
@@ -623,18 +620,6 @@ func (svc *service) shutdown() {
623620
}
624621
}
625622

626-
// convertMap is a helper function allowing us to omit the jrpc2.Func
627-
// signature from the method definitions
628-
func convertMap(m map[string]rpch.Func) rpch.Map {
629-
hm := make(rpch.Map, len(m))
630-
631-
for method, fun := range m {
632-
hm[method] = rpch.New(fun)
633-
}
634-
635-
return hm
636-
}
637-
638623
const requestCancelled jrpc2.Code = -32800
639624
const tracerName = "github.com/opentofu/tofu-ls/internal/langserver/handlers"
640625

0 commit comments

Comments
 (0)