Skip to content

Commit

Permalink
Prefill Required Attributes
Browse files Browse the repository at this point in the history
This adds a new experimental setting for prefilling required attributes as blocks are completed from intellisense. For example, completing a resource provider will fill in the required attributes automatically.
  • Loading branch information
jpogran committed Sep 29, 2021
1 parent 8840e7b commit 4ee3778
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
7 changes: 7 additions & 0 deletions internal/langserver/handlers/complete.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ func (h *logHandler) TextDocumentComplete(ctx context.Context, params lsp.Comple
}
d.SetSchema(schema)

expFeatures, err := lsctx.ExperimentalFeatures(ctx)
if err != nil {
d.PrefillRequiredAttributes = false
}

d.PrefillRequiredAttributes = expFeatures.PrefillRequiredAttributes

fPos, err := ilsp.FilePositionFromDocumentPosition(params.TextDocumentPositionParams, file)
if err != nil {
return list, err
Expand Down
1 change: 1 addition & 0 deletions internal/langserver/handlers/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ func (svc *service) Assigner() (jrpc2.Assigner, error) {
ctx = lsctx.WithDocumentStorage(ctx, svc.fs)
ctx = lsctx.WithClientCapabilities(ctx, cc)
ctx = lsctx.WithModuleFinder(ctx, svc.modMgr)
ctx = lsctx.WithExperimentalFeatures(ctx, &expFeatures)

return handle(ctx, req, lh.TextDocumentComplete)
},
Expand Down
3 changes: 2 additions & 1 deletion internal/settings/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import (
)

type ExperimentalFeatures struct {
ValidateOnSave bool `mapstructure:"validateOnSave"`
ValidateOnSave bool `mapstructure:"validateOnSave"`
PrefillRequiredAttributes bool `mapstructure:"prefillRequiredAttributes"`
}

type Options struct {
Expand Down

0 comments on commit 4ee3778

Please sign in to comment.