@@ -11,59 +11,6 @@ import (
1111 "github.com/terraform-linters/tflint-plugin-sdk/tflint"
1212)
1313
14- // WalkExpressions visits all expressions, including those in the file before merging.
15- // Note that it behaves differently in native HCL syntax and JSON syntax.
16- // In the HCL syntax, expressions in expressions, such as list and object are passed to
17- // the walker function. The walker should check the type of the expression.
18- // In the JSON syntax, only an expression of an attribute seen from the top level of the file
19- // is passed, not expressions in expressions to the walker. This is an API limitation of JSON syntax.
20- //
21- // XXX: Should be moved to SDK?
22- func WalkExpressions (r tflint.Runner , walker func (hcl.Expression ) error ) error {
23- visit := func (node hclsyntax.Node ) hcl.Diagnostics {
24- if expr , ok := node .(hcl.Expression ); ok {
25- if err := walker (expr ); err != nil {
26- // FIXME: walker should returns hcl.Diagnostics directly
27- return hcl.Diagnostics {
28- {
29- Severity : hcl .DiagError ,
30- Summary : err .Error (),
31- },
32- }
33- }
34- }
35- return hcl.Diagnostics {}
36- }
37-
38- files , err := r .GetFiles ()
39- if err != nil {
40- return err
41- }
42- for _ , file := range files {
43- if body , ok := file .Body .(* hclsyntax.Body ); ok {
44- diags := hclsyntax .VisitAll (body , visit )
45- if diags .HasErrors () {
46- return diags
47- }
48- continue
49- }
50-
51- // In JSON syntax, everything can be walked as an attribute.
52- attrs , diags := file .Body .JustAttributes ()
53- if diags .HasErrors () {
54- return diags
55- }
56-
57- for _ , attr := range attrs {
58- if err := walker (attr .Expr ); err != nil {
59- return err
60- }
61- }
62- }
63-
64- return nil
65- }
66-
6714type moduleCall struct {
6815 name string
6916 defRange hcl.Range
0 commit comments