Skip to content

Commit 0a1ffa5

Browse files
committed
formatting
1 parent dc65e6d commit 0a1ffa5

File tree

5 files changed

+10
-17
lines changed

5 files changed

+10
-17
lines changed

decoder/expression_candidates.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@ import (
77
"strconv"
88
"strings"
99

10-
"github.com/zclconf/go-cty/cty"
11-
1210
"github.com/hashicorp/hcl-lang/lang"
1311
"github.com/hashicorp/hcl-lang/reference"
1412
"github.com/hashicorp/hcl-lang/schema"
1513
"github.com/hashicorp/hcl/v2"
1614
"github.com/hashicorp/hcl/v2/hclsyntax"
15+
"github.com/zclconf/go-cty/cty"
1716
)
1817

1918
func (d *PathDecoder) attrValueCandidatesAtPos(ctx context.Context, attr *hclsyntax.Attribute, schema *schema.AttributeSchema, outerBodyRng hcl.Range, pos hcl.Pos) (lang.Candidates, error) {

decoder/hover.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@ import (
66
"sort"
77
"strings"
88

9-
"github.com/zclconf/go-cty/cty"
10-
119
"github.com/hashicorp/hcl-lang/lang"
1210
"github.com/hashicorp/hcl-lang/reference"
1311
"github.com/hashicorp/hcl-lang/schema"
1412
"github.com/hashicorp/hcl/v2"
1513
"github.com/hashicorp/hcl/v2/hclsyntax"
14+
"github.com/zclconf/go-cty/cty"
1615
)
1716

1817
func (d *PathDecoder) HoverAtPos(ctx context.Context, filename string, pos hcl.Pos) (*lang.HoverData, error) {
@@ -56,7 +55,6 @@ func (d *PathDecoder) hoverAtPos(ctx context.Context, body *hclsyntax.Body, body
5655

5756
for name, attr := range body.Attributes {
5857
if attr.Range().ContainsPos(pos) {
59-
6058
if bodySchema.Extensions != nil {
6159
if name == "count" && bodySchema.Extensions.Count {
6260
return countAttributeHoverData(attr.Range()), nil

decoder/hover_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@ import (
88
"testing"
99

1010
"github.com/google/go-cmp/cmp"
11-
"github.com/zclconf/go-cty-debug/ctydebug"
12-
"github.com/zclconf/go-cty/cty"
13-
1411
"github.com/hashicorp/hcl-lang/lang"
1512
"github.com/hashicorp/hcl-lang/schema"
1613
"github.com/hashicorp/hcl/v2"
1714
"github.com/hashicorp/hcl/v2/hclsyntax"
1815
"github.com/hashicorp/hcl/v2/json"
16+
"github.com/zclconf/go-cty-debug/ctydebug"
17+
"github.com/zclconf/go-cty/cty"
1918
)
2019

2120
func TestDecoder_HoverAtPos_noSchema(t *testing.T) {

decoder/semantic_tokens.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@ import (
44
"context"
55
"sort"
66

7-
"github.com/zclconf/go-cty/cty"
8-
97
"github.com/hashicorp/hcl-lang/lang"
108
"github.com/hashicorp/hcl-lang/reference"
119
"github.com/hashicorp/hcl-lang/schema"
1210
"github.com/hashicorp/hcl/v2"
1311
"github.com/hashicorp/hcl/v2/hclsyntax"
12+
"github.com/zclconf/go-cty/cty"
1413
)
1514

1615
// SemanticTokensInFile returns a sequence of semantic tokens
@@ -46,7 +45,6 @@ func (d *PathDecoder) tokensForBody(ctx context.Context, body *hclsyntax.Body, b
4645
return tokens
4746
}
4847

49-
// TODO: test for count extension used in root BodySchema
5048
if bodySchema.Extensions != nil {
5149
if bodySchema.Extensions.Count {
5250
if _, ok := body.Attributes["count"]; ok {
@@ -125,7 +123,6 @@ func (d *PathDecoder) tokensForBody(ctx context.Context, body *hclsyntax.Body, b
125123
}
126124

127125
if block.Body != nil {
128-
// TODO: Test for count.index in a sub-block
129126
if blockSchema.Body != nil && blockSchema.Body.Extensions != nil {
130127
if blockSchema.Body.Extensions.Count {
131128
if _, ok := block.Body.Attributes["count"]; ok {
@@ -164,6 +161,7 @@ func (d *PathDecoder) tokensForExpression(ctx context.Context, expr hclsyntax.Ex
164161
}
165162

166163
address, _ := lang.TraversalToAddress(eType.AsTraversal())
164+
countAvailable := schema.ActiveCountFromContext(ctx)
167165
countIndexAttr := lang.Address{
168166
lang.RootStep{
169167
Name: "count",
@@ -172,16 +170,16 @@ func (d *PathDecoder) tokensForExpression(ctx context.Context, expr hclsyntax.Ex
172170
Name: "index",
173171
},
174172
}
175-
countAvailable := schema.ActiveCountFromContext(ctx)
176-
// TODO why is countAvailable not true here?
177-
// if address.Equals(countIndexAttr) && countAvailable {
173+
178174
if address.Equals(countIndexAttr) && countAvailable {
179175
traversal := eType.AsTraversal()
176+
180177
tokens = append(tokens, lang.SemanticToken{
181178
Type: lang.TokenTraversalStep,
182179
Modifiers: []lang.SemanticTokenModifier{},
183180
Range: traversal[0].SourceRange(),
184181
})
182+
185183
tokens = append(tokens, lang.SemanticToken{
186184
Type: lang.TokenTraversalStep,
187185
Modifiers: []lang.SemanticTokenModifier{},

decoder/semantic_tokens_expr_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@ import (
66
"testing"
77

88
"github.com/google/go-cmp/cmp"
9-
"github.com/zclconf/go-cty/cty"
10-
119
"github.com/hashicorp/hcl-lang/lang"
1210
"github.com/hashicorp/hcl-lang/reference"
1311
"github.com/hashicorp/hcl-lang/schema"
1412
"github.com/hashicorp/hcl/v2"
1513
"github.com/hashicorp/hcl/v2/hclsyntax"
14+
"github.com/zclconf/go-cty/cty"
1615
)
1716

1817
func TestDecoder_SemanticTokensInFile_expressions(t *testing.T) {

0 commit comments

Comments
 (0)