-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support count and count.index completion in blocks
This provides completion hints inside blocks for `count.index` references within resource, data and module blocks anywhere the `count` meta-argument is supported. It detects if count is used already and does not suggest duplicates.
- Loading branch information
Showing
7 changed files
with
508 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package context | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/hashicorp/hcl-lang/schema" | ||
) | ||
|
||
type bodyExtCtxKey struct{} | ||
|
||
type bodyActiveCountCtxKey struct{} | ||
|
||
func WithExtensions(ctx context.Context, ext *schema.BodyExtensions) context.Context { | ||
return context.WithValue(ctx, bodyExtCtxKey{}, ext) | ||
} | ||
|
||
func WithActiveCount(ctx context.Context) context.Context { | ||
return context.WithValue(ctx, bodyActiveCountCtxKey{}, true) | ||
} | ||
|
||
func ExtensionsFromContext(ctx context.Context) (*schema.BodyExtensions, bool) { | ||
ext, ok := ctx.Value(bodyExtCtxKey{}).(*schema.BodyExtensions) | ||
return ext, ok | ||
} | ||
|
||
func ActiveCountFromContext(ctx context.Context) bool { | ||
return ctx.Value(bodyActiveCountCtxKey{}) != nil | ||
} |
This file contains 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
Oops, something went wrong.