Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
jpogran committed Oct 6, 2022
1 parent 2b2b977 commit f0987e8
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion decoder/semantic_tokens.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package decoder

import (
"context"
"log"
"sort"

"github.com/zclconf/go-cty/cty"
Expand Down Expand Up @@ -53,12 +54,14 @@ func (d *PathDecoder) tokensForBody(ctx context.Context, body *hclsyntax.Body, b
if _, ok := body.Attributes["count"]; ok {
// append to context we need count provided
ctx = icontext.WithActiveCount(ctx)
log.Printf("Found Expression: ")
}
}
}

for name, attr := range body.Attributes {

log.Printf("Found: %q / %v+", name, bodySchema.Extensions)
attrSchema, ok := bodySchema.Attributes[name]
if !ok {
if bodySchema.Extensions != nil && name == "count" && bodySchema.Extensions.Count {
Expand Down Expand Up @@ -90,6 +93,8 @@ func (d *PathDecoder) tokensForBody(ctx context.Context, body *hclsyntax.Body, b
})

ec := ExprConstraints(attrSchema.Expr)
countAvailable := icontext.ActiveCountFromContext(ctx)
log.Printf("Found Expression: countAvailable %q ", countAvailable)
tokens = append(tokens, d.tokensForExpression(ctx, attr.Expr, ec)...)
}

Expand Down Expand Up @@ -170,7 +175,10 @@ func (d *PathDecoder) tokensForExpression(ctx context.Context, expr hclsyntax.Ex
},
}
countAvailable := icontext.ActiveCountFromContext(ctx)
if address.Equals(countIndexAttr) && countAvailable {
// TODO why is countAvailable not true here?
log.Printf("Found Expression: %q / %q - %v+", countAvailable, address.Equals(countIndexAttr), address)
// if address.Equals(countIndexAttr) && countAvailable {
if address.Equals(countIndexAttr) {
traversal := eType.AsTraversal()
tokens = append(tokens, lang.SemanticToken{
Type: lang.TokenTraversalStep,
Expand Down

0 comments on commit f0987e8

Please sign in to comment.