1
1
package decoder
2
2
3
3
import (
4
+ "context"
4
5
"fmt"
5
6
6
7
"github.com/hashicorp/hcl-lang/lang"
@@ -13,7 +14,7 @@ import (
13
14
//
14
15
// Schema is required in order to return any candidates and method will return
15
16
// error if there isn't one.
16
- func (d * PathDecoder ) CandidatesAtPos (filename string , pos hcl.Pos ) (lang.Candidates , error ) {
17
+ func (d * PathDecoder ) CandidatesAtPos (ctx context. Context , filename string , pos hcl.Pos ) (lang.Candidates , error ) {
17
18
f , err := d .fileByName (filename )
18
19
if err != nil {
19
20
return lang .ZeroCandidates (), err
@@ -37,10 +38,10 @@ func (d *PathDecoder) CandidatesAtPos(filename string, pos hcl.Pos) (lang.Candid
37
38
outerBodyRng = ob .Range ()
38
39
}
39
40
40
- return d .candidatesAtPos (rootBody , outerBodyRng , d .pathCtx .Schema , pos )
41
+ return d .candidatesAtPos (ctx , rootBody , outerBodyRng , d .pathCtx .Schema , pos )
41
42
}
42
43
43
- func (d * PathDecoder ) candidatesAtPos (body * hclsyntax.Body , outerBodyRng hcl.Range , bodySchema * schema.BodySchema , pos hcl.Pos ) (lang.Candidates , error ) {
44
+ func (d * PathDecoder ) candidatesAtPos (ctx context. Context , body * hclsyntax.Body , outerBodyRng hcl.Range , bodySchema * schema.BodySchema , pos hcl.Pos ) (lang.Candidates , error ) {
44
45
if bodySchema == nil {
45
46
return lang .ZeroCandidates (), nil
46
47
}
@@ -50,10 +51,10 @@ func (d *PathDecoder) candidatesAtPos(body *hclsyntax.Body, outerBodyRng hcl.Ran
50
51
for _ , attr := range body .Attributes {
51
52
if d .isPosInsideAttrExpr (attr , pos ) {
52
53
if aSchema , ok := bodySchema .Attributes [attr .Name ]; ok {
53
- return d .attrValueCandidatesAtPos (attr , aSchema , outerBodyRng , pos )
54
+ return d .attrValueCandidatesAtPos (ctx , attr , aSchema , outerBodyRng , pos )
54
55
}
55
56
if bodySchema .AnyAttribute != nil {
56
- return d .attrValueCandidatesAtPos (attr , bodySchema .AnyAttribute , outerBodyRng , pos )
57
+ return d .attrValueCandidatesAtPos (ctx , attr , bodySchema .AnyAttribute , outerBodyRng , pos )
57
58
}
58
59
59
60
return lang .ZeroCandidates (), nil
@@ -132,7 +133,7 @@ func (d *PathDecoder) candidatesAtPos(body *hclsyntax.Body, outerBodyRng hcl.Ran
132
133
return lang .ZeroCandidates (), err
133
134
}
134
135
135
- return d .candidatesAtPos (block .Body , outerBodyRng , mergedSchema , pos )
136
+ return d .candidatesAtPos (ctx , block .Body , outerBodyRng , mergedSchema , pos )
136
137
}
137
138
}
138
139
}
0 commit comments