feat: Add values-file completions and createCompletionItem helper - #131
Open
diofeher wants to merge 7 commits into
Open
feat: Add values-file completions and createCompletionItem helper#131diofeher wants to merge 7 commits into
diofeher wants to merge 7 commits into
Conversation
Introduce three focused packages ported from PR #55 to support stack/values-file features in subsequent PRs: - internal/ast/config: ConfigAST interface with include/dependency label extraction and include-scope building. - internal/ast/stack: StackAST interface with unit/stack block helpers (FindUnitAt, FindStackAt, source/path getters). - internal/stackutils: LookupUnitPath and LookupStackPath against a parsed *config.StackConfig.
Relocate IsIncludeBlock, IsDependencyBlock, GetNodeIncludeLabel, GetNodeDependencyLabel and the Includes scope out of internal/ast and into internal/ast/config. Include/dependency are config-file concerns and do not belong on the generic IndexedAST. Stack and values files get their own AST packages in follow-ups. - definition.GetDefinitionTargetWithContext now wraps store.AST in astconfig.NewConfigAST and calls GetIncludeLabel/GetDependencyLabel. - Drop corresponding tests from internal/ast/ast_test.go; equivalent coverage lives in internal/ast/config/config_test.go.
Port PR #55's stack handlers, adapted to main's unified store.Store (gated on FileType) and the ast/stack + stackutils foundation packages from the prior commit. - hover/stack.go: GetStackHoverTargetWithContext returns hover info for unit/stack blocks, source attributes, and path attributes. Contexts: HoverContextStackUnit/Source/Path/Block. - definition/stack.go: GetStackDefinitionTargetWithContext navigates from unit/stack blocks to their source modules and resolved paths. ResolveUnitSourceLocation prefers main.tf, falls back to the first *.tf file, then the source directory itself. ResolveStackSourceLocation prefers terragrunt.stack.hcl, falls back to the directory. - resolveBlockPath honors no_dot_terragrunt_stack when set on the matching unit/stack entry in the parsed StackConfig.
Replace the single-FileType early-return guard in State.Hover and State.Definition with a switch on FileType, routing FileTypeUnit to the existing unit logic and FileTypeStack to the new handlers added in the prior commit. - Hover: adds hoverStack dispatch and four stack-specific HoverResponse constructors (unit / source / path / block). - Definition: adds definitionStack dispatch. Unit/stack source contexts resolve via ResolveUnitSourceLocation / ResolveStackSourceLocation; path contexts return the already-resolved target directly. - state_test.go: extends TestState_Hover_StackFile and TestState_Definition_StackFile into real end-to-end assertions for unit source/path hover popups and unit-source navigation.
Port PR #55's values handlers, adapted to main's unified store.Store. - hover/values.go: GetValuesHoverTargetWithContext detects dependency.<name>.<output> references and plain variable words. Contexts: HoverContextValuesVariable, HoverContextValuesDependency. - definition/values.go: GetValuesDefinitionTargetWithContext detects dependency references. ResolveValuesDependencyPath searches common sibling/parent directory layouts for the dependency's terragrunt.hcl.
Extend the Hover and Definition switch to route FileTypeValues through the new values handlers. - hoverValues builds markdown popups for variables and dependency references (newValuesVariableHoverResponse / newValuesDependencyHoverResponse). - definitionValues resolves dependency references to the matching terragrunt.hcl via ResolveValuesDependencyPath. - Rewrite TestState_Hover_ValuesFile to assert real popups and add TestState_Definition_ValuesFile covering dependency navigation.
Contributor
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
diofeher
marked this pull request as draft
April 17, 2026 10:42
Port PR #55's completion enhancements while keeping main's store.FileType as the canonical file-type enum (no duplicate TerragruntFileType). - Introduce createCompletionItem to reduce snippet-construction boilerplate in the stack and values block-completion lists (Kind=Class). - Refactor newStackCompletions to use the helper. - Add newValuesCompletions with 'values' and 'dependency' block snippets, and route FileTypeValues through it (previously returned an empty list). - Add completion_test.go coverage for values-file routing.
diofeher
force-pushed
the
feat/completion-enhancements
branch
from
April 17, 2026 10:44
c131cf4 to
df86add
Compare
diofeher
marked this pull request as ready for review
April 17, 2026 10:48
diofeher
force-pushed
the
feat/values-file-hover-definition
branch
from
April 27, 2026 12:29
ee31994 to
5a47672
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Ports #55's completion enhancements while keeping main's
store.FileTypeas the canonical enum (deliberately does not introduce PR #55's duplicateTerragruntFileType).createCompletionItemhelper reduces snippet-construction boilerplate across block completions (allKind=Class).newStackCompletionsrefactored to use the helper.newValuesCompletionsadded withvaluesanddependencyblock snippets;FileTypeValuesnow routes through it (previously returned an empty list).dep\u2192dependency,val\u2192values).Stacked on #130. Final PR in the four-part cherry-pick of #55.
Test plan
go build ./...go test ./internal/...golangci-lint run\u2014 0 issuesdepinside aterragrunt.values.hcland confirm thedependencysnippet appears.