Skip to content

Commit

Permalink
Review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
dbanck committed Aug 1, 2022
1 parent c0572fb commit 183acf2
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 27 deletions.
11 changes: 4 additions & 7 deletions internal/decoder/decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,10 @@ func varsPathContext(mod *state.Module) (*decoder.PathContext, error) {
}

func DecoderContext(ctx context.Context) decoder.DecoderContext {
dCtx := decoder.DecoderContext{
UtmSource: utm.UtmSource,
UtmMedium: utm.UtmMedium(ctx),
UseUtmContent: true,
CompletionHooks: make(decoder.CompletionFuncMap),
CompletionResolveHooks: make(decoder.CompletionResolveFuncMap),
}
dCtx := decoder.NewDecoderContext()
dCtx.UtmSource = utm.UtmSource
dCtx.UtmMedium = utm.UtmMedium(ctx)
dCtx.UseUtmContent = true

cc, err := ilsp.ClientCapabilities(ctx)
if err == nil {
Expand Down
12 changes: 1 addition & 11 deletions internal/hooks/hooks.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
// Package hooks enables the implementation of hooks for dynamic
// autocompletion. Hooks should be added to this package and
// registered in AppendCompletionHooks in completion_hooks.go.
//
// A hook must have the following signature:
// func (h *Hooks) Name(ctx context.Context, value cty.Value) ([]decoder.Candidate, error)
// It receives the current value of the attribute and must return
// a list of completion candidates.
//
// All hooks have access to path, filename and pos via context:
// path, ok := decoder.PathFromContext(ctx)
// filename, ok := decoder.FilenameFromContext(ctx)
// pos, ok := decoder.PosFromContext(ctx)
// registered via AppendCompletionHooks in completion_hooks.go.
package hooks

import "github.com/hashicorp/terraform-ls/internal/state"
Expand Down
9 changes: 1 addition & 8 deletions internal/langserver/handlers/completion_resolve.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,12 @@ import (
"context"

"github.com/hashicorp/hcl-lang/decoder"
"github.com/hashicorp/hcl-lang/lang"
ilsp "github.com/hashicorp/terraform-ls/internal/lsp"
"github.com/hashicorp/terraform-ls/internal/mdplain"
lsp "github.com/hashicorp/terraform-ls/internal/protocol"
)

type CompletionItem struct {
lsp.CompletionItem

ResolveHook *lang.ResolveHook `json:"data,omitempty"`
}

func (svc *service) CompletionItemResolve(ctx context.Context, params CompletionItem) (CompletionItem, error) {
func (svc *service) CompletionItemResolve(ctx context.Context, params lsp.CompletionItemR) (lsp.CompletionItemR, error) {
cc, err := ilsp.ClientCapabilities(ctx)
if err != nil {
return params, err
Expand Down
1 change: 0 additions & 1 deletion internal/lsp/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ func toCompletionItem(candidate lang.Candidate, caps lsp.CompletionClientCapabil
TextEdit: textEdit(candidate.TextEdit, snippetSupport),
Command: cmd,
AdditionalTextEdits: TextEdits(candidate.AdditionalTextEdits, snippetSupport),
// TODO set deprecated via `tags` if supported.
}

if candidate.ResolveHook != nil {
Expand Down
9 changes: 9 additions & 0 deletions internal/protocol/completion.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package protocol

import "github.com/hashicorp/hcl-lang/lang"

type CompletionItemR struct {
CompletionItem

ResolveHook *lang.ResolveHook `json:"data,omitempty"`
}

0 comments on commit 183acf2

Please sign in to comment.