feat: Hover and go-to-definition for terragrunt.values.hcl - #130
feat: Hover and go-to-definition for terragrunt.values.hcl#130diofeher wants to merge 9 commits into
Conversation
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.
|
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 |
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. Co-authored-by: Diogenes Fernandes <diofeher@gmail.com>
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. Co-authored-by: Diogenes Fernandes <diofeher@gmail.com>
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. Co-authored-by: Diogenes Fernandes <diofeher@gmail.com>
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. Co-authored-by: Diogenes Fernandes <diofeher@gmail.com>
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. Co-authored-by: Diogenes Fernandes <diofeher@gmail.com>
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. Co-authored-by: Diogenes Fernandes <diofeher@gmail.com>
ee31994 to
5a47672
Compare
…' into feat/values-file-hover-definition # Conflicts: # internal/tg/state.go
|
Tested and working fine. |
ca2ece7 to
dc9edaf
Compare
Summary
Adds hover popups and go-to-definition for
terragrunt.values.hclfiles, ported from #55 and adapted to main's unifiedStore+FileTypearchitecture.internal/tg/hover/values.go: hover info for plain variables anddependency.<name>.<output>references.internal/tg/definition/values.go: navigate fromdependency.<name>references to the matchingterragrunt.hcl.ResolveValuesDependencyPathsearches sibling/parent directory layouts.internal/tg/state.go: extends theFileTypeswitch inHoverandDefinitionwithFileTypeValuesdispatch. AddshoverValues/definitionValuesand two values-specificHoverResponseconstructors.TestState_Hover_ValuesFilefor real popups and addsTestState_Definition_ValuesFilecovering dependency navigation.Stacked on #129.
Test plan
go build ./...go test ./internal/...golangci-lint run\u2014 0 issuesterragrunt.values.hcl, hover over variables and dependency references, F12 on a dependency reference to verify navigation.