Skip to content

Commit

Permalink
source version specific built-in references from terraform-schema
Browse files Browse the repository at this point in the history
  • Loading branch information
ansgarm authored and dbanck committed Nov 7, 2024
1 parent 1d863ba commit 4179261
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 59 deletions.
3 changes: 3 additions & 0 deletions internal/features/modules/decoder/module_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ func modulePathContext(mod *state.ModuleRecord, stateReader CombinedReader) (*de
}
}

// append Terraform version specific path targets that are available in all modules (builtin references)
pathCtx.ReferenceTargets = append(pathCtx.ReferenceTargets, referencesForModule(mod, stateReader)...)

for name, f := range mod.ParsedModuleFiles {
pathCtx.Files[name.String()] = f
}
Expand Down
17 changes: 17 additions & 0 deletions internal/features/modules/decoder/references.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package decoder

import (
"github.com/hashicorp/hcl-lang/reference"
"github.com/hashicorp/terraform-ls/internal/features/modules/state"
tfschema "github.com/hashicorp/terraform-schema/schema"
)

func referencesForModule(mod *state.ModuleRecord, stateReader CombinedReader) reference.Targets {
modPath := mod.Path()
resolvedVersion := tfschema.ResolveVersion(stateReader.TerraformVersion(modPath), mod.Meta.CoreRequirements)

return tfschema.BuiltinReferencesForVersion(resolvedVersion, modPath)
}
57 changes: 0 additions & 57 deletions internal/features/modules/jobs/builtin_references.go

This file was deleted.

2 changes: 0 additions & 2 deletions internal/features/modules/jobs/references.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ func DecodeReferenceTargets(ctx context.Context, modStore *state.ModuleStore, ro
}
targets, rErr := pd.CollectReferenceTargets()

targets = append(targets, builtinReferences(modPath)...)

sErr := modStore.UpdateReferenceTargets(modPath, targets, rErr)
if sErr != nil {
return sErr
Expand Down

0 comments on commit 4179261

Please sign in to comment.